I registered some WPF from as startup like this
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
Assembly curAssembly = Assembly.GetExecutingAssembly();
key.SetValue(curAssembly.GetName().Name, Process.GetCurrentProcess().MainModule.FileName);
and register NotifyIcon like this
HandyOrderPOSIcon = new System.Windows.Forms.NotifyIcon();
HandyOrderPOSIcon.Icon = new System.Drawing.Icon("Icon.ico");
HandyOrderPOSIcon.Visible = true;
HandyOrderPOSIcon.ContextMenuStrip = menuStrip;
HandyOrderPOSIcon.MouseClick += delegate (object sender, System.Windows.Forms.MouseEventArgs e) {
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
menuStrip.Show();
}
};
When restart Windows, it throw a Exception like this
but when execute this program manually, it works without this exception.
