开发者

Error Handling in Windows Service

开发者 https://www.devze.com 2023-03-03 23:05 出处:网络
How can i write generic error handler in my windows service? I tried the following code in OnStart method but it is not catching the exceptions.

How can i write generic error handler in my windows service? I tried the following code in OnStart method but it is not catching the exceptions.

protected override void开发者_StackOverflow OnStart(string[] args)
{

                AppDomain.CurrentDomain.UnhandledException += new 
UnhandledExceptionEventHandler(UnhandledExceptionTrapper);
                this.Start();
}

Is there something i am missing here?


You're probably getting exceptions on background threads. Wrap all code in all event handlers in try/catch blocks.

0

精彩评论

暂无评论...
验证码 换一张
取 消