Groups | Blog | Home
all groups > visual c libraries > february 2005 >

visual c libraries : Managed code within unmanaged code ?


William DePalo [MVP VC++]
2/18/2005 8:48:15 AM
[quoted text, click to view]

Yes, you have a couple of options.

[quoted text, click to view]

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

.
.
.

#pragma managed

.
.
.

If you are a COM junkie, from manged code you can treat your .Net components
as COM objects. See this for the details:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconpackagingassemblyforcom.asp

If you do that, the client of your object won't be required to be
implemented in managed code.

Regards,
Will



Marty
2/18/2005 1:07:19 PM
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.

OxyGen
2/18/2005 4:29:14 PM
Yes, you can find the answer of your question in QStat Sample at MSDN
Library.

"Marty" <xmarty99@hotmail.com> escribió en el mensaje
news:bMlRd.74885$L_3.20142@clgrps13...
[quoted text, click to view]

Marty
2/18/2005 5:13:48 PM
Thanks for the information guys

Have a nice day.

Marty

[quoted text, click to view]
AddThis Social Bookmark Button