Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Windows服务中未处理的异常_C#_.net_Exception - Fatal编程技术网

C# Windows服务中未处理的异常

C# Windows服务中未处理的异常,c#,.net,exception,C#,.net,Exception,我在windows服务应用程序(c#)中使用system.timer,并添加了: AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyExceptionHandler); 为了处理我的异常,这在Windows服务中是否可以正常工作? 有人有其他想法吗?为什么服务中存在未处理的异常?例外

我在windows服务应用程序(c#)中使用system.timer,并添加了:

AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += 
       new UnhandledExceptionEventHandler(MyExceptionHandler);
为了处理我的异常,这在Windows服务中是否可以正常工作?
有人有其他想法吗?

为什么服务中存在未处理的异常?例外情况是什么?有些例外是()


另外,你想在处理程序中做什么?可能您试图在处理程序中执行的操作在作为服务运行时受到限制。

此机制将用于捕获任何环境(包括Windows服务)中未处理的异常。但是,在以这种方式处理何种异常方面存在一些限制。例如,StackOverFlowException可能未经处理,但按照其性质,您永远不会看到它通过未经处理的Exception处理程序

你为什么认为这不起作用?您是否尝试过使用调试器附加到流程,启用第一次机会异常并查看发生了什么