Windows Develop Bookmark and Share   
 index > Windows Forms General > NotifyIcon vanishes on some occasions
 

NotifyIcon vanishes on some occasions

I use the System.windows.forms.notifyicon to create a icon in the task tray for a long running client (windows desktop application), which is deployed in a range of users. Occasionly we see a problem when the task tray icon completely disappears, from the task tray. We see this happensometimes after a day or so or after quite a few days, there does not seem to be any consistent pattern here.The last time this happened though it semeed to coincide with high memory and high CPU usage too. I was thinking of writing code to recover from this scenario as a work around for this problem, the problem is i am not sure how to check the available tray icons, and the act accordingly. Any thoughts on how to fix or work around thiswould be greatly appreciated. Thanks all in advance.
anandinnz  Wednesday, September 09, 2009 4:22 PM
You can't check if the icon is still visible, Windows doesn't have an API for it. You can't even find out where your icon is located. You are aware of Windows habit of hiding inactive icons?

Hans Passant.
nobugz  Wednesday, September 09, 2009 4:58 PM
Hi,

I've seen similar issues reported in MSDN newsgroup (not sure was that you?), the icon was not hidden by the notification area, but really disappeared (according to that developer).

Since it is not easy to reproduce the problem - according to the report,the program need to be run continuously for at least a whole night or even several days before the icon "vanishes".

In that report, the problem happened on a Windows XP SP3 box. Can you let me know the environment where you find this problem?

Thanks,
Jie
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

If you have any feedback, please tell us.

The CodeFx Project
My Blog (in Simplified Chinese)
Wang, Jie  Thursday, September 10, 2009 10:33 AM
The standard diagnostic for stuff just disappearing after a while is that a program is leaking handles. The quick check for this is Taskmgr.exe, Programs tab. View + Columns, tick Handles, User32 objects and GDI objects. Observe it while your program is running and actively being used. If a number keeps climbing you've got a leak. Windows pulls the plug when it reaches 10,000.

Hans Passant.
nobugz  Thursday, September 10, 2009 11:19 AM
Thanks for the response. I did not report that in MSDN newsgroup.The problem happens onoccasion and when it doeshappen it does, like you say it doesseems to happenin theWindows XP SP3 Box, we have not seen it on Windows Vista yet.
anandinnz  Thursday, September 10, 2009 3:17 PM
Thanks nobbugz for your responses. I really appreciate it. Interestingly the process doesn't go away, it stays in memory in Task Manager. I actually had a look on one occasion, at the threads, handles, memory etc. and they all seemed fine. The process seems to be running fine, as i see periodic log messages etc from the process, but just that the icon is completely gone. I am also pretty sure the icon was not part of any inactive icons.
anandinnz  Thursday, September 10, 2009 3:22 PM
Thanks for the response. I did not report that in MSDN newsgroup.The problem happens onoccasion and when it doeshappen it does, like you say it doesseems to happenin theWindows XP SP3 Box, we have not seen it on Windows Vista yet.

I built up a simple application which contains a notification icon and a context menu strip. Run it on a Windows XP SP3 box for two days, and the icon is still there. Currently I have no idea how to repro this problem.

Can you build a simple app that can reproduce the problem?

Thanks,
Jie
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

If you have any feedback, please tell us.

The CodeFx Project
My Blog (in Simplified Chinese)
Wang, Jie  Wednesday, September 16, 2009 3:48 AM

You can use google to search for other answers

Custom Search

More Threads

• Service Crashing Randomly getting image from stream and drawing it
• execute control validation
• Using color withTableLayoutPanel
• Help.ShowHelp locking up
• Listbox MulitSelect on MouseDown for DragDrop
• Save File Dialog. (I have code, just need a little help fixing)
• How can I add images to main menu in VS.NET 2003?
• What is the best UI library to get for .NET windows forms development?
• System tray application problem
• Change BackColor of button to the value of a textbox