AssemblyBuilder イベント

名前 | 説明 | |
---|---|---|
![]() | ModuleResolve | 共通言語ランタイム クラス ローダーが、通常の方法で参照をアセンブリの内部モジュールに解決できないときに発生します。 ( Assembly から継承されます。) |

AssemblyBuilder クラス
アセンブリ: mscorlib (mscorlib.dll 内)

<ComVisibleAttribute(True)> _ <ClassInterfaceAttribute(ClassInterfaceType.None)> _ Public NotInheritable Class AssemblyBuilder Inherits Assembly Implements _AssemblyBuilder
[ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType.None)] public sealed class AssemblyBuilder : Assembly, _AssemblyBuilder
[ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType::None)] public ref class AssemblyBuilder sealed : public Assembly, _AssemblyBuilder

動的アセンブリは、Reflection Emit API を使用して作成されたアセンブリです。Save メソッドを使用して動的アセンブリが保存されるときに、動的モジュールがアセンブリに保存されます。実行可能ファイルを生成するには、SetEntryPoint メソッドを呼び出して、アセンブリへのエントリ ポイントであるメソッドを識別する必要があります。アセンブリは、既定ではダイナミック リンク ライブラリ (DLL) として保存されますが、SetEntryPoint を使用して、コンソール アプリケーションまたは Windows ベースのアプリケーションを生成するように要求できます。
動的アセンブリに複数の動的モジュールが含まれている場合、そのアセンブリのマニフェスト ファイル名は、DefineDynamicModule の最初の引数に指定されているモジュール名に一致する必要があります。
GetModules および GetLoadedModules などの基本クラス Assembly のメソッドの中には、AssemblyBuilder オブジェクトが呼び出されたときに正しく動作しないものがあります。定義された動的アセンブリを読み込み、読み込まれたアセンブリに対してメソッドを呼び出します。たとえば、返されたモジュール リストにリソース モジュールが含まれているようにするには、読み込まれた Assembly オブジェクトに対して GetModules を呼び出します。
KeyPair を使用した動的アセンブリへの署名は、アセンブリがディスクに保存されるまで有効ではありません。したがって、遷移動的アセンブリでは厳密な名前が機能しません。


System.Reflection.Assembly
System.Reflection.Emit.AssemblyBuilder


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


AssemblyBuilder クラス
アセンブリ: System.Web (system.web.dll 内)


1 つ以上のファイルをコンパイル済みのアセンブリにビルドするには、AssemblyBuilder クラスのインスタンスが BuildProvider クラスのメソッドと共に使用されます。
BuildProvider クラスはビルド機能をファイル別に定義します。AssemblyBuilder クラスは、各 BuildProvider インスタンスによって指定されたソース コードを 1 つのアセンブリに結合します。ASP.NET ビルド環境では、1 つ以上のファイルから 1 つのアセンブリを構築するときに、AssemblyBuilder オブジェクトが BuildProvider メソッドに渡されます。これにより、各 BuildProvider インスタンスは、アセンブリ全体に対してそれぞれのファイルのソース コードを指定できます。
ASP.NET ビルド環境では、プロジェクト内のファイルが必要とする言語とコンパイラは、BuildProvider.CodeCompilerType プロパティに基づいて判断されます。ASP.NET ビルド環境では、コンパイラ設定に基づいてファイルをグループ化し、同一のコンパイラを必要とするファイルからアセンブリをビルドします。
CodeDomProvider プロパティは、ASP.NET ビルド環境が各 BuildProvider 実装で指定されるソース コードをアセンブリにコンパイルするのに使用する CodeDomProvider 実装を示します。
BuildProvider オブジェクトは、AddCodeCompileUnit メソッドを使用して、CodeDOM グラフの形式でソース コードを指定します。BuildProvider オブジェクトは、CreateCodeFile メソッドを使用して、物理ファイル内に格納されたソース コードを指定します。
各 BuildProvider オブジェクトが適切な AssemblyBuilder メソッドを使用してソース コードを指定した後は、ASP.NET ビルド環境は、AssemblyBuilder クラスを使用して、収集済みのソース コードをアセンブリにコンパイルします。

簡単なビルド プロバイダを、抽象基本クラス BuildProvider から継承して実装するコード例を次に示します。ビルド プロバイダは、基本クラスのメンバである CodeCompilerType、GetGeneratedType、および GenerateCode をオーバーライドします。
GenerateCode メソッドの実装では、ビルド プロバイダは CreateCodeFile メソッドを使用して、アセンブリ コンパイル用の生成済みコードを追加します。
Imports Microsoft.VisualBasic Imports System Imports System.Collections Imports System.IO Imports System.Text Imports System.Web Imports System.Web.Compilation Imports System.CodeDom.Compiler Imports System.CodeDom Imports System.Security Imports System.Security.Permissions <PermissionSet(SecurityAction.Demand, Unrestricted := true)> _ Public Class SampleBuildProvider Inherits BuildProvider Protected _compilerType As CompilerType = Nothing Public Sub New() _compilerType = GetDefaultCompilerType() End Sub ' Return the internal CompilerType member ' defined in this implementation. Public Overrides ReadOnly Property CodeCompilerType() As CompilerType Get CodeCompilerType = _compilerType End Get End Property ' Define a method that returns details for the ' code compiler for this build provider. Public Function GetCompilerTypeDetails() As String Dim details As StringBuilder = New StringBuilder("") If Not _compilerType Is Nothing Then ' Format a string that contains the code compiler ' implementation, and various compiler details. details.AppendFormat("CodeDomProvider type: {0}; ", _ _compilerType.CodeDomProviderType.ToString()) details.AppendFormat("Compiler debug build = {0}; ", _ _compilerType.CompilerParameters.IncludeDebugInformation.ToString()) details.AppendFormat("Compiler warning level = {0}; ", _ _compilerType.CompilerParameters.WarningLevel.ToString()) If Not _compilerType.CompilerParameters.CompilerOptions Is Nothing Then details.AppendFormat("Compiler options: {0}; ", _ _compilerType.CompilerParameters.CompilerOptions.ToString()) End If End If Return details.ToString() End Function ' Define the build provider implementation of the GenerateCode method. Public Overrides Sub GenerateCode(ByVal assemBuilder As AssemblyBuilder) ' Generate a code compile unit, and add it to ' the assembly builder. Dim tw As TextWriter = assemBuilder.CreateCodeFile(Me) If Not tw Is Nothing Then Try ' Generate the code compile unit from the virtual path. Dim compileUnit As CodeCompileUnit = _ SampleClassGenerator.BuildCompileUnitFromPath(VirtualPath) ' Generate the source for the code compile unit, ' and write it to a file specified by the assembly builder. Dim provider As CodeDomProvider = assemBuilder.CodeDomProvider provider.CreateGenerator().GenerateCodeFromCompileUnit(compileUnit, tw, Nothing) Finally tw.Close() End Try End If End Sub Public Overrides Function GetGeneratedType(ByVal results As CompilerResults) As System.Type Dim typeName As String = SampleClassGenerator.TypeName Return results.CompiledAssembly.GetType(typeName) End Function End Class
using System; using System.Collections; using System.IO; using System.Text; using System.Web; using System.Web.Compilation; using System.CodeDom.Compiler; using System.CodeDom; using System.Security; using System.Security.Permissions; // Define a simple build provider implementation. [PermissionSet(SecurityAction.Demand, Unrestricted = true)] public class SampleBuildProvider : BuildProvider { // Define an internal member for the compiler type. protected CompilerType _compilerType = null; public SampleBuildProvider() { // Set the compiler to use Visual Basic. _compilerType = GetDefaultCompilerTypeForLanguage("C#"); } // Return the internal CompilerType member // defined in this implementation. public override CompilerType CodeCompilerType { get { return _compilerType; } } // Define a method that returns details for the // code compiler for this build provider. public string GetCompilerTypeDetails() { StringBuilder details = new StringBuilder(""); if (_compilerType != null) { // Format a string that contains the code compiler // implementation, and various compiler details. details.AppendFormat("CodeDomProvider type: {0}; \n", _compilerType.CodeDomProviderType.ToString()); details.AppendFormat("Compiler debug build = {0}; \n", _compilerType.CompilerParameters.IncludeDebugInformation.ToString()); details.AppendFormat("Compiler warning level = {0}; \n", _compilerType.CompilerParameters.WarningLevel.ToString()); if (_compilerType.CompilerParameters.CompilerOptions != null) { details.AppendFormat("Compiler options: {0}; \n", _compilerType.CompilerParameters.CompilerOptions.ToString()); } } return details.ToString(); } // Define the build provider implementation of the GenerateCode method. public override void GenerateCode(AssemblyBuilder assemBuilder) { // Generate a code compile unit, and add it to // the assembly builder. TextWriter tw = assemBuilder.CreateCodeFile(this); if (tw != null) { try { // Generate the code compile unit from the virtual path. CodeCompileUnit compileUnit = SampleClassGenerator.BuildCompileUnitFromPath(VirtualPath); // Generate the source for the code compile unit, // and write it to a file specified by the assembly builder. CodeDomProvider provider = assemBuilder.CodeDomProvider; provider.CreateGenerator().GenerateCodeFromCompileUnit(compileUnit, tw, null); } finally { tw.Close(); } } } public override System.Type GetGeneratedType(CompilerResults results) { string typeName = SampleClassGenerator.TypeName; return results.CompiledAssembly.GetType(typeName); } }

