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 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 对象表示构造的泛型类型,则此属性返回包含泛型类型定义的程序集。 例如,假设你创建一个名为 MyGenerics.dll 的程序集,其中包含 Visual Basic 中的泛型类型定义 MyGenericStack<T>
(MyGenericStack(Of T)
C generic<T> ref class MyGenericStack
++) 。 如果在另一个程序集的 Visual Basic) 中创建 (MyGenericStack(Of Integer)
实例MyGenericStack<int>
,Assembly则构造类型的 属性将返回一个Assembly表示MyGenerics.dll的对象。
同样,如果当前 Type 对象表示未分配的泛型参数 T
,则此属性返回包含定义 T
的泛型类型的程序集。
Type.Assembly如果 属性在特定 .NET 实现(如 .NET Core 或 通用 Windows 平台)上不可用,请改用 TypeInfo.Assembly 属性。
此属性为只读。