Application Insights を有効にしたASP.NETプロジェクトから Application Insights SDKを削除する手順を紹介します。
手順
Application Insightsの参照モジュール、ファイルの削除
Application Insights 特有の参照モジュールやファイルを削除します。
Application Insights が有効なプロジェクトと無効なプロジェクトのファイルや参照モジュールの違いは下図になります。
#designer(style="width:45%;float:left;margin-left:10px;margin-right:10px;"){
Application Insights が無効のプロジェクト
![](https://resources.ipentec.com/document/image/visual-studio-asp-net-remove-application-insights-sdk-existing-project-01)
}
#designer(style="width:45%;float:left;margin-left:10px;margin-right:10px;"){
Application Insights が有効のプロジェクト
![](https://resources.ipentec.com/document/image/visual-studio-asp-net-remove-application-insights-sdk-existing-project-02)
}
#designer(style="clear:left"){}
"/scripts"フォルダと内部のファイル("ai.0.15.0-buildnnnnn.js","ai.0.15.0-buildnnnnn.min.js")を削除し、ApplicationInsights.configファイルも削除します。Microsoft.AI名前空間のモジュールの参照を外します。
ファイルと参照モジュール削除後のソリューションエクスプローラです。
Web.configの修正
Web.Configファイルを修正します。
ApplicationInsightsWebTracking モジュールの追加部分のタグを削除します。system.webタグ内のhttpModulesタグの部分と、system.webserverタグ内の2か所あります。
修正前
<?xml version="1.0" encoding="utf-8"?>
<!--
ASP.NET アプリケーションの構成方法の詳細については、
http://go.microsoft.com/fwlink/?LinkId=169433 を参照してください
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
</httpModules>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<remove name="ApplicationInsightsWebTracking"/>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
preCondition="managedHandler"/>
</modules>
</system.webServer>
</configuration>
修正後
<?xml version="1.0" encoding="utf-8"?>
<!--
ASP.NET アプリケーションの構成方法の詳細については、
http://go.microsoft.com/fwlink/?LinkId=169433 を参照してください
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
</configuration>
package.config の修正
package.configファイルを修正します。
packageタグのうち、Application Insightsに関係するもの(名前空間が "Microsoft.ApplicationInsights"のもの)を削除します。
編集前:package.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.ApplicationInsights" version="1.2.3" targetFramework="net452" />
<package id="Microsoft.ApplicationInsights.Agent.Intercept" version="1.2.0" targetFramework="net452" />
<package id="Microsoft.ApplicationInsights.DependencyCollector" version="1.2.3" targetFramework="net452" />
<package id="Microsoft.ApplicationInsights.JavaScript" version="0.15.0-build58334" targetFramework="net452" />
<package id="Microsoft.ApplicationInsights.PerfCounterCollector" version="1.2.3" targetFramework="net452" />
<package id="Microsoft.ApplicationInsights.Web" version="1.2.3" targetFramework="net452" />
<package id="Microsoft.ApplicationInsights.WindowsServer" version="1.2.3" targetFramework="net452" />
<package id="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" version="1.2.3" targetFramework="net452" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net452" developmentDependency="true" />
</packages>
編集後:package.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net452" developmentDependency="true" />
</packages>
以上で作業は完了です。
著者
iPentecのメインプログラマー
C#, ASP.NET の開発がメイン、少し前まではDelphiを愛用
最終更新日: 2017-10-06
作成日: 2016-04-05