Quantcast
Channel: Task Scheduler Managed Wrapper
Viewing all articles
Browse latest Browse all 2206

New Post: TaskSchedulerWizard crashes w. NullReferenceException

$
0
0

Hi,
TaskScheduler v1.9.2.28583
TaskSchedulerEditor v1.9.2.28588
AeroWizard v1.2.3.22616

when using the code below, the TaskSchedulerWizard crashes when clicking on the radio buttons ("Run..." etc.) in the wizard step "Security Options". (see stack trace below).
It also crashes with an "Object reference not set to an instance of an object" exception (see 2nd stack trace) after selecting a user account in the same step.
What am I missing?

      string FolderName = "My Folder";
      using (var taskService = new TaskService())
      {
        bool v2 = taskService.HighestSupportedVersion > new Version(1, 1);

        var taskFolder = taskService.RootFolder;
        if (taskService.HighestSupportedVersion > new Version(1, 0, 0, 0))
        {
          try
          {
            taskService.GetFolder(FolderName);
          }
          catch (FileNotFoundException fex)
          {
            taskFolder.CreateFolder(FolderName);
          }

          taskFolder = taskService.GetFolder(FolderName);
        }

        using (var taskSchedulerWizard = new TaskSchedulerWizard())
        {
          var newTaskDefinition = taskService.NewTask();
          newTaskDefinition.Actions.Add(new ExecAction("notepad.exe"));

          taskSchedulerWizard.Initialize(taskService, newTaskDefinition);
          taskSchedulerWizard.RegisterTaskOnFinish = !v2;

          taskSchedulerWizard.AvailablePages = TaskSchedulerWizard.AvailableWizardPages.IntroPage |
            TaskSchedulerWizard.AvailableWizardPages.SecurityPage |
            TaskSchedulerWizard.AvailableWizardPages.SummaryPage |
            TaskSchedulerWizard.AvailableWizardPages.TriggerPropertiesPage |
            TaskSchedulerWizard.AvailableWizardPages.TriggerSelectPage;

          if (taskSchedulerWizard.ShowDialog() != DialogResult.OK) return;
          if (v2)
          {
            taskFolder.RegisterTaskDefinition(taskSchedulerWizard.TaskName, taskSchedulerWizard.TaskDefinition);
          }
          //    _tlv.Tasks = taskFolder.Tasks;
        }
      }

System.NullReferenceException was unhandled
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=Microsoft.Win32.TaskSchedulerEditor
StackTrace:
at Microsoft.Win32.TaskScheduler.TaskSchedulerWizard.taskLoggedOnRadio_CheckedChanged(Object sender, EventArgs e)
at System.Windows.Forms.RadioButton.OnClick(EventArgs e)
at System.Windows.Forms.RadioButton.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at BassicTech.TestHarness.Form1.btnScheduler_Click(Object sender, EventArgs e) in c:\Projects3\Tester\Form1.cs:line 533
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at BassicTech.TestHarness.Program.Main() in c:\Projects3\Tester\Program.cs:line 17
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

----------- 2nd: stack trace --------------
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Win32.TaskScheduler.TaskSchedulerWizard.changePrincipalButton_Click(Object sender, EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18033 built by: FX45RTMGDR

CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll

TestHarness
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0

CodeBase: file:///C:/Projects3/Tester/bin/x86/Debug/TestHarness.exe

System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18033 built by: FX45RTMGDR

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18022 built by: FX45RTMGDR

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18033 built by: FX45RTMGDR

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18033 built by: FX45RTMGDR

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll

Microsoft.Win32.TaskScheduler
Assembly Version: 1.9.2.28583
Win32 Version: 1.9.2.0

CodeBase: file:///C:/Projects3/Tester/bin/x86/Debug/Microsoft.Win32.TaskScheduler.DLL

Microsoft.Win32.TaskSchedulerEditor
Assembly Version: 1.9.2.28588
Win32 Version: 1.9.2.0

CodeBase: file:///C:/Projects3/Tester/bin/x86/Debug/Microsoft.Win32.TaskSchedulerEditor.DLL

TimeSpan2
Assembly Version: 2.0.2.14660
Win32 Version: 2.0.2.0

CodeBase: file:///C:/Projects3/Tester/bin/x86/Debug/TimeSpan2.DLL

AeroWizard
Assembly Version: 1.2.3.22616
Win32 Version: 1.2.3.0

CodeBase: file:///C:/Projects3/Tester/bin/x86/Debug/AeroWizard.DLL

GroupControls
Assembly Version: 1.3.6.22332
Win32 Version: 1.3.6.0

CodeBase: file:///C:/Projects3/Tester/bin/x86/Debug/GroupControls.DLL

System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll

CubicOrange.Windows.Forms.ActiveDirectory
Assembly Version: 2.2.4395.25898
Win32 Version: 2.2.0.0

CodeBase: file:///C:/Projects3/Tester/bin/x86/Debug/CubicOrange.Windows.Forms.ActiveDirectory.DLL

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.


Viewing all articles
Browse latest Browse all 2206

Trending Articles