开发者

Do I have to build a separate release of my class library for each version of .net?

I'm pretty sure the answer is yes, but I haven't found a question that asks this outright.

My product is a set of .NET class libraries. The applications that use them and their config files are entirely out of my control. I had (mistakenly, I believe) thought that if the libraries were built against .NET 2.0, they could be used with later versions. After a recent user problem, I have dug into the situation in more detail, and if I understand correctly, compatibility is only compile-time and not runtime (unless specified in the app config.)

So do I have to build it against each framework version users want to target, or is there a way to produce a class library that is version-independen开发者_开发百科t?


Unless your class library is mixed mode, you should be able to use a .NET 2.0 class library from a .NET 4 application with no problems. (I assume you've built "Any CPU" assemblies.) I've done this on many occasions.

You should be okay, but if you have a specific error I suggest you put together a short but complete program which demonstrates the problem, and include that in your question.


If you intend to target your application to use a runtime (.Net Framework) that is different from the one that was used to build your application, you will need to rebuild.


I believe you can specify the target framework in teh app.config file, like this:

<configuration>
   <startup>
      <supportedRuntime version="v2.0.50727"/>
   </startup>
</configuration>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