How to force .NET 3.5 application run on .NET 4.5

2019-02-24 04:12发布

问题:

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"/>

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

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

回答1:

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"/>


标签: .net .net-4.5