Force an application to run under specific .NET runtime version?

.net

Solution

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

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

Problem

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?

Original source