Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
243 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...