RightsManagementInformation.LoadPublishLicense Method ()


Returns the embedded PublishLicense from the encrypted rights management data stream.

Namespace:   System.IO.Packaging
Assembly:  WindowsBase (in WindowsBase.dll)

public PublishLicense LoadPublishLicense()

Return Value

Type: System.Security.RightsManagement.PublishLicense

The embedded PublishLicense; or null, if the package does not contain a PublishLicense.

Exception Condition

The rights management information in this package cannot be read by the current version of this class.

The following example shows how to use the LoadPublishLicense method.

ShowStatus("   Opening the encrypted Package.");
EncryptedPackageEnvelope ePackage =
    EncryptedPackageEnvelope.Open(xpsFile, FileAccess.ReadWrite);
RightsManagementInformation rmi =

ShowStatus("   Looking for an embedded UseLicense for user:\n       " +
           currentUserId + " [" + _authentication + "]");
UseLicense useLicense =
        new ContentUser(currentUserId, _authentication));

ReadOnlyCollection<ContentGrant> grants;
if (useLicense == null)
    ShowStatus("   No Embedded UseLicense found.\n       " +
               "Attempting to acqure UseLicnese\n       " +
               "from the PublishLicense.");
    PublishLicense pubLicense = rmi.LoadPublishLicense();

    ShowStatus("   Referral information:");

    if (pubLicense.ReferralInfoName == null)
        ShowStatus("       Name: (null)");
        ShowStatus("       Name: " + pubLicense.ReferralInfoName);

    if (pubLicense.ReferralInfoUri == null)
        ShowStatus("    Uri: (null)");
        ShowStatus("    Uri: " +

    useLicense = pubLicense.AcquireUseLicense(_secureEnv);
    if (useLicense == null)
        ShowStatus("   User DOES NOT HAVE RIGHTS\n       " +
            "to access this document!");
        return false;
}// end:if (useLicense == null)
ShowStatus("   UseLicense acquired.");

.NET Framework
Available since 3.0
Return to top