问题
We have a C# project where the C# projects are compiled with TargetFrameworkVersion 4.7.2. For example, in the csproj file this is specified --
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
The compiled and built exe is installed in a VM which has .net 4.6.1 installed. I see that installation is successful and the software is working fine. So can we safely say that projects built with 4.7.2 can execute when .netframework 4.6.1 installed. Or are there any issues to look out for here ?
回答1:
You can use supportedRuntime
element in your app.config
file, like
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>
It's possible, since they use the same CLR version 4.0. But you'll probably get a runtime exception, if using any specific features from .NET 4.7.2. See MSDN and this article for details
来源:https://stackoverflow.com/questions/55791597/can-c-sharp-projects-that-have-4-7-2-target-framework-version-run-on-net-4-6-1