简体   繁体   English

将目标框架设置为4.5

[英]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.

相关问题 如何解决编译目标框架4.5错误? - How to solve compilation target framework 4.5 error? 无法在Visual Studio 2013中定位.NET Framework 4.5 - Unable to target .NET Framework 4.5 in Visual Studio 2013 将异步任务方法目标框架4.5转换为TargetFramework 2.0 - Transform Async Task method target framework 4.5 to TargetFramework 2.0 .NET目标框架兼容性和编译器 - 在.NET 4.5或更高版本上 - .NET target framework compatibility and the compiler - on .NET 4.5 or higher 如何将实体框架4.5设置为永不将任何属性设置为Nullable - How to set entity framework 4.5 to never set any property as Nullable 在目标框架4.5中,WPF Dispatcher.Invoke不允许在单独的线程中更新文本块 - In target framework 4.5, WPF Dispatcher.Invoke is not allowing to update the Text Block in separate thread 将目标点网框架从4.5更改为2.0时的DLLImport问题 - DLLImport issues when changing target Dot net framework from 4.5 to 2.0 为什么我不能在Windows 8中使用Visual Studio 2012将目标框架更改为4.5? - Why can't I change the target framework to 4.5 in Windows 8, using Visual Studio 2012? 无法在多个项目上更改目标框架从v4.0到V4.5或4.5.1 - Cannot change Target Framework on Several Projects From v4.0 to V4.5 or 4.5.1 将项目.net目标框架从3.5升级到4.5后,日历中的C#错误 - C# Error in calendar after upgrading project .net target framework from 3.5 to 4.5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM