简体   繁体   English

应用程序见解使应用程序在启动时冻结

[英]Application insights make the app freeze on startup

I'm building a UWP application for Windows 10 using Template10. 我正在使用Template10为Windows 10构建UWP应用程序。 I would like to use MS Application Insights. 我想使用MS Application Insights。 In my project, I have references to: Microsoft.ApplicationInsights (2.0.0), Microsoft.ApplicationInsights.PersistenceChannel (1.2.3), Microsoft.ApplicationInsights.WindowsApps (1.1.1). 在我的项目中,我引用了: Microsoft.ApplicationInsights (2.0.0), Microsoft.ApplicationInsights.PersistenceChannel (1.2.3), Microsoft.ApplicationInsights.WindowsApps (1.1.1)。 In the App constructor, I have to following code: 在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
}

I have also added a correct InstrumentationKey from Azure to the ApplicationInsights.config like so: 我还从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>

However, when I launch my app, it simply hangs at the app logo. 但是,当我启动我的应用程序时,它只是挂在应用程序徽标上。 When I comment the WindowsAppInitializer.InitializeAsync(); 当我评论WindowsAppInitializer.InitializeAsync(); line out, the app works normal. 排队,该应用程序正常运行。

I have tried removing and readding the mentioned references from the project, removing and reinstalling Application Insights Tools for Visual Studio, but without a success. 我尝试从项目中删除和读取提到的参考,删除并重新安装Visual Studio的Application Insights工具,但是没有成功。

When I create a new Blank App (Universal Windows), Visual Studio sets up the Application Insights automatically and it works as expected. 当我创建一个新的Blank App(通用Windows)时,Visual Studio会自动设置Application Insights,并且可以按预期工作。 But I cannot get it to work with my existing project. 但是我无法使其与我现有的项目一起使用。

Please help. 请帮忙。

The story around using Application Insights in UWP apps is being deprecated in favor of HockeyApp, and there is a known issue with AI 2.0.0 on UWP. 不赞成在UWP应用中使用Application Insights的故事,而推荐使用HockeyApp,并且在UWP上存在AI 2.0.0的已知问题。

See https://github.com/Microsoft/ApplicationInsights-dotnet/issues/210 参见https://github.com/Microsoft/ApplicationInsights-dotnet/issues/210

Just a moment ago I had exactly the same problem and I finally managed to make this work. 不久前,我遇到了完全相同的问题,终于设法完成了这项工作。 So change dependencies in project.json to look like that: 因此,将project.json中的依赖项更改为如下所示:

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

If this won't help I also recommend adding instrumentation key to WindowsAppInitializer: 如果这样做没有帮助,我还建议向WindowsAppInitializer添加检测密钥:

WindowsAppInitializer.InitializeAsync("YOURKEY");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM