Configuring a COM Application for Side-By-Side Execution

An application configuration file enables a COM application to bind to a specific managed component and specify which version of the runtime runs the component. COM application developers can create a .NET-based application configuration file and deploy it with their applications.

Managed and unmanaged applications use the identical configuration file schema to specify a version of the runtime and to bind to a specific component. Win32 application configuration files are slightly different and cannot be substituted for .NET-based files. For file naming and location requirements, see Application Configuration Files.

Specifying the Runtime Version

Without an application configuration file, the latest compatible runtime version installed on the computer is loaded by default. If this behavior does not satisfy the requirements of your COM application, you can indicate in a configuration file the specific runtime version that your application requires. For example, you can specify runtime version 1.0.3705, which loads the .NET Framework version 1.0.

To specify runtime version 1.0.3705

  1. Using an XML editor, create an application configuration file.

  2. Insert the following standard header at the beginning of the file:

    <?xml version ="1.0?>
    
  3. Insert the following XML elements into the file:

    <configuration>
       <startup>
          <requiredRuntime version="v1.0.3705" safemode="true"/>
       </startup>
    </configuration>
    

Setting the safemode attribute to true prevents the runtime startup code from checking the registry and ensures that only runtime version 1.0.3705 is loaded.

Note   COM applications hosted by an extensible host, such as Microsoft Internet Explorer or Microsoft Office cannot control which version of the runtime is loaded.

Specifying an Assembly Version

Without an application configuration file, the runtime loads the latest version of the assembly registered in the Windows registry that contains the type to be activated from COM. You can override this behavior by directing your application to bind to an earlier assembly version.

To redirect assembly binding to an earlier version

  1. Using an XML editor, create an application configuration file.

  2. Insert the following standard header at the beginning of the file:

    <?xml version ="1.0?>
    
  3. Insert the following XML elements into the file. The <bindingRedirect> element with the oldVersion and newVersion attributes redirects binding for myManagedAssembly version 2.0 to version 1.0.

    <configuration>
       <runtime>
          <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
             <dependentAssembly>
                <assemblyIdentity name="myManagedAssembly"
                                  publicKeyToken="32ab4ba45e0a69a1"
                                  culture="en-us" />
                <bindingRedirect oldVersion="2.0.0.0"
                                 newVersion="1.0.0.0"/>
             </dependentAssembly>
          </assemblyBinding>
       </runtime>
    </configuration>
    

You can redirect more than one assembly version by including multiple <bindingRedirect> elements within a <dependentAssembly> element.

See Also

Side-By-Side Execution for COM Interop | Runtime Initialization from a COM Application | Version-Dependent Registry Keys | Applying Version-Dependent Attributes | COM Components and Side-By-Side Execution