使用Enterprise Library 6.0时,以下代码会出现错误:
bool rethrow = ExceptionPolicy.HandleException(ex, "ReplacePolicy1")
必须使用SetExceptionManager方法在ExceptionPolicy类中设置一个ExceptionManager。
在Enterprise Library 5.0中,此代码可用:
public static bool HandleException(Exception exception, string PolicyName)
{
ExceptionManager exManager = EnterpriseLibraryContainer.Current.GetInstance<ExceptionManager>();
ExceptionPolicy.SetExceptionManager(exManager);
bool rethrow = ExceptionPolicy.HandleException(ex, "ReplacePolicy1");
return reThrow;
}
但是在Enterprise Library 6.0中,找不到EnterpriseLibraryContainer类。我想获取ExceptionManager的实例。我该如何解决这个问题?