[英]Set target framework to 4.5
I have a small project which needs .net version 4.5 because of Compression. 由于压缩,我有一个需要.net 4.5的小项目。 This is my App.config:
这是我的App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup>
</configuration>
But when I try to run the program on a stock Windows 7 system, it says that I need to install v4.0.30319. 但是,当我尝试在现有的Windows 7系统上运行该程序时,它说我需要安装v4.0.30319。 This way the user have to install v4.0 first, THEN the v4.5.
这样,用户必须先安装v4.0,然后再安装v4.5。 Is there a way to set it so it will need v4.5 by default?
有没有办法设置它,所以默认情况下它需要v4.5?
I'm using VS2015 if that changes anything 我正在使用VS2015如果这改变了什么
Apparently, according to the MSDN article on <supportedRuntime>
( https://msdn.microsoft.com/en-US/library/w4atty68(v=vs.110).aspx ), your current solution is the correct way to check the version. 显然,根据
<supportedRuntime>
( https://msdn.microsoft.com/zh-CN/library/w4atty68 ( v=vs.110 ) .aspx )上的MSDN文章,您当前的解决方案是检查以下问题的正确方法版。 It seems the .NET 4.0 Update 3 Framework is required as a base for any future versions. 似乎.NET 4.0 Update 3 Framework是所有将来版本的基础。 But this is an assumption, I'd be happy to be corrected here.
但这是一个假设,我很乐意在这里进行更正。
Update : I did a litlte research, and .NET 4.5 effectively replaces .NET 4.0 on the system. 更新 :我做了一点研究,.NET 4.5有效地替换了系统上的.NET 4.0。 In accordance to the article I mentioned, it seems that everything from .NET 4.0 and above seems to be identified with a version string of "v4.0.30319" in the metadata of the assemblies, hence the .NET loader will always think that version has to be installed first.
根据我提到的文章,似乎.NET 4.0及更高版本中的所有内容似乎都用程序集的元数据中的版本字符串“ v4.0.30319”标识,因此.NET加载程序始终会认为该版本具有首先安装。
BUT since .NET 4.x replaces the old one, I would assume that you can install .NET 4.5+ directly without the need to install .NET 4.0 first. 但是,由于.NET 4.x替代了旧版本,因此我假设您可以直接安装.NET 4.5+,而无需先安装.NET 4.0。
In short: I assume that you can install .NET 4.5 directly without installing .NET 4.0 first. 简而言之:我假设您可以直接安装.NET 4.5,而无需先安装.NET 4.0。 If the user doesn't have either, the application will tell him to install 4.0, which is not neccessary, but this is what the PE tells the loader.
如果用户没有,则应用程序将告诉他安装4.0,这不是必需的,但这就是PE告诉加载程序的内容。 I don't think you can check for .NET 4.5 yourself in one turn without some sort of "bootstrapping".
我认为,如果没有某种“引导程序”,您就无法自己检查.NET 4.5。 By that I mean writing a small program that checks the registry for the installed version and, if the correct version is installed, launches your actual program.
我的意思是写一个小程序,检查注册表中已安装的版本,如果安装了正确的版本,则启动您的实际程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.