【问题标题】:Catching runtime exceptions in IoC container在 IoC 容器中捕获运行时异常
【发布时间】:2011-04-06 23:45:21
【问题描述】:

我将 Spring.NET 与 Caliburn 2 一起使用,并在运行时从这些框架中获取一些异常(例如 Spring.NET 中的 NoSuchObjectDefinitionException 和 UnsatisfiedDependencyException,Caliburn 中的 NullReferenceException)。

这些异常是在我的 App.xaml.cs InitializeComponent() 方法完成之后引发的,这意味着(据我所知)我的代码中没有行专门导致错误,因此没有任何东西可以包含在 try-catch 中。几乎可以肯定我在某个地方错误地配置了 Spring 或 Caliburn,但我真的很想知道这些异常包含的任何线索,以便弄清楚。

有没有办法在运行时捕获和检查第三方框架代码生成的异常?

【问题讨论】:

    标签: c# .net spring.net caliburn


    【解决方案1】:

    你可以使用

    Application.DispatcherUnhandledException
    AppDomain.CurrentDomain.UnhandledException
    

    事件。

    这应该会捕获所有您无法使用 try/catch 自己包装的异常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-01
      • 2018-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多