Tuesday, February 10, 2009

A problem of forward declaration in C++/CLI

Today while I started debugging my program, the programmed stopped at
Assembly assembly=Assembly.Load(name)
foreach(Type type in assembly.GetTypes()
{
...
}
and the output window showed:
First-chance exception at 0x7c81eb33 (kernel32.dll) in myprogramm.exe: Microsoft C++ exception: EETypeLoadException at memory location 0x0012d324..
First-chance exception at 0x7c81eb33 (kernel32.dll) in myprogramm.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
A first chance exception of type 'System.Reflection.ReflectionTypeLoadException' occurred in mscorlib.dll
Later I found that all these happens due to a unresolved forward declaration of a ref class. but the unresolved native class will not cause the problem.

So be caution when you are using the forward declaration for a ref class.

No comments: