应用程序洞察使应用程序在启动时冻结

时间:2016-03-17 18:34:15

标签: c# azure-application-insights template10

我正在使用Template10为Windows 10构建UWP应用程序。我想使用MS Application Insights。在我的项目中,我引用了:Microsoft.ApplicationInsights(2.0.0),Microsoft.ApplicationInsights.PersistenceChannel(1.2.3),Microsoft.ApplicationInsights.WindowsApps(1.1.1)。在App构造函数中,我必须遵循以下代码:

public App()
{
    WindowsAppInitializer.InitializeAsync();

    InitializeComponent();
    SplashFactory = (e) => new Views.Splash(e);

    #region App settings

    _settings = SettingsService.Instance;
    RequestedTheme = _settings.AppTheme;
    CacheMaxDuration = _settings.CacheMaxDuration;
    ShowShellBackButton = _settings.UseShellBackButton;

    #endregion
}

我还从Azure添加了正确的InstrumentationKey到ApplicationInsights.config,如下所示:

<?xml version="1.0" encoding="utf-8" ?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
    <InstrumentationKey>my-key</InstrumentationKey>
</ApplicationInsights>

但是,当我启动我的应用时,它只会挂在应用徽标上。当我评论WindowsAppInitializer.InitializeAsync();行时,应用正常。

我尝试从项目中删除并读取上述引用,删除并重新安装Visual Studio的Application Insights工具,但没有成功。

当我创建一个新的空白应用程序(通用Windows)时,Visual Studio会自动设置Application Insights并按预期工作。但我不能让它与我现有的项目合作。

请帮忙。

2 个答案:

答案 0 :(得分:2)

关于在UWP应用程序中使用Application Insights的故事正在被弃用,以支持HockeyApp,并且在UWP上存在AI 2.0.0的已知问题。

请参阅https://github.com/Microsoft/ApplicationInsights-dotnet/issues/210

答案 1 :(得分:1)

刚才我遇到了完全相同的问题,我终于成功完成了这项工作。因此,将project.json中的依赖项更改为:

"dependencies": {
    ...
    "Microsoft.ApplicationInsights": "1.0.0",
    "Microsoft.ApplicationInsights.PersistenceChannel": "1.0.0",
    "Microsoft.ApplicationInsights.WindowsApps": "1.0.0"
},

如果这样做无效,我还建议在WindowsAppInitializer中添加检测密钥:

WindowsAppInitializer.InitializeAsync("YOURKEY");
相关问题