问题描述
我有一个Windows窗体应用程序在程序启动时有这个代码:
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.Automatic );
在它说明:
>
有没有人知道配置文件中哪些元素/属性会影响这个设置?
您可以在配置文件中添加JitDebugging部分,如下所示:
< configuration>
< system.windows.forms jitDebugging =true/>
< / config>
这相当于将UnhandledExceptionMode设置为 UnhandledExceptionMode.ThrowException $ c
注意, UnhandledExceptionMode.Automatic
请注意,如果将ThreadException附加到当前AppDomain,结果自动就好像您将UnhandledExceptionMode设置为 UnhandledExceptionMode.CatchException
。
I have a Windows Forms application that has this code in the program's start up:
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.Automatic);
In the MSDN Documentation for UnhandledExceptionMode.Automatic it states that:
Automatic - Route all exceptions to the ThreadException handler, unless the application's configuration file specifies otherwise.
Does anyone know exactly which element/attribute in the config file it is that affects this setting?
You can add a JitDebugging section to your config file like this:
<configuration>
<system.windows.forms jitDebugging="true"/>
</configuration>
This is equivalent to setting the UnhandledExceptionMode to UnhandledExceptionMode.ThrowException
(incidentally, if you run your application with a Debugger attached, this option is automatically enabled).
Note that UnhandledExceptionMode.Automatic
is the default used by .Net unless you specify otherwise; as far as I can tell, the only reason to explicitly set the Unhandled Exception Mode to Automatic is if you want to undo a previous call that changed it to something else. Note that if you do set it to something other than Automatic, the configuration file setting will not be read.
Note that if you attach a ThreadException to the current AppDomain, the result is automatically as if you had set the UnhandledExceptionMode to UnhandledExceptionMode.CatchException
.
这篇关于哪个.config元素影响异常处理,UnhandledExceptionMode设置为UnhandledExceptionMode.Automatic?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!