dotnet/wpf · error · InvalidOperationException

SR.PeoplePickerErrorConditionFromOpenQueryWindow (formatted…

Error message

SR.PeoplePickerErrorConditionFromOpenQueryWindow (formatted with hresult)

What it means

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.

Solutions

  1. 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).
  2. Ensure the RMS client is installed/healthy — test with a known-good rights-managed document and reset RMS machine state if corrupted.
  3. Wrap the people-picker invocation in try-catch and show the hresult to IT/support for diagnosis.

Example fix

// before
wrapper.ShowDialog(); // may throw with hresult 0x80072751 etc.
// after
try { wrapper.ShowDialog(); }
catch (InvalidOperationException ex)
{
    Log.Error($"People picker failed: {ex.Message}"); // parse hresult, advise RMS remediation
}
Defensive patterns

Strategy: try-catch

Validate before calling

// No reliable pre-check; verify RMS client health first:
// ensure the user can open a known-good protected document before showing the picker.

Try / catch

try { peoplePicker.ShowDialog(owner); }
catch (InvalidOperationException ex) when (ex.Message.Contains("OpenQueryWindow"))
{ Log.Error(ex); ShowRmsSupportDialog(ex.Message); // includes hresult }

Prevention

When it happens

Trigger: Show()/publishing flow that calls OpenQueryWindow and the native OpenQueryWindow call returns a nonzero error hresult instead of a window handle/null.

Common situations: 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.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/566c58dd5dd366f5. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/PeoplePickerWrapper.cs:212

                Marshal.FreeCoTaskMem(queryInitParamsPtr);
                commonQueryInstance = null;
            }
            
            if (hresult == UnsafeNativeMethods.S_OK)
            {
                //The user pressed "OK," so we can return the selected data
                return data;
            }
            else if (hresult == UnsafeNativeMethods.S_FALSE)
            {
                //The user canceled out, so we just return null.
                return null;
            }
            else
            {
                //An error condition was reported, we throw an exception with the
                //hresult included.
                throw new InvalidOperationException(
                    String.Format(CultureInfo.CurrentCulture,
                        SR.PeoplePickerErrorConditionFromOpenQueryWindow, hresult));
            }
        
        }                    
        
        /// <summary>
        /// Turns a set of AD paths (in the form 'LDAP://CN=...') into a set of
        /// e-mail addresses by looking up the paths in the Directory and retrieving
        /// the 'mail' property, if it exists for the given AD object.
        /// </summary>
        /// <param name="paths"></param>
        /// <returns></returns>
        private String[] GetEmailAddressesFromPaths(String[] paths)
        {
            List<String> addresses = new List<String>(paths.Length);

            for (int i = 0; i < paths.Length; i++)

View on GitHub (pinned to 81131a70a4)