Can C# projects that have 4.7.2 target framework version run on .net 4.6.1

陌路散爱 提交于 2020-01-23 13:04:02

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!