开发者

Is there a difference between a .DLL compliled for .Net 4 and .Net 3.0?

I created a .DLL targetting .Net 4 but now I'm thinking of compiling it to .Net 3.0 so people using Visual Studio 2008 can use the DLL.

Is there a difference between a .DLL compliled for .Net 4 and .Net 3.0?

That is, should I create two DLLs (one for each framework) because it's better to use a DLL compiled to the framework your targetting? or should I just offer one compiled to .Net 3.0 and let VS2010 users use that one because there is no difference in using a DLL compiled to a previous framework?

Thanks,

Update: I should have been more explicit and have added "aside from needing the required framework". In other words, is there any difference between, from a .Net 4 project, referencing a DLL compiled in .Net 3.0 and on开发者_开发百科e compiled in .Net 4? Assuming they both use .Net 3.0 syntax, do you gain/lose anything by using either one?


If your assembly is not using any features specific to 4.0, it is probably easiest to just compile a 3.0 version of it and use that for both. (actually, you can go all the way down to version 2.0 if your code allows it, as framework versions 3.0 and 3.5 are each supersets of 2.0)

If your library ever did have separate code for different versions; for maximum flexibility, you can create a separate project for 3.0 and 4.0 versions, and 'link' the same source files rather than having separate copies. You would use preprocessor directives if you ever need to code differently per framework.


Is there a difference between a .DLL compliled for .Net 4 and .Net 3.0?

Yes, there is a difference. When you compile a library for .NET 4.0 it will link against mscorlib, v4.0.0.0 and if there's no .NET 4.0 installed on the target machine it won't work. On the other hand if you compile against .NET 3.5 it will link against mscorlib, v2.0.0.0 and it will work on machines that have .NET 3.5 or later installed (assuming of course this library doesn't have some other special dependencies).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