COMException when choosing other user in TaskEditDialog

Topics: Errors
Oct 7, 2013 at 12:57 PM
I'm using the TaskEditDialog to create a task, but when I click on the button "Change user or group" I get an error saying that no locations can be found and then an exception is thrown with this message: "IDsObjectPicker.Initialize failed"
This is my code
string taskDescription = "Opens notepad";
string taskName = "NotepadOpener";
                  using (TaskService ts = new TaskService())
                    var action = new ExecAction("notepad.exe", null, Environment.CurrentDirectory);

                    MonthlyTrigger trigger = new MonthlyTrigger(1, MonthsOfTheYear.AllMonths) { DaysOfMonth = new int[0], RunOnLastDayOfMonth = true };

                    TaskDefinition td = ts.NewTask();
                    td.Settings.StartWhenAvailable = true;
                    td.RegistrationInfo.Description = taskDescription;
                    td.Principal.LogonType = TaskLogonType.Password;

                    TaskEditDialog editorForm = new TaskEditDialog();
                    editorForm.Editable = true;
                    editorForm.RegisterTaskOnAccept = true;
                    editorForm.Initialize(ts, td);
                    editorForm.TaskName = taskName;
I'm using Windows 7 and I get no such error if I open Task scheduler from windows
Oct 8, 2013 at 12:11 AM
This is a COM method that is failing when trying to launch the system dialog for finding Active Directory objects (like users and groups). My guess is that there is something peculiar about how your system is connected to your domain or workplace. Running this same code on my Windows 7 environment does not throw an exception. When you get the exception, there should be an HResult property with the result from the COM method call. If you post that value, it might help us understand why that method is failing.
Oct 8, 2013 at 7:52 AM
Thanks for the quick response.
The HRESULT is "-2147024809"
My workstation is not a part of a domain, but I assume that shouldn't cause issues?!
Oct 9, 2013 at 2:25 AM
This error is E_INVALID_ARG. I am using another CodePlex project for the ActiveDirectory object picker dialog ( and it seems to be a deficiency in that library. It is a bit of code that has not been updated since 2008 and is wildly complex. I'm not sure why you're getting the error. If you are up to debugging that code and arrive at a solution, please let me know.
Oct 9, 2013 at 9:25 AM
I have seemed to fix it by changing this line in the method SelectAccount in the HelperMethods Class:

dlg.AllowedObjectTypes = ObjectTypes.BuiltInGroups | ObjectTypes.Groups | ObjectTypes.Users | ObjectTypes.WellKnownPrincipals;
dlg.AllowedObjectTypes = ObjectTypes.BuiltInGroups | ObjectTypes.Groups | ObjectTypes.Users | ObjectTypes.WellKnownPrincipals | ObjectTypes.Computers;
Oct 10, 2013 at 12:03 AM
Thanks for resolving this. I have added this change with the most recent source code update and it will get rolled out in the next release.
Mar 5, 2014 at 4:31 PM
Is the fix integrated in the latest codes? It seems to be still different.
Mar 12, 2014 at 4:10 PM
This is fixed in the source code, but has not been compiled into a downloadable assembly for release. If you grab the latest code, you can compile it yourself. A new assembly is forthcoming.
Marked as answer by dahall on 9/1/2015 at 10:08 AM