Call managed code from unmanaged code

N

Nicholas Paldino [.NET/C# MVP]

Holger,

There are two ways. The first is to export your objects as COM
components.

The second is to use C++ and use the /clr switch, which will allow you
to access managed assemblies.

Hope this helps.
 
W

Willy Denoyette [MVP]

Holger Kasten said:
How to call managed code from unmanaged code?

It depends, first what do you call unmanaged code, more exactly what's the
language of implementation?
If it's native C++ you have two options:
- write a mixed code wrapper using Managed C++ (or the upcoming C++/CLI),
or.
- expose your C# classes as COM objects (check MSDN for details on COM
interop), and change your C code such that you can call into COM.
If it's VB6 or Delphi or another language that supports COM natively, your
bets bet is to expsose your C# classes as COM interfaces.
Note however that COM interop puts some constraints on the classes and types
passed to/from unmanaged code.

Willy.
 
H

Holger Kasten

Thx for your reply!



So this would allow me to create a C++ dll which could be a general
wapper for calls to my .net asemblies?

And I could use that dll from all regular W32 apps?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top