This is NOT a Programming doubt!
I am going to write a DLL for some application. I have two options to choose from: C++ or C# In which language I should write DLL?
Does that affects functionality?
I am a completely newbie and Unaware of both C++ and C# (but Some Small programs in C#).
What are Pros and Cons about Writting DLL in C++ or C#?
Thank You very much for your time!
Regards, Swanand!
A DLL is best written in C :)
Let me explain:
DLL's were conceived before C++ came into mainstream use. They were created for the C language. You can write DLL's with C++ but you'll be able to easily use them only from applications that were written with the same version of the same compiler as the DLL. A C DLL can be used from .NET, unlike C++ (yeah, I know, technically it can, but it is a pain in the buttocks).
If you create DLL with C#(or any other .NET language), it's a completely other thing - it's not a windows DLL, it's just a .Net assembly without an entry point(Main), so it can be used from other .NET assemblies by referencing the DLL.
To summarize:
If you need to use your DLL from .NET languages - write it in C#, it won't be a windows dll, just an assembly. Very easy to use.
If you need to use your DLL from ONLY C++ and ONLY from applications written by the same compiler, write in C++. Not portable, easy to use.
If you want to create a general-purpose library that can be used from .NET, C, C++ and regardless of the compiler, use C, or C++ freestanding functions marked as extern "C" and having C-like parameters, like pointers and POD's.
HTH
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