次の方法で共有


方法: Web.config ファイルを変更して、動的にコンパイルされた ASP.NET Web アプリケーションをインストルメント化およびプロファイルする

Visual Studio プロファイリング ツールのインストルメンテーション メソッドを使用すると、動的にコンパイルされた ASP.NET Web アプリケーションから、詳細なタイミング データ、.NET のメモリの割り当てデータ、.NET オブジェクトの有効期間に関するデータを収集できます。

このトピックでは、Web.config 構成ファイルを変更して、ASP.NET Web アプリケーションのインストルメント化とプロファイルを実行できるようにする方法について説明します。

[!メモ]

サンプリング プロファイル方法を使用する場合や、プリコンパイル済みの ASP.NET モジュールをインストルメント化する場合は、Web.config ファイルを変更する必要はありません。

Web.config ファイルのルートは、configuration 要素です。動的にコンパイルされた ASP.NET Web アプリケーションをインストルメント化してプロファイルするためには、次の要素を追加または変更する必要があります。

  • プロファイリングを制御する Microsoft.VisualStudio.Enterprise.ASPNetHelper アセンブリを識別する configuration/runtime/assemblyBinding/dependentAssembly 要素。dependentAssembly 要素には、assemblyIdentity および codeBase という 2 つの子要素が含まれます。

  • プロファイラーの対象アセンブリに対するコンパイルの後処理手順を指定する configuration/system.web/compilation 要素。

  • プロファイリング ツールの configuration/appSettings セクションにおける追加位置を識別する 2 つの add 要素。

アプリケーションの構成を元に戻すことができるように、変更前の Web.config ファイルのコピーを作成しておくことをお勧めします。

ASPNetHelper アセンブリを configuration/runtime/assemblyBinding/dependentAssembly 要素として追加するには

  1. 必要に応じて、runtime 要素を configuration 要素の子要素として追加します。この操作が不要な場合は、次の手順に進みます。

    runtime 要素には属性がありません。configuration 要素には、runtime 子要素を 1 つだけ追加できます。

  2. 必要に応じて、assemblyBinding 要素を runtime 要素の子要素として追加します。この操作が不要な場合は、次の手順に進みます。

    runtime 要素には、assemblyBinding 要素を 1 つだけ追加できます。

  3. assemblyBinding 要素に次の属性名と値を追加します。

    属性名

    属性値

    Xmlns

    urn:schemas-microsoft-com:asm.v1

  4. assemblyBinding 要素の子要素として dependentAssembly 要素を追加します。

    dependentAssembly 要素には属性がありません。

  5. dependentAssembly 要素の子として assemblyIdentity 要素を追加します。

  6. assemblyIdentity 要素に次の属性名と値を追加します。

    属性名

    属性値

    name

    Microsoft.VisualStudio.Enterprise.ASPNetHelper

    PublicKeyToken

    b03f5f7f11d50a3a

    culture

    Neutral

  7. dependentAssembly 要素の子として codeBase 要素を追加します。

  8. codeBase 要素に次の属性名と値を追加します。

    属性名

    属性値

    version

    10.0.0.0

    href

    PathToASPNetHelperDll

    PathToASPNetHelperDll は、Microsoft.VisualStudio.Enterprise.ASPNetHelper.dll のファイル URL です。Visual Studio が既定の場所にインストールされている場合、href の値は C:/Program%20Files/Microsoft%20Visual%20Studio%202010.0/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.Enterprise.ASPNetHelper.DLL となります。

    <configuration>
        <runtime>
            <assemblyBinding 
                xmlns="urn:schemas-microsoft-com:asm.v1"
            >
                <dependentAssembly>
                    <assemblyIdentity                         name="Microsoft.VisualStudio.Enterprise.ASPNetHelper" 
                        publicKeyToken="b03f5f7f11d50a3a"                         culture="neutral" 
                    />
                    <codeBase 
                        version="10.0.0.0"
                        href="file:///C:/Program%20Files/Microsoft%20Visual%20Studio%2010.0/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.Enterprise.ASPNetHelper.DLL" 
                    />
                </dependentAssembly>
            </assemblyBinding>
        </runtime>

