简体   繁体   中英

Tray Icon is working in Debug Mode, Not in Release Mode

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.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM