充分理解.NET版本和向后兼容性 [英] Fully understanding the .NET versions and backward compatibility

查看:176
本文介绍了充分理解.NET版本和向后兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.NET 2.0的应用程序,我打算做一个智能安装程序,这检查可用的.NET版本在用户的PC上并安装特定的端口吧。 我看到的是:

  • 的Windows XP(SP2)自带.NET 2.0
  • 在Windows Vista中自带.NET 3.0
  • 在Windows 7中自带.NET 3.5
  • 在Windows 8中自带.NET 4.5

据我所知,唯一的事情,是不是向后兼容的CLR版本,这是后.NET 4.0改变了。

所以,如果我不希望用户安装额外的框架,只是为了我的申请,我应该有这些版本我的应用程序的:

  • 在.NET 2.0 - XP(SP2和上层),远景(3.0应该可以运行2.0)和7(3.5应该可以运行2.0)
  • 在.NET 4.0 - 如果有人安装了4.0和只没有其他
  • 在.NET 4.5 - 对于有Windows 8的,没有其他.NET安装
  • 用户

我说得对不对?或4.5 / 4.0的向后兼容?

编辑:如果有任何上层的数据是不正确的,请指正

解决方案
  

据我所知,唯一的事情,是不是向后兼容的CLR版本,这是后.NET 4.0改变了。

这心不是真实的。您可以在.NET4框架您.NET2编译的应用程序运行。

您只需要以下内容添加到您的app.config:

 <结构>
<启动>
    < supportedRuntime版本=V2.0.50727/>
    < supportedRuntime版本=4.0版的SKU =NETFramework,版本= V4.0,外形=客户/>
    < supportedRuntime版本=4.0版的SKU =NETFramework,版本= V4.0/>
  < /启动>
< /结构>
 

请注意,我同意@KingKronus,即为什么不挑最小公分母?

在你的情况下,这将是.NET2编译和只有一套PDBS和一个汇编集。

是的,你需要测试你的.NET2编译应用程序运行在.NET4运行正常,但你需要反正来测试你原来的解决方案,在每个框架的应用程序。

I have a .NET 2.0 application and I plan to make a 'smart installer' which checks for the available .NET version on the user's PC and install my specific port for it. I saw that:

  • Windows XP (SP2) comes with .NET 2.0
  • Windows Vista comes with .NET 3.0
  • Windows 7 comes with .NET 3.5
  • Windows 8 comes with .NET 4.5

As far as I know, the only thing that's not backward compatible is the CLR version, which is changed after .NET 4.0.

So if I don't want the user to install additional framework just for my application, I should have these versions of my app:

  • .NET 2.0 - XP (SP2 and upper), Vista (3.0 should be able to run 2.0) and 7 (3.5 should be able to run 2.0)
  • .NET 4.0 - if someone installed 4.0 ONLY and have no other
  • .NET 4.5 - for the users that have Windows 8 with no other .NET installed

Am I right? Or 4.5/4.0 are backward compatible?

EDIT: If any of the upper data isn't right, please correct me

解决方案

As far as I know, the only thing that's not backward compatible is the CLR version, which is changed after .NET 4.0.

This isnt true. You can make your .NET2 compiled application run on the .NET4 framework.

You just need to add the following to your app.config:

<configuration>
<startup>
    <supportedRuntime version="v2.0.50727"/>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

Note, I agree with @KingKronus, ie Why not just pick the lowest common denominator?

In your case that would be .NET2 compiled and only one set of pdbs and one compilation set.

Yes, you would need to test your .NET2-compiled app runs OK on the .net4 runtime BUT you would need to test your app in each of the frameworks in your original solution anyway.

这篇关于充分理解.NET版本和向后兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