Logging Exception with Entlib 4.1

Topics: Exception Handling Application Block, Logging Application Block
Dec 20, 2008 at 10:00 PM
Hello guys,

When I try to logs exceptions with exception handling application block I get the error below. Is somebody knows about that ?


Thanks



Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionHandlingException was unhandled by user code
  Message="The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, Exception Policy]) failed: The type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' cannot be resolved. Please verify the spelling is correct or that the full type name is provided. (Strategy type ConfiguredObjectStrategy, index 2)"
  Source="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
  StackTrace:
       at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.GetExceptionPolicy(Exception exception, String policyName, ExceptionPolicyFactory factory)
       at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName, ExceptionPolicyFactory policyFactory)
       at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName)
       at DAL.KeywordDAL.AddKeyword(Keyword keyword) in D:\Projects\Search\ImageHandler\DAL\KeywordDAL.cs:line 46
       at BAL.KeywordBAL.InsertKeyword(Keyword keyword) in D:\Projects\Search\ImageHandler\BAL\KeywordBAL.cs:line 24
       at SearchTagger.Tagger.ProcessRequest(HttpContext context) in D:\Projects\Search\ImageHandler\SearchTagger\Tagger.ashx.cs:line 28
       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
  InnerException: Microsoft.Practices.ObjectBuilder2.BuildFailedException
       Message="The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, Exception Policy]) failed: The type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' cannot be resolved. Please verify the spelling is correct or that the full type name is provided. (Strategy type ConfiguredObjectStrategy, index 2)"
       Source="Microsoft.Practices.ObjectBuilder2"
       BuildKey="Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, Exception Policy]"
       ExecutingStrategyIndex=2
       ExecutingStrategyTypeName="ConfiguredObjectStrategy"
       StackTrace:
            at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
            at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)
            at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp[TTypeToBuild](IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)
            at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, ILifetimeContainer lifetimeContainer, String id, IConfigurationSource configurationSource)
            at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.LocatorNameTypeFactoryBase`1.Create(String name)
            at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.GetExceptionPolicy(Exception exception, String policyName, ExceptionPolicyFactory factory)
       InnerException: System.ArgumentException
            Message="The type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' cannot be resolved. Please verify the spelling is correct or that the full type name is provided."
            Source="Microsoft.Practices.EnterpriseLibrary.Common"
            StackTrace:
                 at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.AssemblyQualifiedTypeNameConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
                 at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
                 at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.NameTypeConfigurationElement.get_Type()
                 at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.CustomProviderAssembler`3.Assemble(IBuilderContext context, TConfiguration objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
                 at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.AssemblerBasedObjectFactory`2.Create(IBuilderContext context, TConfiguration objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
                 at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEntryCustomFactory.Create(IBuilderContext context, ExceptionTypeData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
                 at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyCustomFactory.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
                 at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.PreBuildUp(IBuilderContext context)
                 at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
            InnerException: 

 
Dec 21, 2008 at 5:32 AM
Make sure you have a reference to Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll in the project.
Dec 22, 2008 at 8:08 PM
I did, but i still get the error. My solution contains 3 application, DAL,BAL and Web application. I tried to handle exceptions at datalayer, thats why i added these references to the DAL project. But I configure the Web.config of the Web application. Do you think that is it becouse of that ?
Dec 22, 2008 at 8:23 PM
You need to make sure there is a reference in the web project also, or the Logging assembly is otherwise available. Remember the DAL assembly is being loaded into the the app domain of the web project, so all references it makes must be able to be resolved in that app domain. 
Dec 22, 2008 at 8:43 PM
Thanks, It works now.