Type.Assembly プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
public:
abstract property System::Reflection::Assembly ^ Assembly { System::Reflection::Assembly ^ get(); };
public abstract System.Reflection.Assembly Assembly { get; }
member this.Assembly : System.Reflection.Assembly
Public MustOverride ReadOnly Property Assembly As Assembly
プロパティ値
現在の型を含むアセンブリを記述する Assembly インスタンス。 ジェネリック型の場合、インスタンスは、特定の構築された型を作成して使用するアセンブリではなく、ジェネリック型定義を含むアセンブリを記述します。
実装
例
次の例では、クラスに関連付けられているアセンブリ名と、型の完全修飾名を表示します。
using System;
class MyAssemblyClass
{
public static void Main()
{
Type objType = typeof(Array);
// Print the assembly full name.
Console.WriteLine($"Assembly full name:\n {objType.Assembly.FullName}.");
// Print the assembly qualified name.
Console.WriteLine($"Assembly qualified name:\n {objType.AssemblyQualifiedName}.");
}
}
// The example displays the following output if run under the .NET Framework 4.5:
// Assembly full name:
// mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
// Assembly qualified name:
// System.Array, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
open System
let objType = typeof<Array>
// Print the assembly full name.
printfn $"Assembly full name:\n {objType.Assembly.FullName}."
// Print the assembly qualified name.
printfn $"Assembly qualified name:\n {objType.AssemblyQualifiedName}."
// The example displays the following output if run under the .NET Framework 4.5:
// Assembly full name:
// mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
// Assembly qualified name:
// System.Array, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
Class Example
Public Shared Sub Main()
Dim objType As Type = GetType(Array)
' Display the assembly full name.
Console.WriteLine($"Assembly full name:{vbCrLf} {objType.Assembly.FullName}.")
' Display the assembly qualified name.
Console.WriteLine($"Assembly qualified name:{vbCrLf} {objType.AssemblyQualifiedName}.")
End Sub
End Class
' The example displays the following output if run under the .NET Framework 4.5:
' Assembly full name:
' mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
' Assembly qualified name:
' System.Array, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
注釈
現在の Type オブジェクトが構築されたジェネリック型を表す場合、このプロパティはジェネリック型定義を含むアセンブリを返します。 たとえば、(Visual Basic でMyGenericStack(Of T)) ジェネリック型定義MyGenericStack<T>を含む MyGenerics.dll という名前のアセンブリを作成するとします。 別のアセンブリに MyGenericStack<int> (Visual Basic でMyGenericStack(Of Integer) ) のインスタンスを作成すると、構築された型の Assembly プロパティは、MyGenerics.dllを表す Assembly オブジェクトを返します。
同様に、現在の Type オブジェクトが割り当てられていないジェネリック パラメーター Tを表す場合、このプロパティは、 Tを定義するジェネリック型を含むアセンブリを返します。
.NET Core やユニバーサル Windows プラットフォームなど、特定の .NET 実装で Type.Assembly プロパティを使用できない場合は、代わりに TypeInfo.Assembly プロパティを使用します。
このプロパティは読み取り専用です。