Visual Studio Application Insights 工具栏未显示事件

Visual Studio Application Insights toolbar not showing events

我不熟悉 Application Insights 并测试在控制台应用程序中发送自定义数据的概念。我设法在 Azure 门户的搜索栏中看到了自定义事件,太棒了。

我的问题出在我阅读的一些教程中,Visual Studio 中有一个工具栏显示事件的数量,例如Application Insights (21) 但我的只有 Application Insights 旁边没有数字,点击它显示 0 个事件

我的代码非常简单:

static void Main(string[] args)
{
    TelemetryConfiguration.Active.InstrumentationKey = "APPLICATIONINSIGHTS_GUID";

    TelemetryClient TC = new TelemetryClient();
    TC.TrackEvent("My event");
    TC.Flush();
}

我有 Visual Studio 2015。我应该安装一些东西来让它工作吗?

您可能需要将 ApplicationInsights.config 文件添加到您的项目中。

确保生成操作是 Content 并且输出目录是 Copy if newer / Copy always 以便它在生成时将文件复制到输出目录

另外,确保你的配置文件中至少有 <ApplicationInsights ... 根标签。像这样:

    <?xml version="1.0" encoding="utf-8"?>
    <ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
    </ApplicationInsights>