Go to content

Bulletcode.NET

Diagnostics

The Bulletcode.NET framework makes it possible to handle exceptions in desktop applications in a consistent way. To enable exception handling, call the AddExceptionHandler() extension method of IServiceCollection:

services.AddExceptionHandler();

This enables handling of the following exceptions:

  • AppDomain.UnhandledException
  • TaskScheduler.UnobservedTaskException
  • MauiWinUIApplication.Current.UnhandledException (in Windows applications)

All unhandled exceptions are automatically logged. See the Logging chapter for more information about enabling and configuring the text file logging provider, which can be used in Bulletcode.UI applications.

When an unhandled exception occurs which doesn’t terminate the application, an error dialog is displayed, which makes it possible to view the error details. The user may choose to ignore the error and the application keeps running. Otherwise, the application is shut down.

This behavior can be configured by passing a callback to the AddExceptionHandler() method which modifies the DiagnosticsOptions:

  • ShowErrorDialog — can be set to false to disable the error dialog
  • ErrorDialogName — specifies the name of the dialog to display

By default, the "Error" dialog is used, which is automatically registered when calling AddNavigationProvider().

If the application implements its own error dialog, it can use the IDialogOptions with ErrorDialogOptions to get information about the exception. See Shell for more information about registering and implementing dialogs.