Back to Devexpress

ProcessStartPolicy.Failed Event

corelibraries-devexpress-dot-data-dot-utils-dot-processstartpolicy-f54f3015.md

latest3.6 KB
Original Source

ProcessStartPolicy.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<ProcessStartPolicy.ProcessStartFailedExceptionEventArgs> Failed
vb
Public Shared Event Failed As EventHandler(Of ProcessStartPolicy.ProcessStartFailedExceptionEventArgs)

Event Data

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

PropertyDescription
ExceptionGets the exception.
ThrowGets or sets whether to throw an exception.

Remarks

The following example demonstrates how to suppress an internal exception and display a message box:

csharp
static void Main() {  
    DevExpress.Data.Utils.ProcessStartPolicy.Failed += ProcessStartPolicy_Failed;  
    //...  
}  

private static void ProcessStartPolicy_Failed(object sender, DevExpress.Data.Utils.ProcessStartPolicy.ProcessStartFailedExceptionEventArgs e) {  
    if(e.Exception is Win32Exception) {  
        System.Diagnostics.ProcessStartInfo si = sender as System.Diagnostics.ProcessStartInfo;  
        e.Throw = false;  
        MessageBox.Show("File not found: " + si.FileName);  
    }  
}
vb
Public Class Form1  
    Shared Sub Main()  
        AddHandler DevExpress.Data.Utils.ProcessStartPolicy.Failed, AddressOf ProcessStartPolicy_Failed  
        Application.EnableVisualStyles()  
        Application.SetCompatibleTextRenderingDefault(False)  
        Application.Run(New Form1)  
    End Sub  

    Private Shared Sub ProcessStartPolicy_Failed(ByVal sender As Object, ByVal e As DevExpress.Data.Utils.ProcessStartPolicy.ProcessStartFailedExceptionEventArgs)  
        If TypeOf e.Exception Is Win32Exception Then  
            Dim si As System.Diagnostics.ProcessStartInfo = TryCast(sender, System.Diagnostics.ProcessStartInfo)  
            e.Throw = False  
            MessageBox.Show("File not found: " & si.FileName)  
        End If  
    End Sub  
End Class

Tip

Exceptions are not raised if a process fails to start. Call the static ThrowOnErrors() method at application startup to throw exceptions.

Read the following topic for more information: Suppress New Processes Initiated by .NET Controls.

See Also

ProcessStartPolicy Class

ProcessStartPolicy Members

DevExpress.Data.Utils Namespace