2010-06-18 120 views
3

我使用的是.NET Exception Management Application Block (EMAB).如果我的IExceptionPublisher引发异常,会发生什么情况?

作为这个的一部分,我实现了IExceptionPublisher类。

但是,我想知道如果这些发布者遇到异常会发生什么。

我有一点看的周围,apparently他们是为了做这样的事情:

try 
{ 
    /* Normal Exception Publishing */ 
} 
catch 
{ 
    ExceptionManager.PublishInternalException(exception, additionalInfo); 
} 

Source

一个警告:如果有 在出现异常时会发生什么我们的自定义发布者 的代码,阻止发布到 MSMQ?为此,我们转向 ExceptionManager.PublishInternalException 方法,该方法将向默认发布者 发布 例外,该例外是Windows应用程序事件 日志。

然而,PublishInternalException既保护内部,所以我将不得不实施ExceptionManager,不IExceptionPublisher,对其进行访问。

回答

0

它处理本身,都发布了原来的异常和你IExceptionPublisher扔应用程序日志

的想法手动调用PublishInternalException必须已涉及到早期测试异常。当前的ExceptionManager将IExceptionPublisher调用封装在自己的try-catch中,它调用PublishInternalException本身。如果您在反射检查出的代码,它基本上做到这一点:

/* Foreach publisher */ 
Exception originalException; 
try 
{ 
    PublishToCustomPublisher(originalException, additionalInfo, current); 
} 
catch (Exception publisherException) 
{ 
    /* Both of these calls use the DefaultPublisher which is the Application Log */ 
    PublishInternalException(publisherException, null); 
    PublishToDefaultPublisher(originalException, additionalInfo); 
} 

您可能还需要检查出的新Enterprise Library Exception Handling Application Block

相关问题