简体   繁体   English

针对Windows 8.x的.Net 4.0

[英].Net 4.0 targeting on windows 8.x

I'm a bit confused about targeting .net 4.0 app to run on windows 8.x. 我对将.net 4.0应用程序定位为在Windows 8.x上运行感到有些困惑。 In my understanding, windows 8.0 comes with 4.5 and windows 8.1 comes with 4.5.1. 以我的理解,Windows 8.0带有4.5,而Windows 8.1带有4.5.1。 So my question, if I build a WinForms or WPF client app targeting c#/.net 4.0 (in Visual Studio Project settings) and of course only using .net 4.0 features (ie, no features from .net 4.5.x), then will this app run fine on windows 8.x without having install .net 4.0 framework (that is, only relying on what comes installed with OS)? 因此,我的问题是,如果我构建针对c#/。net 4.0(在Visual Studio项目设置中)的WinForms或WPF客户端应用程序,并且当然仅使用.net 4.0功能(即,.net 4.5.x中没有功能),那么此应用程序无需安装.net 4.0框架即可在Windows 8.x上正常运行(也就是说,仅依赖于OS附带的功能)? Basically, I'm trying to avoid forcing end user to install .net 4.0 framework on their machine before running the app. 基本上,我试图避免强迫最终用户在运行应用程序之前在其计算机上安装.net 4.0框架。

Looking at DLLs properties of various Microsoft DLLs (eg, System) they show same runtime version when targeting either .net 4.0 or .net 4.5.x --> v4.0.30319. 查看各种Microsoft DLL(例如,System)的DLL属性时,它们针对.net 4.0或.net 4.5.x-> v4.0.30319时,它们显示的运行时版本相同。 So my understanding here is that 4.0 and 4.5.x are targeting same clr runtime version So, my .net 4.0 app should run fine??? 所以我的理解是4.0和4.5.x的目标是相同的clr运行时版本。因此,我的.net 4.0应用程序应该可以正常运行???

From ref here ( http://msdn.microsoft.com/en-us/library/bb822049%28v=vs.110%29.aspx ), it says .net 4.0 can't even be installed on win8.x. 从此处的ref( http://msdn.microsoft.com/zh-cn/library/bb822049%28v=vs.110%29.aspx ),它说.net 4.0甚至无法安装在win8.x上。

In my tests, targeting .net 4.0 and running on clean install of win8.1 seems to work fine (without having to install anything else) but looking for advice on gotchas. 在我的测试中,以.net 4.0为目标并在win8.1的全新安装上运行似乎不错(无需安装其他任何东西),但需要获取有关陷阱的建议。

Thanks. 谢谢。

Note that the .NET framework is intrinsically backwards compatible - .NET 4.5 will execute .NET 4.0 code just fine. 请注意,.NET框架本质上是向后兼容的-.NET 4.5将执行.NET 4.0代码就可以了。 This can be seen even within a solution in that a .NET 4.5/4.5.1 project can reference an older .NET project without incident. 即使在解决方案中,也可以看到这一点,因为.NET 4.5 / 4.5.1项目可以引用较旧的.NET项目而不会发生意外。 This includes .NET 4.0, as well as earlier versions. 这包括.NET 4.0以及早期版本。

In addition to the backwards compatibility, .NET 4.5 does run on the CLR 4.0 - 4.5 is simply a library and compiler expansion. 除了向后兼容之外,.NET 4.5确实可以在CLR 4.0上运行-4.5仅仅是库和编译器扩展。

Possible gotchas 可能的陷阱

  • This emphasis on backwards compatibility is why we almost never see functions disappear from the .NET Framework, just get marked [Obsolete] . 强调向后兼容性的原因是我们几乎永远看不到功能从.NET Framework中消失,而只是将其标记为[Obsolete] it's a good idea to check if any functions you use have become Obsolete, though this is rare and such functions usually continue to work as expected. 检查您使用的任何功能是否已过时是个好主意,尽管这种情况很少见,并且这些功能通常可以按预期继续运行。
  • Windows 8 does NOT like Drive mapping, and will demand that you use UNC paths if you application touches any networks drives. Windows 8不喜欢驱动器映射,如果您的应用程序接触任何网络驱动器,它将要求您使用UNC路径。
  • Windows 8 can be far more aggressive with requiring Admin privileges to run, up to and including needing to explicitly start VS as admin when trying to compile a program which outputs to C:\\Program Files\\... Windows 8可能更具攻击性,需要运行Admin特权才能运行,甚至包括在尝试编译输出到C:\\Program Files\\...的程序时需要以admin身份明确启动VS。

Final note: ALWAYS test your application on the targeted platform before releasing to users. 最后说明:在发布给用户之前,始终在目标平台上测试您的应用程序。

Per this question : 根据这个问题

.NET Framework 4.5 was released on 15 August 2012., a set of new or improved features were added into this version. .NET Framework 4.5于2012年8月15日发布。此版本中添加了一组新功能或改进功能。 The .NET Framework 4.5 is only supported on Windows Vista or later. .NET Framework 4.5仅在Windows Vista或更高版本上受支持。 The .NET Framework 4.5 uses Common Language Runtime 4.0, with some additional runtime features. .NET Framework 4.5使用公共语言运行时4.0,以及一些其他运行时功能。

I would say then that by virtue of having .NET 4.5 installed you will also always have .NET 4.0 installed. 那么我要说的是,由于安装了.NET 4.5,因此您还将始终安装.NET 4.0。 I don't think this should be an issue then! 我认为这不应该成为问题!

From the link you posted: 通过您发布的链接:

Each new version of the .NET Framework retains features from the previous versions and adds new features. .NET Framework的每个新版本均保留以前版本的功能并添加新功能。

Also from that link: 同样从该链接:

The .NET Framework 4.5 is an in-place update that replaces the .NET Framework 4 on your computer, and similiarly, the .NET Framework 4.5.1 4.5.2, and 4.6 Preview are in-place updates to the .NET Framework 4.5, which means that they use the same runtime version, but the assembly versions are updated and include new types and members. .NET Framework 4.5是一个就地更新,它替代了您计算机上的.NET Framework 4,并且类似地,.NET Framework 4.5.1 4.5.2和4.6 Preview是.NET Framework 4.5的就地更新。 ,这意味着它们使用相同的运行时版本,但是程序集版本已更新并包括新的类型和成员。

So, if a system has 4.5, it will be able to run apps targeted for 4.0 as well. 因此,如果系统具有4.5,则它也将能够运行针对4.0的应用程序。 The fact that some versions cannot be installed most likely only means that they are already included from the start. 无法安装某些版本的事实仅意味着它们从一开始就已包含在内。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM