dotnet/wpf · error · MS.Internal.Security.RightsManagement.RightsManagementException
InvalidLicense
InvalidLicense
Error message
RightsManagementFailureCode.InvalidLicense
What it means
GetUserFromHandle parses an issuance-license user handle (name + ID-type strings from the native license). If the userIdType string does not match any supported authentication type (Windows, Passport, etc., including the 'Unspecified' fallback), the license's user section violates the expected schema and the library throws RightsManagementException with FailureCode.InvalidLicense.
Solutions
- Verify the license XML user entries use supported ID-TYPE values (Windows, Passport, or unspecified).
- Re-issue the license with a standard publisher/AuthenticationType.
- Upgrade to a framework version recognizing the newer authentication types.
- Catch RightsManagementException(FailureCode.InvalidLicense) around UnsignedPublishLicense parsing.
Example fix
// before
var ulp = new UnsignedPublishLicense(rawLicenseXml); // throws InvalidLicense on unknown ID-TYPE
// after: validate user types first
var doc = XDocument.Parse(rawLicenseXml);
bool ok = doc.Descendants("IDTYPE").All(e =>
e.Value.Equals("Windows", StringComparison.OrdinalIgnoreCase) ||
e.Value.Equals("Passport", StringComparison.OrdinalIgnoreCase));
if (!ok) throw new InvalidDataException("License has unsupported user ID-TYPE.");
var ulp = new UnsignedPublishLicense(rawLicenseXml); Defensive patterns
Strategy: validation
Validate before calling
var allowed = new[]{"Windows","Passport","Unspecified"};
foreach (var idtype in XDocument.Parse(licenseXml).Descendants("IDTYPE"))
if (!allowed.Contains(idtype.Value, StringComparer.OrdinalIgnoreCase))
throw new InvalidDataException($"Unsupported user ID-TYPE: {idtype.Value}"); Type guard
static bool IsSupportedAuthType(string idType) =>
idType != null &&
(idType.Equals("Windows", StringComparison.OrdinalIgnoreCase) ||
idType.Equals("Passport", StringComparison.OrdinalIgnoreCase) ||
idType.Equals("Unspecified", StringComparison.OrdinalIgnoreCase)); Try / catch
catch (RightsManagementException ex) when (ex.FailureCode == RightsManagementFailureCode.InvalidLicense) { /* re-issue or upgrade the license */ } Prevention
- Normalize user authentication types to supported values when authoring licenses.
- Validate license user sections before constructing UnsignedPublishLicense.
- Upgrade the framework when consuming licenses from newer issuers.
When it happens
Trigger: Reading user entries from an issuance license (via GetIssuanceLicenseUser / GetIssuanceLicenseInfo) whose ID-TYPE attribute is an unrecognized authentication-type string.
Common situations: Licenses issued by non-WPF tools with custom or localized ID-TYPE values; corrupted or hand-edited license XML; newer license formats using types this framework version doesn't know.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- InvalidLicense
- EncryptionNotPermitted
- RightNotGranted
- ArgumentOutOfRangeException(right)
- ArgumentOutOfRangeException(user)
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/4b0c30eebecb92cd.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Security/RightsManagement/IssuanceLicense.cs:614
}
else if (string.Equals(userIdTypeStr, AuthenticationType.Internal.ToString(), StringComparison.OrdinalIgnoreCase))
{
// internal anyone user
if (ContentUser.CompareToAnyone(userIdStr))
{
return ContentUser.AnyoneUser;
}
else if (ContentUser.CompareToOwner(userIdStr))
{
return ContentUser.OwnerUser;
}
}
else if (string.Equals(userIdTypeStr, UnspecifiedAuthenticationType, StringComparison.OrdinalIgnoreCase))
{
return new ContentUser(userNameStr, AuthenticationType.WindowsPassport);
}
throw new RightsManagementException(RightsManagementFailureCode.InvalidLicense);
}
private ContentUser GetIssuanceLicenseUser(int index, out SafeRightsManagementPubHandle userHandle)
{
Invariant.Assert(index >= 0);
int hr = SafeNativeMethods.DRMGetUsers(
_issuanceLicenseHandle, (uint)index, out userHandle);
// there is a special code indication end of the enumeration
if (hr == (int)RightsManagementFailureCode.NoMoreData)
{
userHandle = null;
return null;
}
// check for errors
Errors.ThrowOnErrorCode(hr);View on GitHub (pinned to 81131a70a4)