Reusing Configuration Files Based on a Previous Schema

Although this documentation is based on the Unity 2.0 configuration schema and all examples use Unity 2.0, partial backward compatibility is provided for the Unity 1.2 configuration schema. However, you cannot simply use a Unity 1.2 configuration file. In order to use the contents of a Unity 1.2 configuration file you must:

  1. Create a new configuration file.
  2. Edit the <configSections> to point to the correct assembly.
  3. Add a <sectionExtension> section if you are using container extensions for Unity.
  4. Cut and paste the portions of the Unity 1.2 configuration file you wish to reuse.
    Ff660896.note(en-us,PandP.20).gifNote:
    Check the results as you still may get errors depending upon the specific portions you cut and paste.

For information on using the Unity 1.2 configuration schema see Unity Configuration Schematic on MSDN®.

Unity 1.2 extension configurations cannot just be copied into a Unity 2.0 configuration file. There is no <extensionConfig> section in Unity 2.0. However you can often copy the contents of an old <extensionConfig> section to Unity 2.0 <register> elements.

For example, the following is an excerpt from a Unity 1.2 configuration file.

<extensionConfig>
  <add name="interception"
      type="Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationElement, Microsoft.Practices.Unity.Interception.Configuration">
    <interceptors>
      <interceptor type="transparentProxy">
        <default type="wrappable"/>
        <key type="wrappableWithProperty"/>
      </interceptor>
      <interceptor type="virtualMethod">
        <key type="wrappableVirtual" name="name"/>
      </interceptor>
    </interceptors>
  </add>
</extensionConfig>

In Unity 2.0 you would do the following:

  1. Use <sectionExtension> to add the extension elements to the schema and aliases to the configuration section.
    <sectionExtension type="Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationExtension, Microsoft.Practices.Unity.Interception.Configuration" />
    
  2. You would then use the <extension> element to add the interception extension to the configuration.
        <extension type="Interception" />
    
  3. Then you could copy the interceptor element content and change TransparentProxy to TransparentProxyInterceptor.
    <container name="configuringDefaultInterceptor">
        <extension type="Interception" />
        <interceptors>
          <interceptor type="TransparentProxyInterceptor">
            <default type="wrappable"/>
            <key type="wrappableWithProperty"/>
          </interceptor>
        </interceptors>
    </container>
    

Ff660896.note(en-us,PandP.20).gifNote:
You can use the container element extension or injection members to add extensions. For more information on Unity 2.0 extensions see Configuration Files for Interception.


Show: