Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to call a managed DLL from unmanaged C++?

Tags:

c++

.net

interop

Is it possible to call CLR DLL (one for example which is made with C#) from unmanaged C++ code?

I need a DLL that is not managed to call into it somehow, maybe even via some proxy C++ process that is built with C++ / CLI?

like image 360
Net Citizen Avatar asked Jun 16 '10 14:06

Net Citizen


People also ask

Is dll managed or unmanaged?

dll is definitely unmanaged - it's part of Windows. If you want to check, try to add the file as a reference to your project - if it adds ok, it's managed.

Can we write unmanaged code in C#?

No, there is no such thing as unmanaged C#. C# code will be always compiled into the IL code and executed by CLR. It is the case of managed code calling unmanaged code. Unmanaged code can be implemented in several languages C/C++/Assembly etc, but CLR will have no idea of what is happening in that code.

What is the difference between managed and unmanaged languages?

Difference between managed and unmanaged code? Managed code is the one that is executed by the CLR of the . NET framework while unmanaged or unsafe code is executed by the operating system. The managed code provides security to the code while undamaged code creates security threats.

Is C# managed or unmanaged?

Similar to this, C# is one language that allows you to use unmanaged constructs such as pointers directly in code by utilizing what is known as unsafe context which designates a piece of code for which the execution is not managed by the CLR.


1 Answers

The CLR DLL would have to be built as a COM visible assembly. If you have control of the C#, it's a simple rebuild, otherwise, is pretty much impossible to use it directly.

like image 134
SWeko Avatar answered Sep 17 '22 15:09

SWeko