The problem.
We have multiple components in .net ,was communicating each other for the business use cases and in case of error it should come back to entry point and log the exceptions. We have used Enterprise Library exception handling block to handle the logging and exception part.While testing it is observed that logging was not happening to the desired files.Basically from the exception handling block we were getting an error something like:
The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, DefaultPolicy]) failed:
The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, DefaultPolicy]) 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)
try
{
{
Exception ex = new Exception();
throw ex;
}
catch (Exception ex)
{
bool rethrow = ExceptionPolicy.HandleException(ex, "UI Ploicy");
if (rethrow)
{
throw;
}
throw;
}
Note: It is assumed that we have configured the config files properly.
The solution
Add following dlls as reference where ever you are doing the log.
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling Add following dlls as reference where ever you are doing the log.
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging
Microsoft.Practices.EnterpriseLibrary.Logging
The ExceptionHandling.Logging dll is must to use ExceptionHandling as while logging the exception, Exception handling block use this .dll. Microsoft.Practices.EnterpriseLibrary.Logging
In my case I am having a console application and here I will have to explicitly refer the exception handling blocks into services or console application projects where I log the exceptions.