Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm working with NotifyIcon too, and there are some issues with that. First, you need to set an Icon for the NotifyIcon and be sure you didn't set it's Visibility to anything but Visibility.Visible.</p> <p>Then, NotifyIcon is just a wrapper around the NotifyIcon Windows API, and there's a known issue that it cannot always be created. Therefore, when you initialize the NotifyIcon <strong>it might throw an Exception</strong> because of an error in Windows (the WinApi returns false if it couldn't be created, and in the source code they throw an Exception there). When it does that, you can just recreate the NotifyIcon in a loop until it can be created.</p> <p>I also saw an issue sometime when the NotifyIcon was not created in the app.xaml as a XAML object but in code, since then I always create it in XAML instead of in code. Also now I imported the <a href="http://www.codeproject.com/Articles/36468/WPF-NotifyIcon" rel="nofollow">whole NotifyIcon project from CodeProject</a> to be able to debug it's interior. So now I'm creating it in this way:</p> <pre><code> &lt;NotifyIcon1:NotifyIcon x:Key="NotifyIcon" x:Name="notifyicon" ToolTipText="" Visibility="Visible" IconSource="/Images/Icons/bulb.ico"/&gt; </code></pre> <p>This should throw an Exception if the icon cannot be created in this part of the code in the NotifyIcon library:</p> <pre><code>/// &lt;summary&gt; /// Creates the taskbar icon. This message is invoked during initialization, /// if the taskbar is restarted, and whenever the icon is displayed. /// &lt;/summary&gt; private void CreateTaskbarIcon() { lock (this) { if (!IsTaskbarIconCreated) { const IconDataMembers members = IconDataMembers.Message | IconDataMembers.Icon | IconDataMembers.Tip; //write initial configuration var status = Util.WriteIconData(ref iconData, NotifyCommand.Add, members); if (!status) { throw new Win32Exception("Could not create icon data"); } //set to most recent version SetVersion(); messageSink.Version = (NotifyIconVersion) iconData.VersionOrTimeout; IsTaskbarIconCreated = true; } } } </code></pre> <p>Either you directly edit the code to your needs or you try to recreate the notifyicon when there's an Exception. </p> <p>I guess this will be the problem because it was the same for us, as sometimes after startup Windows is not yet ready to create the icon. Should there be another issue for you, please post the code you use to create the notifyicon and the system (XP? 64bit?) on which the problem arises.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload