小编Mor*_*avi的帖子

如何使用Exception Manager Enterprise Library 6.0

使用Enterprise Library 6.0时,以下代码中会出现此错误:

bool rethrow = ExceptionPolicy.HandleException(ex, "ReplacePolicy1")
Run Code Online (Sandbox Code Playgroud)

"必须使用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;
}
Run Code Online (Sandbox Code Playgroud)

但是在Enterprise Library 6.0中找不到EnterpriseLibraryContainer类.我想要获取ExceptionManager的实例.我该如何解决这个问题?

c# enterprise-library exception-handling

14
推荐指数
1
解决办法
2万
查看次数