Why do I get Win32Exception when running from TaskScheduler?

455 views Asked by At

I get an exception ONLY when I run from TaskScheduler:

static class Program
{
    [STAThread]
    static void Main(string[] args)
     {
        Application.Run(new Master());
     }
}

public partial class Master : Form
{

   public Master()  //  EXCEPTION OCCURS HERE
   {

   }
}

Task Scheduler:

Run whether user logged in or not : Checked 
Run with highest privileges : Checked

System.ComponentModel.Win32Exception was unhandled HResult=-2147467259 Message=The specified procedure could not be found Source=System.Windows.Forms ErrorCode=-2147467259 NativeErrorCode=127 StackTrace: at System.Windows.Forms.NativeWindow.WindowClass.RegisterClass() at System.Windows.Forms.NativeWindow.WindowClass.Create(String className, Int32 classStyle) at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp) at System.Windows.Forms.Control.CreateHandle() at System.Windows.Forms.Application.MarshalingControl..ctor() at System.Windows.Forms.Application.ThreadContext.get_MarshalingControl() at System.Windows.Forms.WindowsFormsSynchronizationContext..ctor() at System.Windows.Forms.WindowsFormsSynchronizationContext.InstallIfNeeded() at System.Windows.Forms.Control..ctor(Boolean autoInstallSyncContext) at System.Windows.Forms.ScrollableControl..ctor() at System.Windows.Forms.ContainerControl..ctor() at System.Windows.Forms.Form..ctor() at FssClient.Master..ctor() at FssClient.Program.Main(String[] args) InnerException:

0

There are 0 answers