Call C # dll from an unmanaged C ++ application without COM

Is there a way to call C # dll from an unmanaged C ++ application without using COM?

+5
source share
4 answers

You can do this using Reverse P/Invoke - an example and discussion here .

+5
source

In fact, you can parse, modify IL, and assemble it with exported functions. I confused this several years ago and created an application that would parse DLLs, provide a list of functions that could potentially be exported, allowing the user to select them, and then rewrite IL and compile everything. Then I could call the dll directly from the unmanaged code ... or p-invoke the dll from the managed code (not very practical, but interesting nonetheless).

Of course, there is a reason that this is not supported in the .net languages ​​themselves (even if it is supported in MSIL). I would not use this in production:

Dead link: http://www.csharphelp.com/2007/03/exporting-managed-code-as-unmanaged/ Strike>

Wayback Machine: https://web.archive.org/web/20140213030149/http://www.csharphelp.com/2007/03/exporting-managed-code-as-unmanaged/

+2
source

I may be a little late, but check this one out.

Using this small msbuild task, you can create a C # library that can be called as if it were a native DLL. (e.g. write plugins for applications that require them to be native DLLs)

Oh, and don't forget to use a project template that will customize everything for you.

+1
source

Your only option is to either use C ++. net, or create a C ++ .NET wrapper for it, which exports what you need.

Call C # code from C ++

0
source

All Articles