110,534
社区成员
发帖
与我相关
我的任务
分享
//加到服务的构造函数中
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler((sender, e) =>
{
if (e.ExceptionObject != null)
{
Exception ex = e.ExceptionObject as Exception; //你也可以getType查看具体的异常类型
//在这里将异常写入你的日志或者windows日志中
);
}
});