Let’s say I have written a Class Library (dll) in .Net and now I have developers using it in their .Net applications.
However, the library itself could probably be useful also for developers writing natively (in C or C++). So my question is if my managed dll can be used in C or C++?
If not, why? Maybe I must add some specific code to make it available to native coders?
Thanks.
EDIT: In case anyone else is interested in this issue, I found this article from Google Books which gives an introduction how to use Net.classes from COM.
The only way to expose a .NET assembly outside of a CLR-based language is through COM Interop. There is nothing that you can do to reference a .NET .dll directly in an unmanaged language.
The reason for this is that the “.dll” file extension used is purely for appearances and the illusion of consistency. .NET generated .dll files do not contain any machine code, they contain IL (intermediate language) that is compiled at runtime (called Just-In-Time compilation, or JIT). The code is not compiled at the time that it is placed in the .dll file. As a result, there is nothing for the unmanaged language to execute.
COM interop allows the CLR to load the .dll, perform that JIT compilation, and use the COM system to handle communication between the native code and the .NET .dll.