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

New Post: TaskEditDialog throws NullReferenceException on OK button click if RegisterTaskOnAccept is true

$
0
0
TaskEditDialog editorForm = new TaskEditDialog( );
editorForm.Editable = true;
editorForm.RegisterTaskOnAccept = true;
editorForm.Initialize( SelectedTask );
editorForm.ShowDialog( );
I know there are other questions about this issue but I've not found a solution in those other questions.

My application registers 3 x Tasks during installation. I want the tasks to run "Run whether user is logged on or not" so I need the user to enter their password at some stage. (Running the Tasks as SYSTEM will not work for my app).

I have a GridControl which loads the Tasks from a particular Folder as ItemsSource. Selecting a Task in the GridControl and Clicking the Editor button shows that Task in the TaskEditDialog.

With RegisterTaskOnAccept set to True clicking OK on the TaskEditDialog shows the NullReferenceException. Clicking Cancel doesn't.
Also using this method, selecting the "Run whether user is logged on or not" radio button shows the Password Dialog when it's OK button is clicked it shows the same NullReferenceException.

With RegisterTaskOnAccept set to false and manually registering the task after the TaskEditDialog has closed then everything works but then how can I get the Password Dialog to show using this method?

I've tried this on Windows 7 64bit which is on a Domain and on Windows 7 32bit which is not on a Domain, both with the same result.
Using .Net4.0 and Nuget to manage TaskSchedulerManagedWrapper (Version 2.0.0)


System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition(String Path, TaskDefinition definition, TaskCreation createType, String UserId, String password, TaskLogonType LogonType, String sddl)
   at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition(String Path, TaskDefinition definition)
   at Microsoft.Win32.TaskScheduler.Task.RegisterChanges()
   at Microsoft.Win32.TaskScheduler.TaskEditDialog.okBtn_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(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.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Viewing all articles
Browse latest Browse all 2206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>