Ent Lib 5.0 Beta 2 Configuration Exception

Topics: Enterprise Library Core, Exception Handling Application Block, Logging Application Block
Mar 23, 2010 at 6:34 PM
Edited Mar 23, 2010 at 7:39 PM

It seems once I moved to Ent Lib 5.0 Beta 2, I'm getting the following error when I try to instantiate the ExceptionManager using 

EnterpriseLibraryContainer

.Current.GetInstance<ExceptionManager>();

Error: Microsoft.Practices.ServiceLocation.ActivationException: Activation error occured while trying to get instance of type ExceptionManager, key "" ---> Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionManager", name = "(none)".
...

Can someone help me resolve this issue.

 

Mar 23, 2010 at 7:46 PM

App.config is as follows;

<configuration>
  <configSections>
    <section name="policyInjection" type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.Configuration.PolicyInjectionSettings, Microsoft.Practices.EnterpriseLibrary.PolicyInjection, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
    <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
  </configSections>
  <policyInjection>
    <policies>
      <add name="Fusion Server Policy">
        <matchingRules>
          <add type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.MatchingRules.NamespaceMatchingRule, Microsoft.Practices.EnterpriseLibrary.PolicyInjection, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            name="Namespace Matching Rule">
            <matches>
              <add match="Business.Common.MyDALTest.*" />
            </matches>
          </add>
        </matchingRules>
        <handlers>
          <add exceptionPolicyName="DAL Policy" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.PolicyInjection, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            name="Exception Handling Call Handler" />
        </handlers>
      </add>
    </policies>
  </policyInjection>
  <loggingConfiguration name="Logging Application Block" tracingEnabled="false"
    defaultCategory="Default Category" logWarningsWhenNoCategoriesMatch="false">
    <listeners>
      <add name="Event Log Destination" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        source="MyCompany Fusion Application" formatter="Default Formatter"
        log="" machineName="." traceOutputOptions="None" filter="All" />
      <add name="Flat File Destination" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        fileName="trace.log" header="" footer="" formatter="" traceOutputOptions="None"
        filter="All" />
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"
        name="Default Formatter" />
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
        name="Text Formatter" />
    </formatters>
    <logFilters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        categoryFilterMode="AllowAllExceptDenied" name="Category" />
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.PriorityFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        minimumPriority="0" maximumPriority="2147483647" name="Priority" />
    </logFilters>
    <categorySources>
      <add switchValue="All" name="Default Category">
        <listeners>
          <add name="Event Log Destination" />
        </listeners>
      </add>
      <add switchValue="All" name="Tracing">
        <listeners>
          <add name="Flat File Destination" />
        </listeners>
      </add>
      <add switchValue="All" name="MyCompany Fusion Category">
        <listeners>
          <add name="Event Log Destination" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events" />
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings" />
    </specialSources>
  </loggingConfiguration>
  <exceptionHandling>
    <exceptionPolicies>
      <add name="DAL Policy">
        <exceptionTypes>
          <add name="Exception" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            postHandlingAction="ThrowNewException">
            <exceptionHandlers>
              <add name="Logging Exception Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
                logCategory="Default Category" eventId="100" severity="Error"
                title="FUSION DAL General Exception" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
                priority="0" />
              <add name="Replace Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                exceptionMessage="Test Msg" exceptionMessageResourceName="DAL_Exception"
                exceptionMessageResourceType="MyCompany.Business.Common.ExceptionHandling_EntLib5.Errors, Business.Common.ExceptionHandling_EntLib5, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
                replaceExceptionType="MyCompany.Business.Common.ExceptionHandling_EntLib5.DataAccessException, Business.Common.ExceptionHandling_EntLib5, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
      <add name="BO Policy">
        <exceptionTypes>
          <add name="DataAccessException" type="MyCompany.Business.Common.ExceptionHandling_EntLib5.DataAccessException, Business.Common.ExceptionHandling_EntLib5, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
            postHandlingAction="ThrowNewException">
            <exceptionHandlers>
              <add name="Logging Exception Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                logCategory="MyCompany Fusion Category" eventId="100" severity="Error"
                title="Enterprise Library Exception Handling" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
                priority="0" />
              <add name="Replace Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                exceptionMessageResourceName="BO_Exception" exceptionMessageResourceType="MyCompany.Business.Common.ExceptionHandling_EntLib5.Errors, Business.Common.ExceptionHandling_EntLib5, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
                replaceExceptionType="MyCompany.Business.Common.ExceptionHandling_EntLib5.BusinessException, Business.Common.ExceptionHandling_EntLib5, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
      <add name="CSLA Server Policy">
        <exceptionTypes>
          <add name="BusinessException" type="MyCompany.Business.Common.ExceptionHandling_EntLib5.BusinessException, Business.Common.ExceptionHandling_EntLib5, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
            postHandlingAction="None" />
        </exceptionTypes>
      </add>
    </exceptionPolicies>
  </exceptionHandling>
</configuration>

Mar 25, 2010 at 2:01 AM

Hi,

Can't seem to repro the problem. Using the config you've posted, I'm encountering other problem, there seem to be a problem with the type name of your ExceptionCallHandler type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.PolicyInjection, try removing the call handler and re adding it again. Also, can you send me a quick repro application.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com