I am making c# wpf application which I need to run at windows startup as aministrator. I am using tasksheduler for this purpose. My application was running fine but recently I added NotifyIcon (from System.Windows.Forms namespace). My application runs fine when it is manually opened, but when it is started with TaskSheduler (on startup), tasksheduler shows 0xE0434352 in last Run Result.
Here is my code for NotifyIcon:
private void Application_Startup(object sender, StartupEventArgs e)
{
public Forms.NotifyIcon ni = new Forms.NotifyIcon();
ni.Visible = true;
ni.Icon = new System.Drawing.Icon("./d.ico");
}
The only explanation I have is that the icon file will not be found. As you start manually the program folder will be a current directory, where the relative path being applied, by TS it can be other folder as program folder.
If you load icon from resources or set to absolute path or specify current directory for TS, then it should work.