2017-08-17 24 views
0

當我厭倦了在SharePoint佈局aspx頁面中引用「Microsoft.ApplicationInsights」時,出現以下錯誤,該頁面沒有頁面後面的代碼。如何在aspx頁面內聯編碼中添加程序集引用

在編譯請求的文件或其依賴項之一時發生錯誤。類型或命名空間名稱「TelemetryClient」找不到(是否缺少using指令或程序集引用?)

嘗試以下方法

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

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

下面是aspx頁面中的一行內嵌C#代碼,其中我試圖創建TelemetryClient對象以將數據記錄到Azure中

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

回答

0

<%@ Import Namespace="Microsoft.ApplicationInsights" %>是包含命名空間的正確方法,但如果出現錯誤,那麼仍然您在項目中是否採用了/添加了該dll Microsoft.ApplicationInsights的引用?(或)可能從NuGet安裝

+0

它會引用GAC在服務器上的權利?我將SharePoint wsp打包在本地並將其部署到服務器上。 – krishna

相關問題