An exception of type 'System.Runtime.InteropServices.COMException' occurred in CubicOrange.Windows.Forms.ActiveDirectory.dll but was not handled in user code

Topics: Errors
Mar 24, 2015 at 3:07 PM
Edited Mar 24, 2015 at 3:45 PM
I use TaskEditDialog. On Window 2008 when I try to open "Change User or Group" dialog I get message:
"the program cannot open the required dialog box because it cannot determine whether the computer named '' is joined to a domain"
After closing the dialog I get unhandled exception:
************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80070005): IDsObjectPicker.Initialize failed
   at CubicOrange.Windows.Forms.ActiveDirectory.DirectoryObjectPickerDialog.Initialize()
   at CubicOrange.Windows.Forms.ActiveDirectory.DirectoryObjectPickerDialog.RunDialog(IntPtr hwndOwner)
   at System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
   at Microsoft.Win32.TaskScheduler.HelperMethods.SelectAccount(IWin32Window parent, String targetComputerName, String& acctName, Boolean& isGroup, Boolean& isService, String& sid) in c:\spb.Common Components\TaskScheduler\TaskService\TaskEditor\HelperMethods.cs:line 18
   at Microsoft.Win32.TaskScheduler.TaskPropertiesControl.InvokeObjectPicker(String targetComputerName) in c:\spb.Common Components\TaskScheduler\TaskService\TaskEditor\TaskPropertiesControl.cs:line 632
   at Microsoft.Win32.TaskScheduler.TaskPropertiesControl.changePrincipalButton_Click(Object sender, EventArgs e) in c:\spb.Common Components\TaskScheduler\TaskService\TaskEditor\TaskPropertiesControl.cs:line 538
   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.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I use 2.3.1 version. Before that I used 2.2.2 and got the same message and exception on Windows 8.

images:
Message
Exception
Mar 24, 2015 at 5:38 PM
Also the dialog allows change only to current user. In other cases after ok pressing It always generate unhandled exception:
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at Microsoft.Win32.TaskScheduler.V2Interop.ITaskFolder.RegisterTaskDefinition(String Path, ITaskDefinition pDefinition, Int32 flags, Object UserId, Object password, TaskLogonType LogonType, Object sddl)
   at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition(String Path, TaskDefinition definition, TaskCreation createType, String UserId, String password, TaskLogonType LogonType, String sddl) in c:\spb.Common Components\TaskScheduler\TaskService\TaskFolder.cs:line 404
   at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition(String Path, TaskDefinition definition) in c:\spb.Common Components\TaskScheduler\TaskService\TaskFolder.cs:line 369
   at Microsoft.Win32.TaskScheduler.Task.RegisterChanges() in c:\spb.Common Components\TaskScheduler\TaskService\Task.cs:line 1230
   at Microsoft.Win32.TaskScheduler.TaskEditDialog.okBtn_Click(Object sender, EventArgs e) in c:\spb.Common Components\TaskScheduler\TaskService\TaskEditor\TaskEditDialog.cs:line 280
   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.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Is it right behavior?
Coordinator
Mar 24, 2015 at 9:02 PM
The first error is due to a problem with how that particular system is representing the computer to the domain. The prompt you get is from Windows. The COMException generated and not handled is a bug in the library which I have fixed and will be released in 2.3.2 shortly.

The second error is a permissions problem with the account used to initialize the TaskService. If no account was specified, it is the local account. That account does have permission to make changes to the task.
Marked as answer by dahall on 4/20/2015 at 8:13 AM