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:
The concept of DLL's was created when ther was no today's C++. It was created for C. 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
It will depend upon your target application. If you are writing Win32 app, then C++ may be wise choice. If you are developing a reusable library in .NET chose C#.
When you say C++ are you referring to the Standard C++ or the "Managed" version?
If you are referring to the latter then you are no worse off than writing in C# as Managed C++ is an alternative .NET language, and actually I think you have more functionality available, although it is not as simple a language to write in as C#.
Pros and cons dont change for a library if you mean managed c++. But for the coding, ease of use and available libraries matters.
I would suggest c# since you say you are newbie. Its much more easy and you have LOTS of sources online.
But if you plan to use some native code and need CLR support then c++ is the only choice.
Good luck