0

我正在使用 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 Tools,但没有成功。

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

请帮忙。

4

2 回答 2

2

围绕在 UWP 应用中使用 Application Insights 的故事已被弃用,取而代之的是 HockeyApp,并且 UWP 上的 AI 2.0.0 存在一个已知问题。

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

于 2016-03-18T00:51:09.693 回答
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");
于 2016-03-18T23:51:53.867 回答