I'm using Application Insights for a WPF Application. Tracking of PageViews and custom events is working.
Now I would like to track crashes. My idea was to:
private void AppDispatcherUnhandledException(object sender,
DispatcherUnhandledExceptionEventArgs e)
{
telemetryClient.TrackException(e.Exception);
telemetryClient.Flush();
}
The code is called when a unhandled exception occurs but it is not shown as "Crash" in the Application Insights portal. I have read somewhere that TrackException does not count as "Crash" when the application does not really crash.
Desktop (e.g. WPF) applications must use the low level API of Application Insights. I have not found a way to tell Application Insights that the WPF Application is crashing.
How could I do that?
For WPF applications, there is no inherent support for capturing crashes. Your statement "The code is called when a unhandled exception occurs but it is not shown as "Crash" in the Application Insights portal. I have read somewhere that TrackException does not count as "Crash" when the application does not really crash." - is true.
Here is the documentation describing it.
If you still want to treat the exceptions that you are handling to be treated as crashes, the one way that you can do that is by treating the tracked exception as unhandled.
Here is how -