Calling managed code

G

Guest

Hi,

I just created a solution that is based on unmanaged C++ code. Now, the .net
framework consists of some cool functions and classes - there is especially
one namespace I'd like to use.
That's why I'm currently trying to figure out what's the best way to use
this managed code snippet.
Is it possible to create a managed Dll (in any language, C#,VB,C.net) and
call this out of my unmanged C++ code?
If not, is it possible to create an old-style C++ dll (for calling
convention) and to insert some managed code (just like building a 'hybrid')?

Thanks for any help
Peter
 
J

Jacky Kwok

Peter said:
Hi,

I just created a solution that is based on unmanaged C++ code. Now, the .net
framework consists of some cool functions and classes - there is especially
one namespace I'd like to use.
That's why I'm currently trying to figure out what's the best way to use
this managed code snippet.
Is it possible to create a managed Dll (in any language, C#,VB,C.net) and
call this out of my unmanged C++ code?
If not, is it possible to create an old-style C++ dll (for calling
convention) and to insert some managed code (just like building a 'hybrid')?

Thanks for any help
Peter

Yes, you can. However, I cannot confirm it is a safe method.

I have many cases which need to call Dotnet libraries from C/C++ native
code.

I will create a C/C++ DLL project in VS.NET and complie it with Assembly
Support (/clr).

The project exports native C DLL exported functions as normal.
However, in the functions, it calls to the Dotnet classes (e.g. in C#).

The C/C++ functions need to wrap any input/output parameters between
native and Dotnet datatype.


I still do not encounter any great problem by using this method.
 

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