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

前端 未结 3 1558
暖寄归人
暖寄归人 2020-11-30 07:58

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?

相关标签:
3条回答
  • 2020-11-30 08:09

    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.

    0 讨论(0)
  • 2020-11-30 08:25

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

    <configuration>
       <startup>
          <supportedRuntime version="v2.0.50727"/>
       </startup>
    </configuration>
    
    0 讨论(0)
  • 2020-11-30 08:26

    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

    0 讨论(0)
提交回复
热议问题