System.Web.Compilation.AssemblyBuilder


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


AssemblyBuilder プロパティ

名前 | 説明 | |
---|---|---|
![]() | CodeBase | オーバーライドされます。 アセンブリの場所を初めに指定されたとおりに取得します (AssemblyName オブジェクトなど)。 |
![]() | EntryPoint | オーバーライドされます。 このアセンブリのエントリ ポイントを返します。 |
![]() | EscapedCodeBase | コードベースを表す URI を、エスケープ文字も含めて取得します。 ( Assembly から継承されます。) |
![]() | Evidence | このアセンブリの証拠を取得します。 ( Assembly から継承されます。) |
![]() | FullName | アセンブリの表示名を取得します。 ( Assembly から継承されます。) |
![]() | GlobalAssemblyCache | アセンブリがグローバル アセンブリ キャッシュから読み込まれたかどうかを示す値を取得します。 ( Assembly から継承されます。) |
![]() | HostContext | アセンブリの読み込みに使用したホスト コンテキストを取得します。 ( Assembly から継承されます。) |
![]() | ImageRuntimeVersion | オーバーライドされます。 マニフェストを格納しているファイルに保存される共通言語ランタイムのバージョンを取得します。 |
![]() | Location | オーバーライドされます。 マニフェストを格納している読み込み済みファイルがシャドウ コピーされていない場合に、このファイルの場所をコードベース書式で取得します。 |
![]() | ManifestModule | 現在のアセンブリのマニフェストを格納しているモジュールを取得します。 ( Assembly から継承されます。) |
![]() | ReflectionOnly | オーバーライドされます。 その動的アセンブリが、リフレクションのみのコンテキストで使用されるかどうかを示す値を取得します。 |

AssemblyBuilder プロパティ
AssemblyBuilder メソッド


名前 | 説明 | |
---|---|---|
![]() | System.Runtime.InteropServices._AssemblyBuilder.GetIDsOfNames | 名前のセットを対応するディスパッチ識別子のセットに割り当てます。 |
![]() | System.Runtime.InteropServices._AssemblyBuilder.GetTypeInfo | オブジェクトの型情報を取得します。この型情報は、インターフェイスの型情報を取得するために使用できます。 |
![]() | System.Runtime.InteropServices._AssemblyBuilder.GetTypeInfoCount | オブジェクトが提供する型情報インターフェイスの数を取得します (0 または 1)。 |
![]() | System.Runtime.InteropServices._AssemblyBuilder.Invoke | オブジェクトによって公開されているプロパティおよびメソッドにアクセスできるようにします。 |

AssemblyBuilder メソッド

名前 | 説明 | |
---|---|---|
![]() | AddAssemblyReference | 1 つのファイルについて生成されたソース コードが参照するアセンブリを追加します。 |
![]() | AddCodeCompileUnit | アセンブリのソース コードを CodeDOM グラフの形式で追加します。 |
![]() | CreateCodeFile | ビルド プロバイダが一時的なソース ファイルを作成して、そのソース ファイルをアセンブリのコンパイルに含めることができるようにします。 |
![]() | CreateEmbeddedResource | ビルド プロバイダがリソース ファイルを作成して、そのファイルをアセンブリ コンパイルに含めることができるようにします。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GenerateTypeFactory | 型に対する高速オブジェクトのファクトリ テンプレートを、コンパイル対象アセンブリに挿入します。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetTempFilePhysicalPath | 一時ファイルのパスを生成します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

