可以将应用程序的目标既3.5和4.5 .NET版本? [英] Can an application target to both 3.5 and 4.5 .Net version?

查看:276
本文介绍了可以将应用程序的目标既3.5和4.5 .NET版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个WPF应用程序,这既.NET 3.5和4.5的所有源代码兼容。这意味着如果我改变.NET目标的属性要么3.5或4.5,它将complie并没有任何错误运行情况良好。结果
我不知道有反正我的我的应用程序文件可以同时运行3.5和4.5 .NET PC(例如:Windows 7和Windows 8.1),无complie 2版本每个.NET? !谢谢

I write a WPF app, that all source code compatible with both .NET 3.5 and 4.5. That mean if I change .NET target in the Properties to either 3.5 or 4.5, it will complie and run well without any error.
I wonder there is anyway to my my app file can run on both 3.5 and 4.5 .NET pc (example: Windows 7 and Windows 8.1), without complie 2 version for each .NET? Thank!

编辑:结果
当我有问题的.NET 3.5应用程序复制到Windows 8.1电脑,Windows拒绝运行我的应用程序,并要求我安装.NET 3.5。因此,如果只与.NET 3.5 complie,就不要让应用程序可以运行在.NET 4.5的PC。

推荐答案

建立与.NET 3.5和这些行添加到的App.config 和它的工作对我来说:

Build with .NET 3.5 and add these lines to App.config and it worked for me:

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

这篇关于可以将应用程序的目标既3.5和4.5 .NET版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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