[英]Application insights make the app freeze on startup
我正在使用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工具,但是没有成功。
当我创建一个新的Blank App(通用Windows)时,Visual Studio会自动设置Application Insights,并且可以按预期工作。 但是我无法使其与我现有的项目一起使用。
请帮忙。
不赞成在UWP应用中使用Application Insights的故事,而推荐使用HockeyApp,并且在UWP上存在AI 2.0.0的已知问题。
参见https://github.com/Microsoft/ApplicationInsights-dotnet/issues/210
不久前,我遇到了完全相同的问题,终于设法完成了这项工作。 因此,将project.json中的依赖项更改为如下所示:
"dependencies": {
...
"Microsoft.ApplicationInsights": "1.0.0",
"Microsoft.ApplicationInsights.PersistenceChannel": "1.0.0",
"Microsoft.ApplicationInsights.WindowsApps": "1.0.0"
},
如果这样做没有帮助,我还建议向WindowsAppInitializer添加检测密钥:
WindowsAppInitializer.InitializeAsync("YOURKEY");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.