如何强制在.NET 4.5运行.NET 3.5应用程序运行?应用程序、NET

2023-09-03 06:15:44 作者:不浪漫的浪漫

我想实现在此描述的解决方案:Can我使用的是.NET 4的功能,同时针对.NET 3.5 SP1?。它工作正常,当.NET 3.5的应用程序在.NET 4.0中运行。然而,在.NET 4.5的应用程序运行在.NET 3.5的环境。我已经试过如下:

I'm trying to implement the solution described here: Can I use a .NET 4 feature while targeting .NET 3.5 SP1?. It works fine when a .NET 3.5 application runs on .NET 4.0. However, on .NET 4.5 the app runs on .NET 3.5 environment. I have tried the following:

<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
<supportedRuntime version="v4.0"/>
<supportedRuntime version="v2.0.50727"/>

没有成功。 Environment.Version 还告诉 2.0.50727.5456 而在.NET 4.0中一切正常。

with no success. Environment.Version still tells 2.0.50727.5456 while on .NET 4.0 everything is OK.

有没有办法来强制.NET 3.5应用程序中使用.NET 4.5(如果可用)?

Is there a way to force .NET 3.5 app use .NET 4.5 if available?

推荐答案

这是我的错:意外的app.config并没有复制到构建目录。一切工作有:

It's my fault: app.config accidentally was not copied onto build directory. Everything works with:

<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
<supportedRuntime version="v4.0"/>
<supportedRuntime version="v2.0.50727"/>