次の方法で共有


Assembly.GetAssembly メソッド

指定されたクラスが定義されているアセンブリを取得します。

Public Shared Function GetAssembly( _
   ByVal type As Type _) As Assembly
[C#]
public static Assembly GetAssembly(Typetype);
[C++]
public: static Assembly* GetAssembly(Type* type);
[JScript]
public static function GetAssembly(
   type : Type) : Assembly;

パラメータ

  • type
    返されるアセンブリ内のクラスを表す Type オブジェクト。

戻り値

指定されたクラスが定義されているアセンブリ。

例外

例外の種類 条件
ArgumentNullException type が null 参照 (Visual Basic では Nothing) です。

使用例

指定したクラスのアセンブリを取得する例を次に示します。

 
Dim SampleAssembly As [Assembly]
' Instantiate a target object.
Dim Integer1 As New Int32()
Dim Type1 As Type
' Set the Type instance to the target class type.
Type1 = Integer1.GetType()
' Instantiate an Assembly class to the assembly housing the Integer type.  
SampleAssembly = [Assembly].GetAssembly(Integer1.GetType())
' Gets the location of the assembly using file: protocol.
Console.WriteLine(("CodeBase=" + SampleAssembly.CodeBase))
        End Sub 'Snippet1

[C#] 
Assembly SampleAssembly;
// Instantiate a target object.
Int32 Integer1 = new Int32();
Type Type1;
// Set the Type instance to the target class type.
Type1 = Integer1.GetType();
// Instantiate an Assembly class to the assembly housing the Integer type.  
SampleAssembly = Assembly.GetAssembly(Integer1.GetType());
// Gets the location of the assembly using file: protocol.
Console.WriteLine("CodeBase=" + SampleAssembly.CodeBase);

[C++] 
Assembly* SampleAssembly;
// Instantiate a target object.
Int32 Integer1(0);
Type* Type1;
// Set the Type instance to the target class type.
Type1 = __box(Integer1)->GetType();
// Instantiate an Assembly class to the assembly housing the Integer type.  
SampleAssembly = Assembly::GetAssembly(__box(Integer1)->GetType());
// Gets the location of the assembly using file: protocol.
Console::WriteLine(S"CodeBase= {0}", SampleAssembly->CodeBase);

[JScript] 
var SampleAssembly : Assembly;
// Instantiate a target object.
var Integer1 : Int32 = 0;
var Type1 : Type;
// Set the Type instance to the target class type.
Type1 = Integer1.GetType();
// Instantiate an Assembly class to the assembly housing the Integer type.  
SampleAssembly = Assembly.GetAssembly(Integer1.GetType());
// Gets the location of the assembly using file: protocol.
Console.WriteLine("CodeBase=" + SampleAssembly.CodeBase);

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

Assembly クラス | Assembly メンバ | System.Reflection 名前空間