代码之家  ›  专栏  ›  技术社区  ›  Matt Mitchell

如果我的IEExceptionPublisher抛出异常会发生什么?

  •  3
  • Matt Mitchell  · 技术社区  · 14 年前

    .NET Exception Management Application Block (EMAB).

    作为其中的一部分,我正在实现IExceptionPublisher类。

    然而,我想知道如果这些出版商遇到了一个例外会发生什么。

    我四处看了看 apparently 他们应该这样做:

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

    Source

    一个警告:如果有 我们的自定义发布服务器中有一个例外 MSMQ?为此,我们转向 ExceptionManager.PublishInternalException异常 方法,该方法将发布 默认发布服务器例外, 哪个是Windows应用程序事件 日志。

    但是,PublishInternalException同时受保护 所以我必须实现ExceptionManager,而不是IEExceptionPublisher,才能访问它。

    1 回复  |  直到 14 年前
        1
  •  0
  •   Matt Mitchell    14 年前

    手动调用PublishInternalException的想法一定与早期的测试版有关。当前ExceptionManager将IEExceptionPublisher调用包装在自己的try catch中,try catch调用PublishInternalException本身。如果您在Reflector中查看代码,它基本上是这样做的:

    /* 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