RightsManagementException Constructor (RightsManagementFailureCode)

RightsManagementException.RightsManagementException(RightsManagementFailureCode) Constructor

Initializes a new instance of the RightsManagementException class with a given RightsManagementFailureCode.

Namespace: System.Security.RightsManagement
Assembly: WindowsBase (in windowsbase.dll)

public RightsManagementException (
	RightsManagementFailureCode failureCode
)
public RightsManagementException (
	RightsManagementFailureCode failureCode
)
public function RightsManagementException (
	failureCode : RightsManagementFailureCode
)
You cannot use constructors in XAML.

Parameters

failureCode

The failure code for the error.

The following example shows use of the FailureCode property to create an error message for the user. For the full sample, see Rights Managed Package Publish Sample.

WriteStatus("   Building secure environment.");
try
{
    string applicationManifest = "<manifest></manifest>";
    if (File.Exists("rpc.xml"))
    {
        StreamReader manifestReader = File.OpenText("rpc.xml");
        applicationManifest = manifestReader.ReadToEnd();
    }

    if (_secureEnv == null)
    {
        if (SecureEnvironment.IsUserActivated(new ContentUser(
                    _currentUserId, AuthenticationType.Windows)))
        {
            _secureEnv = SecureEnvironment.Create(
                applicationManifest, new ContentUser(
                    _currentUserId, AuthenticationType.Windows));
        }
        else
        {
            _secureEnv = SecureEnvironment.Create(
                applicationManifest,
                AuthenticationType.Windows,
                UserActivationMode.Permanent);
        }
    }
}
catch (RightsManagementException ex)
{
    MessageBox.Show("ERROR: Failed to build secure environment.\n" +
        "Exception: " + ex.Message + "\n\n" +
        ex.FailureCode.ToString() + "\n\n" + ex.StackTrace,
        "Rights Management Exception",
        MessageBoxButton.OK, MessageBoxImage.Error);
    return false;
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2016 Microsoft