Compartilhar via


RightsManagementException Construtores

Definição

Inicializa uma nova instância da classe RightsManagementException.

Sobrecargas

RightsManagementException()

Inicializa uma nova instância da classe RightsManagementException.

RightsManagementException(RightsManagementFailureCode)

Inicializa uma nova instância da classe RightsManagementException com um RightsManagementFailureCode fornecido.

RightsManagementException(String)

Inicializa uma nova instância da classe RightsManagementException com uma mensagem fornecida.

RightsManagementException(SerializationInfo, StreamingContext)

Inicializa uma nova instância da classe RightsManagementException e define o repositório SerializationInfo com informações sobre a exceção.

RightsManagementException(RightsManagementFailureCode, Exception)

Inicializa uma nova instância da classe RightsManagementException com um RightsManagementFailureCode e um InnerException fornecidos.

RightsManagementException(RightsManagementFailureCode, String)

Inicializa uma nova instância da classe RightsManagementException com um RightsManagementFailureCode e um Message fornecidos.

RightsManagementException(String, Exception)

Inicializa uma nova instância da classe RightsManagementException com um Message e um InnerException fornecidos.

RightsManagementException(RightsManagementFailureCode, String, Exception)

Inicializa uma nova instância da classe RightsManagementException com um RightsManagementFailureCode, um Message e um InnerException fornecidos.

Exemplos

O exemplo a seguir mostra o RightsManagementExceptionuso do .

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;
}
WriteStatus("   Building secure environment.")
Try
    Dim applicationManifest As String = "<manifest></manifest>"
    If File.Exists("rpc.xml") Then
        Dim manifestReader As StreamReader = File.OpenText("rpc.xml")
        applicationManifest = manifestReader.ReadToEnd()
    End If

    If _secureEnv Is Nothing Then
        If SecureEnvironment.IsUserActivated(New ContentUser(_currentUserId, AuthenticationType.Windows)) Then
            _secureEnv = SecureEnvironment.Create(applicationManifest, New ContentUser(_currentUserId, AuthenticationType.Windows))
        Else
            _secureEnv = SecureEnvironment.Create(applicationManifest, AuthenticationType.Windows, UserActivationMode.Permanent)
        End If
    End If
Catch ex As RightsManagementException
    MessageBox.Show("ERROR: Failed to build secure environment." & vbLf & "Exception: " & ex.Message & vbLf & vbLf & ex.FailureCode.ToString() & vbLf & vbLf & ex.StackTrace, "Rights Management Exception", MessageBoxButton.OK, MessageBoxImage.Error)
    Return False
End Try

RightsManagementException()

Inicializa uma nova instância da classe RightsManagementException.

public:
 RightsManagementException();
public RightsManagementException ();
Public Sub New ()

Exemplos

O exemplo a seguir mostra o RightsManagementExceptionuso do .

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;
}
WriteStatus("   Building secure environment.")
Try
    Dim applicationManifest As String = "<manifest></manifest>"
    If File.Exists("rpc.xml") Then
        Dim manifestReader As StreamReader = File.OpenText("rpc.xml")
        applicationManifest = manifestReader.ReadToEnd()
    End If

    If _secureEnv Is Nothing Then
        If SecureEnvironment.IsUserActivated(New ContentUser(_currentUserId, AuthenticationType.Windows)) Then
            _secureEnv = SecureEnvironment.Create(applicationManifest, New ContentUser(_currentUserId, AuthenticationType.Windows))
        Else
            _secureEnv = SecureEnvironment.Create(applicationManifest, AuthenticationType.Windows, UserActivationMode.Permanent)
        End If
    End If
Catch ex As RightsManagementException
    MessageBox.Show("ERROR: Failed to build secure environment." & vbLf & "Exception: " & ex.Message & vbLf & vbLf & ex.FailureCode.ToString() & vbLf & vbLf & ex.StackTrace, "Rights Management Exception", MessageBoxButton.OK, MessageBoxImage.Error)
    Return False
End Try

Aplica-se a

RightsManagementException(RightsManagementFailureCode)

Inicializa uma nova instância da classe RightsManagementException com um RightsManagementFailureCode fornecido.

