Export (0) Print
Expand All

RightsManagementException.FailureCode Property

Gets the RightsManagementFailureCode for the error.

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

public RightsManagementFailureCode FailureCode { get; }
/** @property */
public RightsManagementFailureCode get_FailureCode ()

public function get FailureCode () : RightsManagementFailureCode

Members of this class are either not typically used in XAML, or cannot be used in XAML.

Property Value

The failure code for the error.

The following example shows use of the FailureCode and Message properties 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:
© 2014 Microsoft