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.