Change .NET Framework Target of Compiled Executable

杀马特。学长 韩版系。学妹 提交于 2019-12-10 06:26:20

问题


As Windows 8 doesn't contain .NET 2/3.5 by default, I would like to convert some .NET 2.0 compiled executables to .NET 4.5 without re-compiling them with VS 2012. Is there an utility for this task?


回答1:


You could just create or modify the app.config file, and set the supportedRuntime element to 4.5. This will cause the 4.0 CLR (which will use the 4.5 framework) to load the assembly, and does not require any change to the executable itself.




回答2:


As additional information (the solution provided by Reed Copsey works) you can have multiple supportedRuntime elements in order to support systems where 4.x is not installed:

<configuration>
    <startup>
        <supportedRuntime version="v4.0" />
        <supportedRuntime version="v2.0.50727" />
    </startup>
...

And that will make it work nicely in Windows 8 or prior versions where .Net 4.x is not installed.




回答3:


I believe you can't do that as this attributte is backed in the assembly itself (TargetFramework), what you can do if you don't have the source code is to decompile the assembly and recompile it using the desired .NET Framework version.



来源:https://stackoverflow.com/questions/12181953/change-net-framework-target-of-compiled-executable

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