I have a C++/CLI form, and a native class in separate files.

I include the header file of the native class at the top of the Form.h

This causes the compiler to try to compile the constructor of the Form as a native function and spits out 100+ errors and causes the compilation to halt.

Any ideas why?

6 Years
Discussion Span
Last Post by jonsca

What /clr setting do you have set for the compilation? If you don't have any on there, it will try to compile your code as native.


I added a #pragma managed before the form's definition and it works fine now. <shrug> the clr settings are correct.


Good to know. I'll have to keep my eyes out for some guidelines about this kind of thing. I'm starting to figure out a bit more about the optimizations of the managed code and the juggling act that goes on with the unmanaged pieces, but in terms of the settings it's confusing.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.