corelibraries-devexpress-dot-data-dot-utils-dot-processstartpolicy-f54f3015.md
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
public static event EventHandler<ProcessStartPolicy.ProcessStartFailedExceptionEventArgs> Failed
Public Shared Event Failed As EventHandler(Of ProcessStartPolicy.ProcessStartFailedExceptionEventArgs)
The Failed event's data class is ProcessStartPolicy.ProcessStartFailedExceptionEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Exception | Gets the exception. |
| Throw | Gets or sets whether to throw an exception. |
The following example demonstrates how to suppress an internal exception and display a message box:
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);
}
}
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