Call a dot-net dll from C++

A

AHN

Hi, please instruct somebody how to call a dll written in dot-net from a C++
program. Thanks
 
N

Nicholas Paldino [.NET/C# MVP]

AHN,

You have two options. The first is to expose your .NET dll through COM,
and then access your .NET objects through COM in your C++ program.

The other option is to use mixed mode development in C++, which will
allow you to run sections of managed and unmanaged code together.

Hope this helps.
 
A

AHN

Thanks a lot, could you please be a little more specific. A small code
snippet, maybe. How'm I exposing dll through COM?
Where to look? Thank you.

message AHN,

You have two options. The first is to expose your .NET dll through COM,
and then access your .NET objects through COM in your C++ program.

The other option is to use mixed mode development in C++, which will
allow you to run sections of managed and unmanaged code together.

Hope this helps.
 
A

AHN

That is just for registering the dll. After that you need to reach it from
code which is elementary from unmanaged VB but very hard from (mainframe)
c++. Until now I haven't succeeded. The recipes in the help don't work so
far for me. Actually, you can create an old vb app calling a dot.net dll and
then access that vb dll from c++.

Hello

You can use REGASM (Assembly Registration Tool) for it, which allows COM
clients to create .NET Framework classes transparently.

See here:
http://msdn.microsoft.com/library/d...ml/cpgrfassemblyregistrationtoolregasmexe.asp
 
W

Willy Denoyette [MVP]

What exactly do you mean with (mainframe) C++?
Managed code can be called from C++ by means of:
- COM interop (this is the regasm stuff), or
- using a managed wrapper written in ME C++ (or the upcoming VS2005
C++/CLI).


Willy.
 

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