In our project, we were using Enterprise library 5.0 for exception handling. Now, we are planning to use Enterprise library 6.0 and we are facing issues that EnterpriseLibraryContainer.Current is not available in Enterprise library 6.0.
I have found this link Fluent API takes effect only once (Enterprise Library) and it mentioned for LogWriter migration for 6.0. Same Way i would like to do for ExceptionHandling. Below is sample code that are similar to our project.
EHConfigMgr.cs
var builder = new ConfigurationSourceBuilder();
var exceptionHandlingBuilder = builder.ConfigureExceptionHandling();
ServiceLocator.Current.GetAllInstances<IExceptionHandlingConfigurator>().ToList().ForEach(c => c.ConfigureExceptinHandling(exceptionHandlingBuilder));
exceptionHandlingBuilder.GivenPolicyWithName("WCF Exception Shielding")
.ForExceptionType<FaultException<ValidationFault>>()
.HandleCustom<WcfRethrowValidationFaultHandler>()
.ThenThrowNewException();
var tempAppConfigPath = Path.GetTempFileName();
File.Copy(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, tempAppConfigPath, true);
File.SetAttributes(tempAppConfigPath, FileAttributes.Normal);
var configSource = new FileConfigurationSource(tempAppConfigPath, false);
var s = new DictionaryConfigurationSource();
builder.UpdateConfigurationWithReplace(configSource);
EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(configSource);
Proxybase.cs
protected ProxyBase()
{
ExceptionManager = EnterpriseLibraryContainer.Current.GetInstance<ExceptionManager>();
}
Please help me to change the proxybase without affecting exisiting functionality.