2009-07-20 72 views

回答

5

对于C#,尝试处理来自AppDomain中的UnhandledException事件,所以,在你Main()方法Add:

AppDomain.CurrentDomain.UnhandledException += 
    new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); 

,然后添加下面的方法:

static void CurrentDomain_UnhandledException(object sender, 
    UnhandledExceptionEventArgs e) 
{ 
    // .... Remove Notification icon here 
} 
4

不幸的是,答案是否定的 - Rob的答案实际上检测到崩溃并尝试删除崩溃处理程序中的图标,该图标有其自己的一系列问题(例如,它假定有足够的CLR在崩溃时正在运行以执行未处理的异常,那不是一个请小心)。

这里的问题是shell(它运行Shell_NotifyIcon代码)与您的应用程序不同步。