Back to Devexpress

RichEditDocumentServer.UnhandledException Event

officefileapi-devexpress-dot-xtrarichedit-dot-richeditdocumentserver-34dd2a75.md

latest3.1 KB
Original Source

RichEditDocumentServer.UnhandledException Event

This event is raised when an exception unhandled by the RichEditDocumentServer occurs.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
public event RichEditUnhandledExceptionEventHandler UnhandledException
vb
Public Event UnhandledException As RichEditUnhandledExceptionEventHandler

Event Data

The UnhandledException event's data class is RichEditUnhandledExceptionEventArgs. The following properties provide information specific to this event:

PropertyDescription
ExceptionGets the exception which triggers the UnhandledException event.
HandledGets or sets whether the exception should be propagated upwards.

Remarks

The UnhandledException event is helpful when you are unable to catch the exception which is likely to occur. The most common case is an attempt to save the document to a read-only or locked file. If you do not handle the UnhandledException event, the unhandled exception is thrown and the application crashes. All changes in the document are lost. To prevent this, handle the exception using the following code.

csharp
private void richEditDocumentServer1_UnhandledException(object sender, 
    DevExpress.XtraRichEdit.RichEditUnhandledExceptionEventArgs e)
{
    e.Handled = true;
    // Add your code to handle the exception.
    BeginInvoke(new MethodInvoker(delegate()
    {
        MessageBox.Show(e.Exception.Message, "The command is not completed!");
    }));
}
vb
Private Shared My_Exception As Exception

Private Sub richEditDocumentServer1_UnhandledException(ByVal sender As Object, _
        ByVal e As DevExpress.XtraRichEdit.RichEditUnhandledExceptionEventArgs) _
        Handles richEditDocumentServer1.UnhandledException
    My_Exception = e.Exception
    e.Handled = True
    ' Add your code to handle the exception.
    BeginInvoke(New MethodInvoker(AddressOf ShowMessageMethod))
End Sub
Private Shared Sub ShowMessageMethod()
    MessageBox.Show(My_Exception.Message, "The command is not completed!")
End Sub

See Also

RichEditDocumentServer Class

RichEditDocumentServer Members

DevExpress.XtraRichEdit Namespace