Managed code within unmanaged code ?

  • Thread starter Thread starter Marty
  • Start date Start date
M

Marty

Hi,

Can I mix my managed code within my unmanaged code?

Just for instance, I have a socket class that is managed code. It is
include in my unmanaged VC++ project and it compile.

The point is, when I want to instantiate my class, I still get this error:
fatal error C1190: managed targeted code requires '#using
<mscorlib.dll>' and '/clr' option

But this is already set in my class (right-click file properties).

At this time, only the socket class properties is configure to have the
/clr and mscorlib.dll. Should it be done for all the unmanaged project?

Any idea?

Thank you very much.

Marty
 
Marty said:
Can I mix my managed code within my unmanaged code?

Yes, you have a couple of options.
Just for instance, I have a socket class that is managed code. It is
include in my unmanaged VC++ project and it compile.

The point is, when I want to instantiate my class, I still get this error:
fatal error C1190: managed targeted code requires '#using <mscorlib.dll>'
and '/clr' option

The simplest thing to do is to set your unmanaged prooject properties so
that it compiles with the /CLR switch:

Project->Properties

from the menu

Click on the Configuration Properties folder and select General and then
scroll down to use Managed Extensions in the right pane.

Then in a module where you want to use both modes, use this to separate the
managed and unmanaged functions

#using <mscorlib.dll>

#pragma unmanaged
 
Back
Top