{"record":{"id":"566c58dd5dd366f5","repo":"dotnet/wpf","slug":"sr-peoplepickererrorconditionfromopenquerywindow-formatted","errorCode":null,"errorMessage":"SR.PeoplePickerErrorConditionFromOpenQueryWindow (formatted with hresult)","messagePattern":"SR\\.PeoplePickerErrorConditionFromOpenQueryWindow \\(formatted with hresult\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/PeoplePickerWrapper.cs","lineNumber":212,"sourceCode":"                Marshal.FreeCoTaskMem(queryInitParamsPtr);\n                commonQueryInstance = null;\n            }\n            \n            if (hresult == UnsafeNativeMethods.S_OK)\n            {\n                //The user pressed \"OK,\" so we can return the selected data\n                return data;\n            }\n            else if (hresult == UnsafeNativeMethods.S_FALSE)\n            {\n                //The user canceled out, so we just return null.\n                return null;\n            }\n            else\n            {\n                //An error condition was reported, we throw an exception with the\n                //hresult included.\n                throw new InvalidOperationException(\n                    String.Format(CultureInfo.CurrentCulture,\n                        SR.PeoplePickerErrorConditionFromOpenQueryWindow, hresult));\n            }\n        \n        }                    \n        \n        /// <summary>\n        /// Turns a set of AD paths (in the form 'LDAP://CN=...') into a set of\n        /// e-mail addresses by looking up the paths in the Directory and retrieving\n        /// the 'mail' property, if it exists for the given AD object.\n        /// </summary>\n        /// <param name=\"paths\"></param>\n        /// <returns></returns>\n        private String[] GetEmailAddressesFromPaths(String[] paths)\n        {\n            List<String> addresses = new List<String>(paths.Length);\n\n            for (int i = 0; i < paths.Length; i++)","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/PeoplePickerWrapper.cs#L194-L230","documentation":"PeoplePickerWrapper.OpenQueryWindow launches the native Rights Management people-picker dialog and, if the native window reports a failure, throws InvalidOperationException formatted with the returned hresult (SR.PeoplePickerErrorConditionFromOpenQueryWindow). It surfaces an error state coming from the unmanaged RMS dialog as a managed exception.","triggerScenarios":"Show()/publishing flow that calls OpenQueryWindow and the native OpenQueryWindow call returns a nonzero error hresult instead of a window handle/null.","commonSituations":"RMS client misconfiguration, missing AD RMS/Azure RMS connectivity, corrupted RMS machine state, or unsupported OS RMS components when the user clicks 'Add recipients' in a rights-managed publishing dialog.","solutions":["Inspect the hresult embedded in the exception message; map it to the RMS client error and fix the underlying RMS condition (service reachability, machine certificate).","Ensure the RMS client is installed/healthy — test with a known-good rights-managed document and reset RMS machine state if corrupted.","Wrap the people-picker invocation in try-catch and show the hresult to IT/support for diagnosis."],"exampleFix":"// before\nwrapper.ShowDialog(); // may throw with hresult 0x80072751 etc.\n// after\ntry { wrapper.ShowDialog(); }\ncatch (InvalidOperationException ex)\n{\n    Log.Error($\"People picker failed: {ex.Message}\"); // parse hresult, advise RMS remediation\n}","handlingStrategy":"try-catch","validationCode":"// No reliable pre-check; verify RMS client health first:\n// ensure the user can open a known-good protected document before showing the picker.","typeGuard":null,"tryCatchPattern":"try { peoplePicker.ShowDialog(owner); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"OpenQueryWindow\"))\n{ Log.Error(ex); ShowRmsSupportDialog(ex.Message); // includes hresult }","preventionTips":["Ensure the RMS client is installed and machine-activated.","Check RMS service connectivity before the publishing flow.","Parse the hresult from the message for support triage."],"tags":["wpf","rights-management","interop","native-error"],"backgroundTag":"upstream-api-error","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}