使用 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 的实例。我该如何解决这个问题?