Partager via


Targeting a .NET Framework Version

You can use an application configuration file to specify which versions of the .NET Framework an application or component supports. You must specify the version and build number of each supported .NET Framework version when you use the <supportedRuntime> and <requiredRuntime> elements in an application configuration.

The configuration rules for specifying what version of the .NET Framework an application can use are significantly tighter for .NET Framework version 1.1. For applications using .NET Framework version 1.0, regardless of what the configuration file specified, the application was run on .NET Framework version 1.0. For applications using .NET Framework version 1.1, the <supportedRuntime> element should be used to designate what version or versions of the runtime an application supports. Note that applications build with .NET Framework version 1.0 automatically run with .NET Framework version 1.1 unless specifically configured not to.

Note   An application configuration file must have the same name as the application, with a .config extension. For example, for an application named myExecutable.exe, the application configuration file must be named myExecutable.exe.config.

Currently, you can target an application to run on .NET Framework version 1.0, .NET Framework version 1.1, or both.

Targeting .NET Framework Version 1.1

The application configuration file entry shown in this section causes an application built using .NET Framework 1.0 to use .NET Framework version 1.1 in the following cases:

  • If .NET Framework version 1.1 is installed.
  • If both .NET Framework version 1.0 and .NET Framework version 1.1 are installed.

If only version 1.0 is installed, the application will run because version 1.0 does not recognize the <supportedRuntime> element and will use the version in the PE file header which points to version 1.0.

In the following illustration , MyApp and Assembly A have static references to .NET Framework version 1.0, while Assembly B has a static reference to .NET Framework version 1.1. In this example, MyApp has an application configuration file that states that the application supports version 1.1, so the application and Assembly A are redirected to use .NET Framework version 1.1.

Application configuration file that redirects assembly binding to version 1.1

9w519wzk.sbs2(en-us,VS.71).gif

To target an application built using .NET Framework version 1.0 to run on .NET Framework version 1.1

  • Enter the following XML in the application configuration file:

    <?xml version ="1.0"?>
    <configuration>
    <startup>
    <supportedRuntime version="v1.1.4322" /> 
    </startup>
    </configuration> 
    

Targeting .NET Framework Version 1.0

Targeting an application built using .NET Framework version 1.1 to run on .NET Framework version 1.0 requires a significantly larger entry in the application configuration file. Each assembly that makes up the .NET Framework must be redirected to use .NET Framework version 1.0.

The application configuration file entry shown in this section causes the application to use .NET Framework version 1.0 in the following cases:

  • If .NET Framework version 1.0 is installed.
  • If both .NET Framework version 1.0 and .NET Framework version 1.1 are installed.

If only .NET Framework version 1.1 is installed, the application will not run.

In the following illustration , MyApp and Assembly A have static references to .NET Framework version 1.0, while Assembly B has a static reference to .NET Framework version 1.1. In this example, MyApp has an application configuration file that states that the application supports version 1.0, so Assembly B is redirected to use .NET Framework version 1.0.

Application configuration file that redirects assembly binding to version 1.0

9w519wzk.sbs3(en-us,VS.71).gif

To target an application built using .NET Framework version 1.1 to run on .NET Framework version 1.0

  • Enter the following XML in the application configuration file:

    <?xml version ="1.0"?>
    <configuration>
        <startup>
           <requiredRuntime version="v1.0.3705"  />
        </startup>
        <runtime>
            <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v1.0.3705">
                <dependentAssembly> 
                    <assemblyIdentity name="Regcode" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.EnterpriseServices" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.Security" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="CustomMarshalers" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="Accessibility" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.Configuration.Install" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.DirectoryServices" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.Drawing.Design" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.ServiceProcess" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.Web" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.Web.RegularExpressions" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.Web.Services" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.Windows.Forms" publicKeyToken="b77a5c561934e089" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.Xml" publicKeyToken="b77a5c561934e089" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.Design" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.Drawing" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.Messaging" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="IEExecRemote" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="IEHost" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="IIEHost" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="ISymWrapper" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="mscorcfg" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.Management" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.Runtime.Remoting" publicKeyToken="b77a5c561934e089" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.Runtime.Serialization.Formatters.Soap" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="System.Web.Mobile" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="Microsoft.Vsa.Vb.CodeDOMProcessor" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="Microsoft_VsaVb" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="Microsoft.Vsa" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="Microsoft.VisualBasic.Vsa" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="cscompmgd" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="Microsoft.JScript" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="Microsoft.VisualBasic" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
                </dependentAssembly>
                <dependentAssembly> 
                    <assemblyIdentity name="Microsoft.VisualC" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
                    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
                </dependentAssembly>
            </assemblyBinding>
        </runtime>
    </configuration> 
    

See Also

Using Side-by-Side Execution | Configuring Assembly Binding Redirection | Locating Runtime Version Information