public:
 RightsManagementException(System::Security::RightsManagement::RightsManagementFailureCode failureCode);
public RightsManagementException (System.Security.RightsManagement.RightsManagementFailureCode failureCode);
new System.Security.RightsManagement.RightsManagementException : System.Security.RightsManagement.RightsManagementFailureCode -> System.Security.RightsManagement.RightsManagementException
Public Sub New (failureCode As RightsManagementFailureCode)

Parâmetros

failureCode
RightsManagementFailureCode

O código de falha para o erro.

Exemplos

O exemplo a seguir mostra o FailureCode uso da propriedade para criar uma mensagem de erro para o usuário.

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;
}
WriteStatus("   Building secure environment.")
Try
    Dim applicationManifest As String = "<manifest></manifest>"
    If File.Exists("rpc.xml") Then
        Dim manifestReader As StreamReader = File.OpenText("rpc.xml")
        applicationManifest = manifestReader.ReadToEnd()
    End If

    If _secureEnv Is Nothing Then
        If SecureEnvironment.IsUserActivated(New ContentUser(_currentUserId, AuthenticationType.Windows)) Then
            _secureEnv = SecureEnvironment.Create(applicationManifest, New ContentUser(_currentUserId, AuthenticationType.Windows))
        Else
            _secureEnv = SecureEnvironment.Create(applicationManifest, AuthenticationType.Windows, UserActivationMode.Permanent)
        End If
    End If
Catch ex As RightsManagementException
    MessageBox.Show("ERROR: Failed to build secure environment." & vbLf & "Exception: " & ex.Message & vbLf & vbLf & ex.FailureCode.ToString() & vbLf & vbLf & ex.StackTrace, "Rights Management Exception", MessageBoxButton.OK, MessageBoxImage.Error)
    Return False
End Try

Aplica-se a

RightsManagementException(String)

Inicializa uma nova instância da classe RightsManagementException com uma mensagem fornecida.

public:
 RightsManagementException(System::String ^ message);
public RightsManagementException (string message);
new System.Security.RightsManagement.RightsManagementException : string -> System.Security.RightsManagement.RightsManagementException
Public Sub New (message As String)

Parâmetros

message
String

Uma mensagem que descreve o erro.

Exemplos

O exemplo a seguir mostra o Message uso da propriedade para criar uma mensagem de erro para o usuário.

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;
}
WriteStatus("   Building secure environment.")
Try
    Dim applicationManifest As String = "<manifest></manifest>"
    If File.Exists("rpc.xml") Then
        Dim manifestReader As StreamReader = File.OpenText("rpc.xml")
        applicationManifest = manifestReader.ReadToEnd()
    End If

    If _secureEnv Is Nothing Then
        If SecureEnvironment.IsUserActivated(New ContentUser(_currentUserId, AuthenticationType.Windows)) Then
            _secureEnv = SecureEnvironment.Create(applicationManifest, New ContentUser(_currentUserId, AuthenticationType.Windows))
        Else
            _secureEnv = SecureEnvironment.Create(applicationManifest, AuthenticationType.Windows, UserActivationMode.Permanent)
        End If
    End If
Catch ex As RightsManagementException
    MessageBox.Show("ERROR: Failed to build secure environment." & vbLf & "Exception: " & ex.Message & vbLf & vbLf & ex.FailureCode.ToString() & vbLf & vbLf & ex.StackTrace, "Rights Management Exception", MessageBoxButton.OK, MessageBoxImage.Error)
    Return False
End Try

Aplica-se a

RightsManagementException(SerializationInfo, StreamingContext)

Inicializa uma nova instância da classe RightsManagementException e define o repositório SerializationInfo com informações sobre a exceção.

protected:
 RightsManagementException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected RightsManagementException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Security.RightsManagement.RightsManagementException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.RightsManagement.RightsManagementException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parâmetros

info
SerializationInfo

O objeto que contém os dados serializados.

context
StreamingContext

As informações contextuais sobre a origem ou o destino.

Confira também

Aplica-se a

RightsManagementException(RightsManagementFailureCode, Exception)

Inicializa uma nova instância da classe RightsManagementException com um RightsManagementFailureCode e um InnerException fornecidos.

public:
 RightsManagementException(System::Security::RightsManagement::RightsManagementFailureCode failureCode, Exception ^ innerException);
public RightsManagementException (System.Security.RightsManagement.RightsManagementFailureCode failureCode, Exception innerException);
new System.Security.RightsManagement.RightsManagementException : System.Security.RightsManagement.RightsManagementFailureCode * Exception -> System.Security.RightsManagement.RightsManagementException
Public Sub New (failureCode As RightsManagementFailureCode, innerException As Exception)

Parâmetros

failureCode
RightsManagementFailureCode

O código de falha para o erro.

innerException
Exception

A instância de exceção que causou o erro.

Exemplos

O exemplo a seguir mostra o uso da e Message das FailureCode propriedades para criar uma mensagem de erro para o usuário.

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;
}
WriteStatus("   Building secure environment.")
Try
    Dim applicationManifest As String = "<manifest></manifest>"
    If File.Exists("rpc.xml") Then
        Dim manifestReader As StreamReader = File.OpenText("rpc.xml")
        applicationManifest = manifestReader.ReadToEnd()
    End If

    If _secureEnv Is Nothing Then
        If SecureEnvironment.IsUserActivated(New ContentUser(_currentUserId, AuthenticationType.Windows)) Then
            _secureEnv = SecureEnvironment.Create(applicationManifest, New ContentUser(_currentUserId, AuthenticationType.Windows))
        Else
            _secureEnv = SecureEnvironment.Create(applicationManifest, AuthenticationType.Windows, UserActivationMode.Permanent)
        End If
    End If
Catch ex As RightsManagementException
    MessageBox.Show("ERROR: Failed to build secure environment." & vbLf & "Exception: " & ex.Message & vbLf & vbLf & ex.FailureCode.ToString() & vbLf & vbLf & ex.StackTrace, "Rights Management Exception", MessageBoxButton.OK, MessageBoxImage.Error)
    Return False
End Try

Aplica-se a

RightsManagementException(RightsManagementFailureCode, String)

Inicializa uma nova instância da classe RightsManagementException com um RightsManagementFailureCode e um Message fornecidos.

public:
 RightsManagementException(System::Security::RightsManagement::RightsManagementFailureCode failureCode, System::String ^ message);
public RightsManagementException (System.Security.RightsManagement.RightsManagementFailureCode failureCode, string message);
new System.Security.RightsManagement.RightsManagementException : System.Security.RightsManagement.RightsManagementFailureCode * string -> System.Security.RightsManagement.RightsManagementException
Public Sub New (failureCode As RightsManagementFailureCode, message As String)

Parâmetros

failureCode
RightsManagementFailureCode

O código de falha para o erro.

message
String

Uma mensagem que descreve o erro.

Exemplos

O exemplo a seguir mostra o uso da e Message das FailureCode propriedades para criar uma mensagem de erro para o usuário.

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;
}
WriteStatus("   Building secure environment.")
Try
    Dim applicationManifest As String = "<manifest></manifest>"
    If File.Exists("rpc.xml") Then
        Dim manifestReader As StreamReader = File.OpenText("rpc.xml")
        applicationManifest = manifestReader.ReadToEnd()
    End If

    If _secureEnv Is Nothing Then
        If SecureEnvironment.IsUserActivated(New ContentUser(_currentUserId, AuthenticationType.Windows)) Then
            _secureEnv = SecureEnvironment.Create(applicationManifest, New ContentUser(_currentUserId, AuthenticationType.Windows))
        Else
            _secureEnv = SecureEnvironment.Create(applicationManifest, AuthenticationType.Windows, UserActivationMode.Permanent)
        End If
    End If
Catch ex As RightsManagementException
    MessageBox.Show("ERROR: Failed to build secure environment." & vbLf & "Exception: " & ex.Message & vbLf & vbLf & ex.FailureCode.ToString() & vbLf & vbLf & ex.StackTrace, "Rights Management Exception", MessageBoxButton.OK, MessageBoxImage.Error)
    Return False
