Elmo
Elmo

Reputation: 6471

Change .NET Framework Target of Compiled Executable

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?

Upvotes: 4

Views: 9864

Answers (3)

Nelson Rodriguez
Nelson Rodriguez

Reputation: 492

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.

Upvotes: 3

Rafael
Rafael

Reputation: 2817

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.

Upvotes: 0

Reed Copsey
Reed Copsey

Reputation: 564931

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.

Upvotes: 6

Related Questions