【发布时间】:2016-10-07 13:31:59
【问题描述】:
我已经更新了 Visual Studio 2015 更新 3,用于使用 Url 中的说明添加的更新 1 配置文件,但它不起作用我如何在 Windows 10 通用应用程序中将见解发送到 azure,
【问题讨论】:
标签: windows-10-universal windows-10-mobile azure-application-insights
我已经更新了 Visual Studio 2015 更新 3,用于使用 Url 中的说明添加的更新 1 配置文件,但它不起作用我如何在 Windows 10 通用应用程序中将见解发送到 azure,
【问题讨论】:
标签: windows-10-universal windows-10-mobile azure-application-insights
您使用的是哪个网址?
对于 VS2015 更新 3,您必须:
1) 使用 nuget 包管理器手动添加 microsoft.applicationinsights.windowsapps 包
2) 在 App 构造函数中的 App.xaml.cs 中添加启动代码:
public void App()
{
// add this code to initialize AI. do not await here, you'll slow down
// app startup, use continuewith to get/set any AI thing you need after
// it initializes
WindowsAppsInitializer.InitializeAsync().ContinueWith( t =>
{
// any other code you need to do with app insights here
}, continuationOptions: TaskContinuationOptions.OnlyRanToCompletion );
this.InitializeComponent();
// ... any other startup code here
}
3) 如果这样做没有将 applicationinsights.config 文件添加到您的项目中,请手动创建一个文本文件,即:
<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights>
<InstrumentationKey>[your key here]</InstrumentationKey>
</ApplicationInsights>
(某些版本的说明使用了一个旧的配置文件示例,其中包含一些 cmets,并且 cmets 包含一个 <InstrumentationKey> 标签,并且出于性能原因,windows 应用程序 sdk 启动使用正则表达式来查找键而不是加载完整的 xml 解析器,因此如果有带有检测键的 cmets,它将使用它作为您的 ikey 而不是真正的 xml!)
4) 在 VS 中将该文件添加到您的项目中,并将其属性设置为:
Build Action: Content
Copy to Output Directory: Copy if Newer
(在您的 .csproj 中看起来像这样)
<Content Include="ApplicationInsights.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
如果您在调用 InitializeAsync 时手动设置代码中的检测密钥,则不需要 applicationinsights.config 文件。
【讨论】: