Type.Assembly Właściwość

Definicja

Pobiera typ Assembly , w którym jest zadeklarowany. W przypadku typów ogólnych pobiera typ Assembly ogólny, w którym zdefiniowano typ ogólny.

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

Wartość właściwości

Wystąpienie Assembly opisujące zestaw zawierający bieżący typ. W przypadku typów ogólnych wystąpienie opisuje zestaw, który zawiera definicję typu ogólnego, a nie zestaw, który tworzy i używa określonego typu konstrukcji.

Implementuje

Przykłady

W poniższym przykładzie wyświetlana jest nazwa zestawu skojarzona z klasą i w pełni kwalifikowana nazwa typu.

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.

Uwagi

Jeśli bieżący Type obiekt reprezentuje skonstruowany typ ogólny, ta właściwość zwraca zestaw zawierający definicję typu ogólnego. Załóżmy na przykład, że tworzysz zestaw o nazwie MyGenerics.dll zawierający definicję MyGenericStack<T> typu ogólnego (MyGenericStack(Of T) w języku Visual Basic generic<T> ref class MyGenericStack w języku C++). Jeśli tworzysz wystąpienie MyGenericStack<int> klasy (MyGenericStack(Of Integer) w języku Visual Basic) w innym zestawie, Assembly właściwość typu konstruowanego zwraca Assembly obiekt reprezentujący MyGenerics.dll.

Podobnie, jeśli bieżący Type obiekt reprezentuje nieprzypisany parametr Togólny , ta właściwość zwraca zestaw zawierający typ ogólny, który definiuje T.

Type.Assembly Jeśli właściwość nie jest dostępna w określonej implementacji platformy .NET, takiej jak .NET Core lub platforma uniwersalna systemu Windows, użyj TypeInfo.Assembly właściwości .

Ta właściwość jest tylko do odczytu.

Dotyczy