views:

59

answers:

2

Hello,

I am calling LoadTypeLib for loading unmanaged type libraries in C++/CLI. I need to compile some code(some code areas) as managed and some code areas as unmanaged(native) code and form a mixed mode class library as executable.

What i need to mention between the lines of code so that whatever the part i need to be compiled as managed should compiled as managed and what part I need to be unmanaged(native) should be compiled as native?

Regards Usman

+1  A: 

#pragma managed

Prefer using #pragma managed with push and on/off, then pop, #pragma unmanaged is actually quite useless.

Ben Voigt
+1  A: 

Don't use #pragma managed - it's considered "evil" and may cause problems with DLL init/shutdown.

I would recommend explicitly compiling some files as managed (/clr), and some as native (without /clr). You can also have two pre-compiled headers - one for managed, one for native.

Filip