Share via


Type.Assembly 属性

获取在其中声明该类型 Assembly。对于泛型类型,则获取在其中定义该泛型类型的 Assembly

**命名空间:**System
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
Public MustOverride ReadOnly Property Assembly As Assembly
用法
Dim instance As Type
Dim value As Assembly

value = instance.Assembly
public abstract Assembly Assembly { get; }
public:
virtual property Assembly^ Assembly {
    Assembly^ get () abstract;
}
/** @property */
public abstract Assembly get_Assembly ()
public abstract function get Assembly () : Assembly

属性值

描述包含当前类型的程序集的 Assembly 实例。对于泛型类型,该实例描述包含泛型类型定义的程序集,而不是创建和使用特定构造类型的程序集。

备注

如果当前 Type 对象表示构造泛型类型,则该属性返回包含泛型类型定义的程序集。例如,假设您创建了一个名为 MyGenerics.dll 的程序集,该程序集包含泛型类型定义 MyGenericStack<T>(在 Visual Basic 中为 MyGenericStack(Of T),在 C++ 中为 generic<T> ref class MyGenericStack)。如果您在另一个程序集中创建了 MyGenericStack<int>(在 Visual Basic 中为 MyGenericStack(Of Integer))的实例,则该构造类型的 Assembly 属性返回表示 MyGenerics.dll 的 Assembly 对象。

类似地,如果当前 Type 对象表示未分配的泛型参数 T,则此属性返回包含定义 T 的泛型类型的程序集。

此属性为只读。

示例

下面的示例显示与类关联的程序集名和类型的完全限定名。

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic
Class MyAssemblyClass
    Public Shared Sub Main()
        Dim objType As Type = GetType(System.Array)
        ' Print the full assembly name.
        Console.WriteLine("Full assembly name: {0}.", objType.Assembly.FullName.ToString())
        ' Print the qualified assembly name.
        Console.WriteLine("Qualified assembly name: {0}.", objType.AssemblyQualifiedName.ToString())
    End Sub 'Main
End Class 'MyAssemblyClass
using System;
using System.Reflection;

class MyAssemblyClass
{

    public static void Main()
    {
        Type objType = typeof(System.Array);
                    
        // Print the full assembly name.
        Console.WriteLine ("Full assembly name: {0}.", objType.Assembly.FullName.ToString()); 

        // Print the qualified assembly name.
        Console.WriteLine ("Qualified assembly name: {0}.", objType.AssemblyQualifiedName.ToString()); 
    }
}
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 );
}
import System.*;
import System.Reflection.*;

class MyAssemblyClass
{
    public static void main(String[] args)
    {
        Type objType = System.Array.class.ToType();
        // Print the full assembly name.
        Console.WriteLine("Full assembly name: {0}.",
            objType.get_Assembly().get_FullName().ToString());
        // Print the qualified assembly name.
        Console.WriteLine("Qualified assembly name: {0}.",
            objType.get_AssemblyQualifiedName().ToString());
    } //main
} //MyAssemblyClass

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

Type 类
Type 成员
System 命名空间