unable to log exception

Topics: Exception Handling Application Block, Logging Application Block
Mar 16, 2007 at 12:43 PM
I receive error using the exception and logging application block. here is d stack trace:

System.Configuration.ConfigurationErrorsException was unhandled by user code
Message="The type Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null from configuration could not be created. (c:\\inetpub\\wwwroot\\motoman\\web.config line 57)"
Source="System.Configuration"
BareMessage="The type Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null from configuration could not be created."
Filename="c:\\inetpub\\wwwroot\\motoman\\web.config"
Line=57
StackTrace:
at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSourceImplementation.GetSection(String sectionName)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource.GetSection(String sectionName)
at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings.GetExceptionHandlingSettings(IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionHandlingConfigurationView.get_ExceptionHandlingSettings()
at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionHandlingConfigurationView.GetExceptionPolicyData(String policyName)
at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyCustomFactory.GetConfiguration(String id, IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyCustomFactory.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id)
at Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)
at Microsoft.Practices.ObjectBuilder.SingletonStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)
at Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfigurationNameMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id)
at Microsoft.Practices.ObjectBuilder.BuilderBase`1.DoBuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies)
at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies)
at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUpTTypeToBuild(IReadWriteLocator locator, String idToBuild, Object existing, PolicyList[] transientPolicies)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUpT(IReadWriteLocator locator, 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)
at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName)
at Motoman.Atn.Dal.PinNumberDB.Save(String sourcefilepath, String formatfilepath) in C:\Documents and Settings\Developer\My Documents\Visual Studio 2005\Projects\motoman\MotomanDAL\PinNumberDB.cs:line 93
at Motoman.Atn.BLL.PinNumberManager.PinSaves(String filepath, String formatfilepath) in C:\Documents and Settings\Developer\My Documents\Visual Studio 2005\Projects\motoman\MotomanBLL\PinNumberManager.cs:line 31
at Default.PageLoad(Object sender, EventArgs e) in c:\Inetpub\wwwroot\motoman\Default.aspx.cs:line 18
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Mar 16, 2007 at 3:05 PM
I think the exception being thrown pretty much says it all:

System.Configuration.ConfigurationErrorsException

There is an error loading your configuration information. The configuration information is probably invalid or perhaps you have not included all the assemblies in your application like this one:

Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll

It is difficult to pinpoint without knowing more information. Make sure you are using the GUI configuration tool to save the configuration as it validates before saving and just double check you have all the necessary assemblies in the application.

Regards,

Dave

__________________

David Hayden
Microsoft MVP C#
Mar 19, 2007 at 9:11 AM
thanks,
I wasn't adding the Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll to the web project I only added it to my class library project reference, tot it would work with out adding it.
Mar 26, 2007 at 5:54 PM
I've encountered a similar problem when using the Web Service Software Factory Microsoft.Practices.ServiceFactory.ExceptionHandling dll. The web.config of the service would validate with the config tool and then fail at runtime. It appeared to be missing the Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll in the bin dir. So to force it to copy i created an internal class which inherits from LoggingExceptionHandler inside the Microsoft.Practices.ServiceFactory.ExceptionHandling dll, it now copies the required dll across without adding a direct reference.

Cheers, Wes