Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling

16,994

Your web.config isn't actually in the post.

In any event, you've got a reference to Entlib 2.0 in your config file. You need to update to point at the Entlib 5 version number and public key token. It's probably in your element, but if it's there I wouldn't be surprised if the rest of your file also had the wrong version #'s.

[update on further reflection]

Actually, based on the error message, there's another possibility - the runtime is finding the 2.0 assembly instead of the 5.0 assembly when it goes to load. Double check all your assembly references, and check your bin directory - make sure it's got the right assembly in it.

You can also try running the fuslogvw tool on the web server - it'll tell you what assemblies the runtime tried to load, and where it looked for them.

Share:
16,994
user583754
Author by

user583754

Updated on June 05, 2022

Comments

  • user583754
    user583754 almost 2 years

    I get this below error when i add Enterprise library 5.0 file MS.Practices.EnterpriseLibrary.ExceptionHandling.dll for my wcf application.

    An error occurred creating the configuration section handler for exceptionHandling: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

     <exceptionHandling>
    <exceptionPolicies>
      <add name="Global Policy">
        <exceptionTypes>
          <add name="Exception" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="None">
            <exceptionHandlers>
              <add name="Wrap Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WrapHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling" exceptionMessage="Global Message." wrapExceptionType="ExceptionHandlingQuickStart.BusinessLayer.BusinessLayerException, ExceptionHandlingQuickStart.BusinessLayer" /> 
              <add name="Custom Handler" type="AppMessageExceptionHandler, ExceptionLibraryForWCF"/>
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
      <add name="Handle and Resume Policy">
        <exceptionTypes>
          <add name="Exception" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="None">
            <exceptionHandlers/>
          </add>
        </exceptionTypes>
      </add>
      <add name="Propagate Policy">
        <exceptionTypes>
          <add name="Exception" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="NotifyRethrow">
            <exceptionHandlers/>
          </add>
        </exceptionTypes>
      </add>
      <add name="Replace Policy">
        <exceptionTypes>
          <add name="SecurityException" type="System.Security.SecurityException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="ThrowNewException">
            <exceptionHandlers>
              <add name="Replace Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" exceptionMessage="Replaced Exception: User is not authorized to peform the requested action." replaceExceptionType="System.ApplicationException, mscorlib"/>
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
      <add name="Wrap Policy">
        <exceptionTypes>
          <add name="DBConcurrencyException" type="System.Data.DBConcurrencyException, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="ThrowNewException">
            <exceptionHandlers>
              <!--<add name="Wrap Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WrapHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling" exceptionMessage="Wrapped Exception: A recoverable error occurred while attempting to access the database." wrapExceptionType="ExceptionHandlingQuickStart.BusinessLayer.BusinessLayerException, ExceptionHandlingQuickStart.BusinessLayer" /> -->
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>
    

    Below is my web.config declaration for my exception handling -->

  • user583754
    user583754 over 13 years
    There is only version 5.0.414.0 specified in my web.config not 2.0.0.0.
  • user583754
    user583754 over 13 years
    please see web.config section above
  • Chris Tavares
    Chris Tavares over 13 years
    What's in the <configSections> element? That's probably where the issue is.