I'm building a DLL class library - I want to make it usable by as many people as possible. Which version of the .NET Framework and which C# version should I use? Is it possible to produce a backwards-compatible DLL or different DLLs for different versions? Or does Windows automatically update the .NET framework so I should just use the latest version? Any guidance appreciated!
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
try this:
switch targetting mode to framework 2.0 (removing System.Core reference).
if it not compile, than try adding a reference to linqbridge.dll:
If not, then you should target 3.5 ;)
Combined with using an approach like the one mentioned by Will Hughes, if you want the access / option to use newer features when available, during active development, use the latest framework. When ready to start making release candidates, set to the lowest framework, and then when issues arrive, steadily bump up the framework version and / or use the #ifdef approach to work out.
I don't think anyone uses .Net 1.1 anymore. So unless you really want to use 3.5 features 2.0 should be fine. Also if you have control over who's going to actually use your library then it depends on them too. If they have the latest framework then you could use that.
I vote for Erik van Brakel's answer. Also I would like to suggest that if you want to support 3.5 features like LINQ and Extension methods, you may create an additional library, say
MyLibrary.DLL
MyLibrary.LINQ.dll
thus using the same approach as MS did (when they left System.dll 2.0 version but added all new features into System.Core.dll)
It depends on what the dll is for. If it just has a generic C# logic that you would like to make available to others, then .net 2.0 is probably your best bet. However if it has anything to do with the newer features in .net like WPF, EF, WCF, silverlight, ect then it will need to be in the version of .net that supports that particular feature.
Personally, I would say write it in .net 3.5 only because making the jump from .net2.0 to .net3.5 is pretty painless because there is not many breaking changes unlike the jump from .net1.x to .net2.0. :)
I would target version 2.0 with the library containing the core functions and add an extra library targeting 3.5 to add some extension methods based on your core library.