I have a DLL that I wrote in C# and I want to use it both with C# applications and applications written in unmanaged VC++. Is this possible?
No. DLL is PL specific. In visual studio you have COM objects which can be used in other VS based PLs. You can use sockets with client and server topology to talk from one program to another program.
DLL files use languages like C or C++, although you'll see C++ more often. You can write your own DLLs to run some code you need if you're willing to learn how to do it. It could be valuable to your project and of course it could make you look good in return.
In Windows, a dynamic-link library (DLL) is a kind of executable file that acts as a shared library of functions and resources. Dynamic linking is an operating system capability. It enables an executable to call functions or use resources stored in a separate file.
To supplement other answers here, here's the MS support article which describes your scenario.
http://support.microsoft.com/kb/828736
Well, seems I have to bring up my unmanaged exports again. ;-)
Just answered a similar question 2 days ago. This totally works in C#, and it even creates a .lib & .exp file for your C# assembly to be consumed by C++:
internal class Sample
{
[DllExport("_export_test", CallingConvention.Cdecl)]
static int Test(int a)
{
return a + 1;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With