企业库handlingInstanceId

时间:2009-12-24 14:55:32

标签: .net exception-handling

我可以在不使用自定义处理程序的情况下获得handlingInstanceId(我正在使用标准处理程序)。

1 个答案:

答案 0 :(得分:0)

如果您使用的是ReplaceHandler,您实际上可以将handlingInstanceID放在自定义错误消息中:

<exceptionHandling>
  <exceptionPolicies>
    <add name="ReplacingException">
      <exceptionTypes>
        <add name="Exception" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
          postHandlingAction="ThrowNewException">
          <exceptionHandlers>
            <add name="Replace Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
              exceptionMessage="An application error occurred and has been logged with error code: {handlingInstanceID}"
              exceptionMessageResourceName="" exceptionMessageResourceType=""
              replaceExceptionType="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          </exceptionHandlers>
        </add>
      </exceptionTypes>
    </add>
  </exceptionPolicies>
</exceptionHandling>