1

I'm Currently Working in Windows Application.

I just created a tray Icon while closing the Form, Tray Icon is visible in System Tray.

While Left Click the Tray Icon Form is maximized to normal state.

Right Click Event is not working in Release Mode, but working in Debug Mode.

After Building this application Right Event is not working, the output.exe file from Debug mode.

Any help would be appreciated. Thanks in Advance.

In form Load

private void MainRelease_Load(object sender, EventArgs e)
{
    TrayIcon.Visible = false;
    TrayMenu.Items.Add("Exit");
    TrayMenu.Items[0].Click += new System.EventHandler(this.Dispose_Click);
}

In button close Event

   private void btnClose_Click(object sender, EventArgs e)
{
    this.WindowState = FormWindowState.Minimized;
    TrayIcon.Visible = true;
    ShowInTaskbar = false;
}

In Tray Icon mouse click Event

private void TrayIcon_MouseClick(object sender, MouseEventArgs e)
{
    if (e.Button == System.Windows.Forms.MouseButtons.Left)
    {
        this.WindowState = FormWindowState.Normal;
        TrayIcon.Visible = false;
        ShowInTaskbar = true;

    }
    if (e.Button == System.Windows.Forms.MouseButtons.Right)
    {
        TrayMenu.Show(Cursor.Position.X, Cursor.Position.Y);
    }
}

Tray Menu dispose event

private void Dispose_Click(object Sender, EventArgs e)
{
    TrayIcon.Visible = false;
    TrayIcon.Icon = null;
    TrayIcon.Dispose();
    Application.Exit();
}

While in Release Mode Tray Icon Mouse Right Click Event is not working . But in Debug Mode its working.

Please Help me to solve this Issue.

Ganesh Pravin
  • 79
  • 1
  • 13

1 Answers1

0

Maybe this is a dumb answer, but are you sure your release build is up to date? If your debugging in the designer then the release build isn't updated when you run a Build unless you set it up that way. Maybe your release build is from before you added code to handle the right click?

If its not that, does the release build work if you run it from the Release folder rather than debugging in release mode from the designer?

Ashigore
  • 4,618
  • 1
  • 19
  • 39
  • Release build is up to date only. I deleted both Debug and Release folder and created a new build.Then also error persists. – Ganesh Pravin Nov 15 '13 at 08:59