Mixing Ent Lib versions in a single webapp

Topics: Exception Handling Application Block, Logging Application Block
Dec 30, 2009 at 1:30 AM

Is it possible to mix ent lib versions in a single web app.  The issue I've had dropped on me is that an existing application uses Ent Lib 3.1 and my application uses 4.1 .  I'm thinking all would be ok if I could name one loggingConfiguration and exceptionHandling section for one app std names and the other loggingConfiguration4.1 etc, is this supposed to work?  It doesn't so far for me.  Any ideas?

 

Dec 31, 2009 at 2:27 PM

I've found that you can use mixed versions of both GAC'd verions thus far if you use the runtime assembly binding redirection capability of .Net but you can not use the publicKeyToken element of each redirected version since the ootb versions of 3.1 and 4.1 do not share the same publicKey.  Of course you can always build custom versions of each making certain they use the same publicKey.  Just in case anyone encounters this heres my runtime section that does load/run but finds other issues in implicit uses of the library such as IExceptionHandler.  I believe the implementation signatures don't match between versions 3.1 and 4.1 and although avoids binding issues still does not work.  This uses the publicKeyToken from 4.1 as 31BF3856AD364E35 instead of from 3.1 as

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Caching" publicKeyToken="31BF3856AD364E35"/>
        <bindingRedirect oldVersion="3.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Caching.Database" publicKeyToken="31BF3856AD364E35"/>
        <bindingRedirect oldVersion="3.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Common" publicKeyToken="31BF3856AD364E35"/>
        <bindingRedirect oldVersion="3.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Data" publicKeyToken="31BF3856AD364E35"/>
        <bindingRedirect oldVersion="3.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling" publicKeyToken="31BF3856AD364E35"/>
        <bindingRedirect oldVersion="3.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Logging" publicKeyToken="31BF3856AD364E35"/>
        <bindingRedirect oldVersion="3.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.Design" publicKeyToken="31BF3856AD364E35"/>
        <bindingRedirect oldVersion="3.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Logging.Database" publicKeyToken="31BF3856AD364E35"/>
        <bindingRedirect oldVersion="3.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.Design" publicKeyToken="31BF3856AD364E35"/>
        <bindingRedirect oldVersion="3.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>