June 3rd, 2009, 02:16 PM
CArchive exception - BadClass?
This problem relates to a previous thread, but since I've learned more about the problem it kind of seemed new and warranted a separate thread.
The main problem:
MFC DLL (being called from another executable) that used to be a COM DLL but I've removed COM and converted to an MFC DLL.
There is a class in there (CSequence) that is serialized with CArchive to create what we call sequence files. This project (all components) has been around a while and was in Visual Studio 6. It should read the sequence files in the known directory on startup, but is choking when it tries to read a sequence file.
Based on previous suggestions in first thread, I instrumented the old VS6 code and ran it to create text file versions of the sequence files. Then I wrote a quick console program to recreate binary sequence files the same way the regular software did. No data types changed sizes, the new sequence files were byte for byte exactly the same as the old ones. Wasted effort (other than knowledge gained).
When I run a trace statement shows up in Visual Studio (2005 now) that tells me the exception is a "BadClass" exception. That implies to me it is not finding my implementation of Serialize() to know what to do with it.
Doing some research (understanding problem more than I did in first post), I came across this MS Knowledgebase article.
It almost looks like its a known problem as I fall in to the EXE calling an MFC extension DLL category, but it also appears that it was fixed in a service pack or something before my current VS config and should be working. It mentions to look for the date on the Afx.h file to be a 2002 date or later and mine is a 2006 date.
Any idea if this is some known MS problem or if there is anything else to try?
BTW, I tested that quick little program I wrote to see if it could also load the new sequence file as it does in the regular program. It does the exact same thing that chokes in the DLL just fine. No issues. Which sounds more and more like that knowledge base article I linked.
Tags for this Thread
Click Here to Expand Forum to Full Width