This documentation is archived and is not being maintained.
UseLicense Class
Visual Studio 2008
Represents a license that enables access to protected rights managed content.
Assembly: WindowsBase (in WindowsBase.dll)
As with other System.Security.RightsManagement types, UseLicense is only usable in full trust applications.
The following example shows how to use this class to initialize a PublishLicense. For the full sample, see Rights Managed Package Publish Sample.
WriteStatus(" Signing the UnsignedPublishLicense\n" + " to build the PublishLicense."); UseLicense authorsUseLicense; PublishLicense publishLicense = unsignedLicense.Sign(_secureEnv, out authorsUseLicense); WriteStatus(" Binding the author's UseLicense and"); WriteStatus(" obtaining the CryptoProvider."); CryptoProvider cryptoProvider = authorsUseLicense.Bind(_secureEnv); WriteStatus(" Creating the EncryptedPackage."); Stream packageStream = File.OpenRead(packageFile); EncryptedPackageEnvelope ePackage = EncryptedPackageEnvelope.CreateFromPackage(encryptedFile, packageStream, publishLicense, cryptoProvider); WriteStatus(" Adding an author's UseLicense."); RightsManagementInformation rmi = ePackage.RightsManagementInformation; rmi.SaveUseLicense(author, authorsUseLicense); ePackage.Close(); WriteStatus(" Done - Package encryption complete."); WriteStatus("Verifying package encryption."); if (EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(encryptedFile)) { WriteStatus(" Confirmed - '" + encryptedFilename + "' is encrypted."); } else { MessageBox.Show("ERROR: '" + encryptedFilename + "' is NOT ENCRYPTED.", "Encryption Error", MessageBoxButton.OK, MessageBoxImage.Error); WriteStatus("ERROR: '" + encryptedFilename + "' is NOT ENCRYPTED.\n"); return false; }
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: