Type.Assembly Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the Assembly in which the type is declared. For generic types, gets the Assembly in which the generic type is defined.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

Public MustOverride ReadOnly Property Assembly As Assembly
public abstract Assembly Assembly { get; }

Property Value

Type: System.Reflection..::.Assembly
An Assembly instance that describes the assembly containing the current type. For generic types, the instance describes the assembly that contains the generic type definition, not the assembly that creates and uses a particular constructed type.

Remarks

If the current Type object represents a constructed generic type, this property returns the assembly that contains the generic type definition. For example, suppose you create an assembly named MyGenerics.dll that contains the generic type definition MyGenericStack<T> (MyGenericStack(Of T) in Visual Basic, generic<T> ref class MyGenericStack in C++). If you create an instance of MyGenericStack<int> (MyGenericStack(Of Integer) in Visual Basic) in another assembly, the Assembly property for the constructed type returns an Assembly object that represents MyGenerics.dll.

Similarly, if the current Type object represents an unassigned generic parameter T, this property returns the assembly that contains the generic type that defines T.

This property is read-only.

Examples

The following example displays the assembly name associated with the class and the fully qualified name of the type.

Imports System.Reflection
Class Example
    Public Shared Sub Demo(outputBlock As System.Windows.Controls.TextBlock)
        Dim objType As Type = GetType(System.Array)
        ' Print the full assembly name.
        outputBlock.Text += String.Format("Full assembly name: {0}.", objType.Assembly.FullName.ToString()) + Environment.NewLine
        ' Print the qualified assembly name.
        outputBlock.Text += String.Format("Qualified assembly name: {0}.", objType.AssemblyQualifiedName.ToString()) + Environment.NewLine
    End Sub 'Main
End Class 'MyAssemblyClass
using System;
using System.Reflection;

class Example
{

    public static void Demo(System.Windows.Controls.TextBlock outputBlock)
    {
        Type objType = typeof(System.Array);

        // Print the full assembly name.
        outputBlock.Text += String.Format("Full assembly name: {0}.", objType.Assembly.FullName.ToString()) + Environment.NewLine; 

        // Print the qualified assembly name.
        outputBlock.Text += String.Format("Qualified assembly name: {0}.", objType.AssemblyQualifiedName.ToString()) + Environment.NewLine; 
    }
}

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Platforms

Windows Phone

See Also

Reference

Type Class

System Namespace