0
votes

Using VS2010, I am working on wrapping a large number of .h files and one .lib from native C++ (using MFC) to C++/CLI for eventual use as a referenced .dll in C#.

While creating the wrapper I'm getting compiler errors stating CObject is undefined. In the project properties I have set use of MFC to use MFC in a static library and runtime library to multi-threaded debug DLL (/MDd). I am linking the .lib and including the .h files. The compiler errors are in the .h files where some of the classes are inheriting from CObject.

Shouldn't the compiler know about CObject?

1
A managed ref class cannot inherit from a native class like CObject. - Hans Passant

1 Answers

0
votes

Are you #including the MFC headers? afx.h, afxwin.h, anything like that? It's possible that #include was in stdafx.h in your native C++ project, and didn't get copied into the header files that you're using in your C++/CLI project.