There are many questions on SO asking same doubt. Solution for this is to set
notifyIcon.icon = null
and calling Dispose
for it in FormClo
Use this code when you want to do it when you press the Exit or Close button:
private void ExitButton_Click(object sender, EventArgs e)
{
notifyIcon.Dispose();
Application.Exit(); // or this.Close();
}
Use this code when you want to do it when the form is closing:
private void Form1_FormClosing(object sender, EventArgs e)
{
notifyIcon.Dispose();
Application.Exit(); // or this.Close();
}
The important code is this:
notifyIcon.Dispose();