Hi dahall, I'm having the same problem and seems the posted code doesn't work.
Here is my code using taskscheduler-78172 running on Windows XP Professional 2002 SP3.
using(TaskService ts = new TaskService())
{
TaskDefinition td = ts.NewTask();
TaskSchedulerWizard wizard = new TaskSchedulerWizard();
wizard.Initialize(ts, td);
wizard.RegisterTaskOnFinish = true;
wizard.ShowDialog();
}
When I come to Security Options page, user account is automatically displayed, and I click Next button, popup dialog shows to input user name and password.
After I input them, I got this exception:
System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="Microsoft.Win32.TaskSchedulerEditor"
StackTrace:
at Microsoft.Win32.TaskScheduler.CredentialsDialog.IsValidPassword(String userName, String password)
at Microsoft.Win32.TaskScheduler.CredentialsDialog.RunDialog(IntPtr parentWindowHandle)
at System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
at Microsoft.Win32.TaskScheduler.TaskSchedulerWizard.InvokeCredentialDialog(String userName)
at Microsoft.Win32.TaskScheduler.TaskSchedulerWizard.secOptPage_Commit(Object sender, WizardPageConfirmEventArgs e)
at AeroWizard.WizardPage.OnCommit()
at AeroWizard.WizardPage.CommitPage()
at AeroWizard.WizardControl.NextPage(WizardPage nextPage)
at AeroWizard.WizardControl.NextPage()
at AeroWizard.WizardControl.nextButton_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.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(Int32 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.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at DataUploadAutomationTest.TaskScheduler.OpenWizard() in C:\Source\DataUploadAutomationTest\DataUploadAutomationTest\TaskScheduler.cs:line 28
at DataUploadAutomationTest.TaskScheduler.Main(String[] args) in C:\Source\DataUploadAutomationTest\DataUploadAutomationTest\TaskScheduler.cs:line 15
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Any idea?