.Net - Can a class library (dll) written in .Net be used by an application written in C or C ++?

Let's say I wrote a class library (dll) in .NET, and now I have developers using it in their .Net applications.

However, the library itself can probably be useful also for developers written initially (in C or C ++). So my question is, can my managed dll be used in C or C ++?

If not, why? Maybe I should add some code to make it available to native coders?

Thanks.

EDIT . If anyone else is interested in this issue, I found this article from Google Books that gives an idea of ​​how to use Net.classes from COM.

+3
source share
3 answers

The only way to show the .NET assembly outside the CLR is through COM Interop. You can do nothing to refer to .NET.dll directly in an unmanaged language.

The reason for this is that the .dll file extension is used solely for the visibility and illusion of consistency. The generated .NET .dll files do not contain machine code, they contain IL (intermediate language), which is compiled at run time (Just-In-Time or JIT compilation). The code does not compile when it is placed in a DLL file. As a result, nothing exists for an unmanaged language.

COM interop allows the CLR to load the DLL, execute this JIT compilation, and use the COM system to handle the communication between native code and .NET.dll.

+10

. , , , COM, , . Thoe C ++ Microsoft CLR .Net DLL. , Mono, DLL- .Net. (.. P/Invoke)

+1

, ++ COM-, , # ++. Visual Studio, Microsoft, . , . - CXXI ​​, Icaza .

0

Source: https://habr.com/ru/post/1716317/


All Articles