Conversion from C++ to /clr yields 'LNK4248 unresolved typeref tok

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My first attempt to convert a fairly complex C++ project to MC++ using the
/clr switch has several problems. The source compiles fine (with deprecated
warnings of course). The linker emits several LNK4248 messages all related
to _IMAGELIST and _TREEITEM. When I try to execute the application, a dialog
popups saying, "An unhandled exception of type 'System.MissingFieldExcepton'
occured in Unknow Module."

So,

1) How do I fix the LNK4248 messages (I would have thought the compiler
would have known about MS structures).
2) How do I even begin to unravel the fatal runtime error?
3) Does the usage of 3rd party COM objects of itself yield problems using
the /clr switch?

Thanks for any help
 
Add empty definitions of both structures. The linker will do that
automatically for you in VC 2005 (and give a warning).

This is because the CLR internally does not support using a pointer to an
undefined class. These 2 structures are never defined in the Windows
headers. In native C++ this is not an error as long as you don't try to
deference anything of it, in the CLR just creating the pointer is illegal.

Ronald Laeremans
Visual C++ team
 
Back
Top