ExceptionManager instance

Topics: Exception Handling Application Block
May 2, 2011 at 9:44 AM

I want to catch DivideByZeroException (whatever) on client-side (silverlight) and put this exception via RIA Service into server-side and log it there to database. On the client-side i have a Configuration.xaml, on the server-side my entlib configuration existing on Web.config. If i use LogWriter - logs successfully goes from client to server via RIAServiceTraesListener (based on RemoteServiceTraceListener), and on the server logs saves to database via FormattedDatabaseTraceListener. But if i want to log my exceptions via ExceptionHandling Application Block, i must have instance of ExceptionManager - that what i can't do. I try to get instance differently:

1. EnterpriseLibraryContainer.Current.GetInstance<ExceptionManager>() 

2. new UnityContainer().AddNewExtensions<EnterpriseLibraryCoreExtensions>().Resolve<ExceptionManager>()

But i have exception - Activation error occured while trying to get instance of type ExceptionManager, key "". Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionManager", name = "(none)".Exception occurred while: while resolving.Exception is: InvalidOperationException - The type ExceptionManager cannot be constructed. You must configure the container to supply this value.-----------------------------------------------At the time of the exception, the container was:
  Resolving Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionManager,(none)

 

Help me with it, please. 

PS: Sorry for my English.

May 3, 2011 at 9:33 AM
Edited May 3, 2011 at 9:51 AM

Hi,

I would think the basic question here is how have you configured your Exception Handling Block? Can you post your configuration here.

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 3, 2011 at 12:15 PM

<
ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:el="clr-namespace:Microsoft.Practices.EnterpriseLibrary.Logging.Configuration;assembly=Microsoft.Practices.EnterpriseLibrary.Logging.Silverlight" xmlns:SilverlightLogging="clr-namespace:SilverlightLogging;assembly=SilverlightLogging" xmlns:ehl="clr-namespace:Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.Configuration;assembly=Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.Silverlight" xmlns:eh="clr-namespace:Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration;assembly=Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Silverlight"> <el:LoggingSettings DefaultCategory="Database" x:Key="loggingConfiguration" LogWarningWhenNoCategoriesMatch="True"> <el:LoggingSettings.TraceListeners> <SilverlightLogging:RIAServiceTraceListenerData Name="server" IsolatedStorageBufferMaxSizeInKilobytes="4096" SendImmediately="False" /> </el:LoggingSettings.TraceListeners> <el:LoggingSettings.TraceSources> <el:TraceSourceData Name="Database" DefaultLevel="All"> <el:TraceSourceData.TraceListeners> <el:TraceListenerReferenceData Name="server" /> </el:TraceSourceData.TraceListeners> </el:TraceSourceData> </el:LoggingSettings.TraceSources> </el:LoggingSettings> <eh:ExceptionHandlingSettings x:Key="exceptionHandlingConfiguration"> <eh:ExceptionHandlingSettings.ExceptionPolicies> <eh:ExceptionPolicyData Name="DivideByZeroPolicy"> <eh:ExceptionPolicyData.ExceptionTypes> <eh:ExceptionTypeData TypeName="System.DivideByZeroException" PostHandlingAction="ThrowNewException"> <eh:ExceptionTypeData.ExceptionHandlers> <eh:ReplaceHandlerData ExceptionMessage="New message." ReplaceExceptionTypeName="System.Exception" /> <ehl:LoggingExceptionHandlerData Name="LoggingExceptionHandler" UseDefaultLogger="False" FormatterTypeName="TextExceptionFormatter" LogCategory="Database" EventId="100" Severity="Error" Title="Enterprise Library Exception Handling" Priority="0" /> </eh:ExceptionTypeData.ExceptionHandlers> </eh:ExceptionTypeData> </eh:ExceptionPolicyData.ExceptionTypes> </eh:ExceptionPolicyData> </eh:ExceptionHandlingSettings.ExceptionPolicies> </eh:ExceptionHandlingSettings> </ResourceDictionary>
May 3, 2011 at 1:02 PM

I solved it by rename x:Key="exceptionHandlingConfiguration" to "exceptionHandling"

Thanks for attention