プロファイラーの後処理手順を configuration/system.web/compilation 要素に追加するには

  1. 必要に応じて、system.web 要素を configuration 要素の子要素として追加します。この操作が不要な場合は、次の手順に進みます。

    system.web 要素には属性がありません。configuration 要素には、system.web 子要素を 1 つだけ追加できます。

  2. 必要に応じて、compilation 要素を system.web 要素の子要素として追加します。この操作が不要な場合は、次の手順に進みます。

    system.web 要素には、compilation 子要素を 1 つだけ追加できます。

  3. compilation 要素の既存の属性を削除し、次の属性名と値を追加します。

    属性名

    属性値

    assemblyPostProcessorType

    Microsoft.VisualStudio.Enterprise.Common.AspPerformanceInstrumenter, Microsoft.VisualStudio.Enterprise.ASPNetHelper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

    <configuration>
        <runtime>
        . . .
        </runtime>
        <system.web>
            <compilation
                assemblyPostProcessorType="Microsoft.VisualStudio.Enterprise.Common.AspPerformanceInstrumenter,
                    Microsoft.VisualStudio.Enterprise.ASPNetHelper,
                    Version=10.0.0.0,
                    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
            />
        </system.web>
    <configuration>

プロファイラーの場所の設定を configuration/appSettings 要素に追加するには

  1. 必要に応じて、appSettings 要素を configuration 要素の子要素として追加します。この操作が不要な場合は、次の手順に進みます。

    appSettings 要素には属性がありません。configuration 要素には、appSettings 子要素を 1 つだけ追加できます。

  2. appSettings 要素の子として add 要素を追加します。

  3. add 要素に次の属性名と値を追加します。

    属性名

    属性値

    key

    Microsoft.VisualStudio.Enterprise.AspNetHelper.VsInstrLocation

    value

    PerformanceToolsFolder\VSInstr.Exe

  4. appSettings 要素の子要素として add 要素をもう 1 つ追加します。

  5. この add 要素に次の属性名と値を追加します。

    属性名

    属性値

    key

    Microsoft.VisualStudio.Enterprise.AspNetHelper.VsInstrTools

    value

    PerformanceToolsFolder

    PerformanceToolsFolder は、プロファイラーの実行可能ファイルのパスです。Visual Studio が既定の場所にインストールされている場合、この値は C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Performance Tools となります。

    <configuration>
        <runtime>
        . . .
        </runtime>
        . . .
        <system.web>
        </system.web>
        <appSettings>
            <add
                key="Microsoft.VisualStudio.Enterprise.AspNetHelper.VsInstrLocation"
                value="C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Performance Tools\vsinstr.exe"
        />
            <add
                key="Microsoft.VisualStudio.Enterprise.AspNetHelper.VsInstrTools"
                value="C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Performance Tools\"
            />
        </appSettings>
    </configuration>

使用例

動的にコンパイルされた ASP.NET Web アプリケーションのインストルメント化とプロファイルが有効になった Web.config ファイルのすべての内容を次に示します。この例では、変更前のファイルに他の設定が含まれていなかったことを前提としています。

<?xml version="1.0"?>
    <configuration>
        <runtime>
            <assemblyBinding 
                xmlns="urn:schemas-microsoft-com:asm.v1"
            >
                <dependentAssembly>
                    <assemblyIdentity 
                        name="Microsoft.VisualStudio.Enterprise.ASPNetHelper" 
                        publicKeyToken="b03f5f7f11d50a3a"
                        culture="neutral" 
                    />
                    <codeBase 
                        version="10.0.0.0"
                        href="file:///C:/Program%20Files/Microsoft%20Visual%20Studio%2010.0/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.Enterprise.ASPNetHelper.DLL" 
                    />
                </dependentAssembly>
            </assemblyBinding>
        </runtime>
        <system.web>
            <compilation
                assemblyPostProcessorType="Microsoft.VisualStudio.Enterprise.Common.AspPerformanceInstrumenter,
                    Microsoft.VisualStudio.Enterprise.ASPNetHelper,
                    Version=10.0.0.0,
                    Culture=neutral,
                    PublicKeyToken=b03f5f7f11d50a3a" 
            />
        </system.web>
        <appSettings>
            <add
                key="Microsoft.VisualStudio.Enterprise.AspNetHelper.VsInstrLocation"
                value="C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Performance Tools\vsinstr.exe"
            />
            <add
                key="Microsoft.VisualStudio.Enterprise.AspNetHelper.VsInstrTools"
                value="C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Performance Tools\"
            />
        </appSettings>
    </configuration>

参照

処理手順

方法: プロファイラーのコマンド ラインを使用して動的にコンパイルされた ASP.NET Web アプリケーションをインストルメントし、詳細なタイミング データを収集する

方法: プロファイラーのコマンド ラインを使用して動的にコンパイルされた ASP.NET Web アプリケーションをインストルメントし、メモリ データを収集する