【问题标题】:Application insights make the app freeze on startup应用程序洞察力使应用程序在启动时冻结
【发布时间】:2016-03-19 07:51:53
【问题描述】:

我正在使用 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 向ApplicationInsights.config 添加了正确的 InstrumentationKey,如下所示:

<?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 Tools,但没有成功。

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

请帮忙。

【问题讨论】:

    标签: c# azure-application-insights template10


    【解决方案1】:

    有关在 UWP 应用中使用 Application Insights 的故事正在被 HockeyApp 弃用,并且 UWP 上的 AI 2.0.0 存在一个已知问题。

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

    【讨论】:

    • 我什至尝试将 Application Insights 包降级到 1.2.3。这样应用程序才能工作,但 Insights 不能:( 但是,您的链接将我引向article,它表示自 4 月 15 日起,MS 将不再接受使用 AI 的新 UWP 应用程序,并在 6 月 15 日完全关闭该服务。所以,似乎我所有的努力都付诸东流了。我仍然不明白,他们如何取代使用这种劣质产品的人工智能(HockeyApp)。
    【解决方案2】:

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

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

    如果这没有帮助,我还建议向 WindowsAppInitializer 添加检测密钥:

    WindowsAppInitializer.InitializeAsync("YOURKEY");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-17
      • 2015-11-10
      • 1970-01-01
      • 2022-07-06
      • 2014-05-24
      • 1970-01-01
      相关资源
      最近更新 更多