Back to Devexpress

RegistryAccessPolicy.Failed Event

corelibraries-devexpress-dot-data-dot-utils-dot-registryaccesspolicy-77adce3a.md

latest3.6 KB
Original Source

RegistryAccessPolicy.Failed Event

Allows you to respond to associated failures.

Namespace : DevExpress.Data.Utils

Assembly : DevExpress.Data.Desktop.v25.2.dll

NuGet Packages : DevExpress.Data.Desktop, DevExpress.ExpressApp.Win.Design

Declaration

csharp
public static event EventHandler<RegistryAccessPolicy.FailedEventArgs> Failed
vb
Public Shared Event Failed As EventHandler(Of RegistryAccessPolicy.FailedEventArgs)

Event Data

The Failed event's data class is RegistryAccessPolicy.FailedEventArgs. The following properties provide information specific to this event:

PropertyDescription
ExceptionGets the exception.
OperationGets the registry operation being processed.
ThrowGets or sets whether to throw an exception.

Remarks

The Failed event occurs when the RegistryAccessPolicy throws an exception and allows you to respond to the associated failure:

csharp
using DevExpress.Data.Utils;
using DevExpress.Data.Utils.Registry.Internal;

[STAThread]
static void Main() {
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    RegistryAccessPolicy.ThrowAlways();
    RegistryAccessPolicy.Failed += RegistryAccessPolicy_Failed;
    Application.Run(new Form1());
}

static void RegistryAccessPolicy_Failed(object sender, RegistryAccessPolicy.FailedEventArgs e) {
    if(e.Operation == RegistryOperation.QueryValue || e.Operation == RegistryOperation.EnumerateSubKeyTree) {
        e.Throw = false;
    }
}
vb
Imports DevExpress.Data.Utils
Imports DevExpress.Data.Utils.Registry.Internal

<STAThread>
Shared Sub Main()
    Application.EnableVisualStyles()
    Application.SetCompatibleTextRenderingDefault(False)
    RegistryAccessPolicy.ThrowAlways()
    AddHandler RegistryAccessPolicy.Failed, AddressOf RegistryAccessPolicy_Failed
    Application.Run(New Form1())
End Sub

Shared Sub RegistryAccessPolicy_Failed(ByVal sender As Object, ByVal e As RegistryAccessPolicy.FailedEventArgs)
    If e.Operation = RegistryOperation.QueryValue OrElse e.Operation = RegistryOperation.EnumerateSubKeyTree Then
        e.Throw = False
    End If
End Sub

Tip

  • ThrowAlways() – Throws an exception when the control accesses the system registry.
  • ThrowOnErrors() – Throws an exception if a request to the system registry fails.

Read the following topic for additional information: Registry Access Policy.

See Also

RegistryAccessPolicy Class

RegistryAccessPolicy Members

DevExpress.Data.Utils Namespace