MC++ FAQ
Monday 04 | 14 | 2003
TypeLoadException in code using common controls
If you're mixing unmanaged and managed code in your MC++ applications, and the unmanaged code uses the common controls (either directly or through MFC), you might run into unexpected System::TypeLoadException exceptions at runtime, similar to this:
An unhandled exception of type 'System.TypeLoadException' occurred in 
X.exe

Additional information: Could not load type _TREEITEM from assembly
X....

You might find this error with other types, too, such as _IMAGELIST.

The reason for this is because these types are not defined in the windows headers, but only forward declarations are provided, which cause the MC++ compiler not to generate metadata for them.

There is one easy workaround for this, and that is to provide empty definitions of them in one of your .CPP files in the project, like this:

struct _IMAGELIST { };
struct _TREEITEM { };
Posted by tomasr at April 14, 2003 11:24 PM
Comments

This helps lots!!! Thanks!!!

Posted by: Susan on March 26, 2004 04:51 PM

This doesn't work for me.
I am combining unmanaged c++ code in the .NET project which we create for writing managed c++ code.

I am getting the same exception as above. And I have included class GLUquadric {}; inone of my .cpp files. But it is still showing the same exception. can any body help me.

Posted by: aravind on April 9, 2004 01:26 PM

Now it works.
The problem is I have to add the class GLUquadric{} declaration in all the files that uses the GLUquadricObj declarations.

thanks & sorry

Posted by: aravind on April 9, 2004 01:46 PM
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?

Copyright(C) 2002, Tomas Restrepo, All rights reserved. Powered by Movable Type 2.63