End Try

Aplica-se a

RightsManagementException(String, Exception)

Inicializa uma nova instância da classe RightsManagementException com um Message e um InnerException fornecidos.

public:
 RightsManagementException(System::String ^ message, Exception ^ innerException);
public RightsManagementException (string message, Exception innerException);
new System.Security.RightsManagement.RightsManagementException : string * Exception -> System.Security.RightsManagement.RightsManagementException
Public Sub New (message As String, innerException As Exception)

Parâmetros

message
String

Uma mensagem que descreve o erro.

innerException
Exception

A instância de exceção que causou essa exceção.

Exemplos

O exemplo a seguir mostra o Message uso da propriedade para criar uma mensagem de erro para o usuário.

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;
}
WriteStatus("   Building secure environment.")
Try
    Dim applicationManifest As String = "<manifest></manifest>"
    If File.Exists("rpc.xml") Then
        Dim manifestReader As StreamReader = File.OpenText("rpc.xml")
        applicationManifest = manifestReader.ReadToEnd()
    End If

    If _secureEnv Is Nothing Then
        If SecureEnvironment.IsUserActivated(New ContentUser(_currentUserId, AuthenticationType.Windows)) Then
            _secureEnv = SecureEnvironment.Create(applicationManifest, New ContentUser(_currentUserId, AuthenticationType.Windows))
        Else
            _secureEnv = SecureEnvironment.Create(applicationManifest, AuthenticationType.Windows, UserActivationMode.Permanent)
        End If
    End If
Catch ex As RightsManagementException
    MessageBox.Show("ERROR: Failed to build secure environment." & vbLf & "Exception: " & ex.Message & vbLf & vbLf & ex.FailureCode.ToString() & vbLf & vbLf & ex.StackTrace, "Rights Management Exception", MessageBoxButton.OK, MessageBoxImage.Error)
    Return False
End Try

Aplica-se a

RightsManagementException(RightsManagementFailureCode, String, Exception)

Inicializa uma nova instância da classe RightsManagementException com um RightsManagementFailureCode, um Message e um InnerException fornecidos.

public:
 RightsManagementException(System::Security::RightsManagement::RightsManagementFailureCode failureCode, System::String ^ message, Exception ^ innerException);
public RightsManagementException (System.Security.RightsManagement.RightsManagementFailureCode failureCode, string message, Exception innerException);
new System.Security.RightsManagement.RightsManagementException : System.Security.RightsManagement.RightsManagementFailureCode * string * Exception -> System.Security.RightsManagement.RightsManagementException
Public Sub New (failureCode As RightsManagementFailureCode, message As String, innerException As Exception)

Parâmetros

failureCode
RightsManagementFailureCode

O código de falha para o erro.

message
String

Uma mensagem que descreve o erro.

innerException
Exception

A instância de exceção que causou o erro.

Exemplos

O exemplo a seguir mostra o uso da e Message das FailureCode propriedades para criar uma mensagem de erro para o usuário.

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;
}
WriteStatus("   Building secure environment.")
Try
    Dim applicationManifest As String = "<manifest></manifest>"
    If File.Exists("rpc.xml") Then
        Dim manifestReader As StreamReader = File.OpenText("rpc.xml")
        applicationManifest = manifestReader.ReadToEnd()
    End If

    If _secureEnv Is Nothing Then
        If SecureEnvironment.IsUserActivated(New ContentUser(_currentUserId, AuthenticationType.Windows)) Then
            _secureEnv = SecureEnvironment.Create(applicationManifest, New ContentUser(_currentUserId, AuthenticationType.Windows))
        Else
            _secureEnv = SecureEnvironment.Create(applicationManifest, AuthenticationType.Windows, UserActivationMode.Permanent)
        End If
    End If
Catch ex As RightsManagementException
    MessageBox.Show("ERROR: Failed to build secure environment." & vbLf & "Exception: " & ex.Message & vbLf & vbLf & ex.FailureCode.ToString() & vbLf & vbLf & ex.StackTrace, "Rights Management Exception", MessageBoxButton.OK, MessageBoxImage.Error)
    Return False
End Try

Aplica-se a