AssemblyBuilder メンバ
AssemblyBuilder データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | CodeBase | オーバーライドされます。 アセンブリの場所を初めに指定されたとおりに取得します (AssemblyName オブジェクトなど)。 |
![]() | EntryPoint | オーバーライドされます。 このアセンブリのエントリ ポイントを返します。 |
![]() | EscapedCodeBase | コードベースを表す URI を、エスケープ文字も含めて取得します。(Assembly から継承されます。) |
![]() | Evidence | このアセンブリの証拠を取得します。(Assembly から継承されます。) |
![]() | FullName | アセンブリの表示名を取得します。(Assembly から継承されます。) |
![]() | GlobalAssemblyCache | アセンブリがグローバル アセンブリ キャッシュから読み込まれたかどうかを示す値を取得します。(Assembly から継承されます。) |
![]() | HostContext | アセンブリの読み込みに使用したホスト コンテキストを取得します。(Assembly から継承されます。) |
![]() | ImageRuntimeVersion | オーバーライドされます。 マニフェストを格納しているファイルに保存される共通言語ランタイムのバージョンを取得します。 |
![]() | Location | オーバーライドされます。 マニフェストを格納している読み込み済みファイルがシャドウ コピーされていない場合に、このファイルの場所をコードベース書式で取得します。 |
![]() | ManifestModule | 現在のアセンブリのマニフェストを格納しているモジュールを取得します。 (Assembly から継承されます。) |
![]() | ReflectionOnly | オーバーライドされます。 その動的アセンブリが、リフレクションのみのコンテキストで使用されるかどうかを示す値を取得します。 |



名前 | 説明 | |
---|---|---|
![]() | System.Runtime.InteropServices._AssemblyBuilder.GetIDsOfNames | 名前のセットを対応するディスパッチ識別子のセットに割り当てます。 |
![]() | System.Runtime.InteropServices._AssemblyBuilder.GetTypeInfo | オブジェクトの型情報を取得します。この型情報は、インターフェイスの型情報を取得するために使用できます。 |
![]() | System.Runtime.InteropServices._AssemblyBuilder.GetTypeInfoCount | オブジェクトが提供する型情報インターフェイスの数を取得します (0 または 1)。 |
![]() | System.Runtime.InteropServices._AssemblyBuilder.Invoke | オブジェクトによって公開されているプロパティおよびメソッドにアクセスできるようにします。 |

AssemblyBuilder メンバ
ASP.NET プロジェクト内の 1 つ以上の仮想パスからアセンブリをビルドするためのコンテナを提供します。
AssemblyBuilder データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | AddAssemblyReference | 1 つのファイルについて生成されたソース コードが参照するアセンブリを追加します。 |
![]() | AddCodeCompileUnit | アセンブリのソース コードを CodeDOM グラフの形式で追加します。 |
![]() | CreateCodeFile | ビルド プロバイダが一時的なソース ファイルを作成して、そのソース ファイルをアセンブリのコンパイルに含めることができるようにします。 |
![]() | CreateEmbeddedResource | ビルド プロバイダがリソース ファイルを作成して、そのファイルをアセンブリ コンパイルに含めることができるようにします。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GenerateTypeFactory | 型に対する高速オブジェクトのファクトリ テンプレートを、コンパイル対象アセンブリに挿入します。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetTempFilePhysicalPath | 一時ファイルのパスを生成します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

_AssemblyBuilder インターフェイス
アセンブリ: mscorlib (mscorlib.dll 内)

<CLSCompliantAttribute(False)> _ <InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> _ <ComVisibleAttribute(True)> _ <GuidAttribute("BEBB2505-8B54-3443-AEAD-142A16DD9CC7")> _ Public Interface _AssemblyBuilder
[CLSCompliantAttribute(false)] [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] [ComVisibleAttribute(true)] [GuidAttribute("BEBB2505-8B54-3443-AEAD-142A16DD9CC7")] public interface _AssemblyBuilder
[CLSCompliantAttribute(false)] [InterfaceTypeAttribute(ComInterfaceType::InterfaceIsIUnknown)] [ComVisibleAttribute(true)] [GuidAttribute(L"BEBB2505-8B54-3443-AEAD-142A16DD9CC7")] public interface class _AssemblyBuilder


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


_AssemblyBuilder メソッド

名前 | 説明 | |
---|---|---|
![]() | GetIDsOfNames | 一連の名前を対応する一連のディスパッチ識別子に割り当てます。 |
![]() | GetTypeInfo | オブジェクトの型情報を取得します。その後は、インターフェイスの型情報の取得に使用できます。 |
![]() | GetTypeInfoCount | オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。 |
![]() | Invoke | オブジェクトが公開するプロパティおよびメソッドにアクセスできるようにします。 |

_AssemblyBuilder メンバ
System.Reflection.Emit.AssemblyBuilder クラスをアンマネージ コードに公開します。
_AssemblyBuilder データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | GetIDsOfNames | 一連の名前を対応する一連のディスパッチ識別子に割り当てます。 |
![]() | GetTypeInfo | オブジェクトの型情報を取得します。その後は、インターフェイスの型情報の取得に使用できます。 |
![]() | GetTypeInfoCount | オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。 |
![]() | Invoke | オブジェクトが公開するプロパティおよびメソッドにアクセスできるようにします。 |

- _AssemblyBuilderのページへのリンク