2

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?

4

1 回答 1

2

对于 WPF 应用程序,没有对捕获崩溃的固有支持。您的声明“当发生未处理的异常时调用代码,但它在 Application Insights 门户中未显示为“崩溃”。我在某处读到,当应用程序没有真正崩溃时,TrackException 不算作“崩溃”。” - 是真的。
是描述它的文档。

如果您仍然希望将正在处理的异常视为崩溃,那么您可以这样做的一种方法是将跟踪的异常视为未处理。

这是如何 -

        var exceptionTelemetry = new Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry(new Exception());
        exceptionTelemetry.HandledAt = Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.Unhandled;
        telemetryClient.TrackException(exceptionTelemetry);
于 2015-06-25T23:02:57.930 回答