0

当我厌倦了在没有页面背后代码的 SharePoint 布局 aspx 页面中引用“Microsoft.ApplicationInsights”时,我收到了以下错误。

在编译请求的文件或其依赖项之一期间发生错误。找不到类型或命名空间名称“TelemetryClient”(您是否缺少 using 指令或程序集引用?)

尝试了以下方法

<%@ Assembly Name="Microsoft.ApplicationInsights, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"%>

并且

<%@ Import Namespace="Microsoft.ApplicationInsights" %>

在我试图创建 TelemetryClient 对象以将数据记录到 Azure 的 aspx 页面中的一段内联 C# 代码下方

.....
TelemetryClient telemetryClient = new TelemetryClient();
telemetryClient.InstrumentationKey = instKey;
telemetryClient.TrackException(ex, sp_coid);
.....
4

1 回答 1

0

<%@ Import Namespace="Microsoft.ApplicationInsights" %>是包含命名空间的正确方法,但如果您遇到错误,那么您是否在项目中获取/添加了该 dll 的引用Microsoft.ApplicationInsights(或)可能从 NuGet 安装

于 2017-08-17T13:42:43.260 回答