26

I have .NET 2.0 runtime installed, then I installed the .NET 4.0 runtime, so I have both. When I run a .NET app, is there a way to force which runtime will be used?

Edit/Clarification: I meant w/o regards to how the application was built. I am under the assumption that the .NET 4.0 runtime can run a .NET program compiled 5 years ago that targeted the 2.0 runtime (oldprogram.exe). So now I am on a machine with both runtimes, either of which could handle oldprogram.exe. Which runtime is chosen? Can I influence which runtime is chosen?

3 Answers 3

30

Yes, use the <supportedRuntime> element in the .exe.config file. For example:

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

Take a look: Configuring Assembly Binding Redirection

By default, applications use the set of .NET Framework assemblies that shipped with the runtime version used to compile the application. You can use the appliesTo attribute on the <assemblyBinding> element in an application configuration file to redirect assembly binding references to a specific version of the .NET Framework assemblies. This optional attribute uses a .NET Framework version number to indicate which version it applies to. If no appliesTo attribute is specified, the <assemblyBinding> element applies to all versions of the .NET Framework.

1
  • +1, this is the right answer if the program has already been built. Jan 12, 2010 at 1:41
4

Here's a list of MSDN reference to target specific .NET Framework version for VS.NET projects:

How to: Target a Specific .NET Framework

Visual Studio 2010
How to: Target a Specific .NET Framework Version or Profile

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.