Why is UnhandledExceptionEventArgs.ExceptionObject an object and not an Exception?

后端 未结 2 2054
时光取名叫无心
时光取名叫无心 2020-12-04 17:33

Why is UnhandledExceptionEventArgs.ExceptionObject an object and not an Exception?

I am attaching to AppDomain.UnhandledException

2条回答
  •  眼角桃花
    2020-12-04 17:48

    In addition to what Jared has already mentioned, you can safely cast to Exception in .NET Framework 2.0 and higher if RuntimeCompatibilityAttribute(WrapNonExceptionThrows=true) has been applied to your assembly (will be added automatically by the C# and VB compilers).

    When this attribute has been applied, non-Exception "exceptions" will be wrapped in RuntimeWrappedException.

提交回复
热议问题