Type.Assembly プロパティ

定義

型が宣言される Assembly を取得します。 ジェネリック型の場合は、ジェネリック型が定義される Assembly を取得します。

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 namespace System;
using namespace System::Reflection;
int main()
{
   Type^ objType = System::Array::typeid;
   
   // Print the full assembly name.
   Console::WriteLine( "Full assembly name: {0}.", objType->Assembly->FullName );
   
   // Print the qualified assembly name.
   Console::WriteLine( "Qualified assembly name: {0}.", objType->AssemblyQualifiedName );
}
// The example displays the following output if run under the .NET Framework 4.5:
//    Full assembly name:
//       mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
//    Qualified assembly name:
//       System.Array, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
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 の オブジェクトが構築されたジェネリック型を表す場合、このプロパティはジェネリック型定義を含むアセンブリを返します。 たとえば、ジェネリック型定義 MyGenericStack<T> を含む MyGenerics.dll という名前のアセンブリを作成するとします (MyGenericStack(Of T) Visual Basic では C generic<T> ref class MyGenericStack ++ の場合)。 別のアセンブリで (MyGenericStack(Of Integer) Visual Basic では ) のMyGenericStack<int>インスタンスを作成すると、Assembly構築された型の プロパティは、MyGenerics.dllをAssembly表すオブジェクトを返します。

同様に、現在 Type の オブジェクトが未割り当てジェネリック パラメーター Tを表す場合、このプロパティは を定義するジェネリック型を含むアセンブリを返します T

プロパティが Type.Assembly .NET Core やユニバーサル Windows プラットフォームなどの特定の .NET 実装で使用できない場合は、代わりに プロパティをTypeInfo.Assembly使用します。

このプロパティは読み取り専用です。

適用対象