Assembly Class
 

Represents an assembly, which is a reusable, versionable, and self-describing building block of a common language runtime application.

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


[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType.None)]
[ComVisibleAttribute(true)]
[PermissionSetAttribute(SecurityAction.InheritanceDemand, Unrestricted = true)]
public abstract class Assembly : _Assembly, IEvidenceFactory, 
	ICustomAttributeProvider, ISerializable
[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType::None)]
[ComVisibleAttribute(true)]
[PermissionSetAttribute(SecurityAction::InheritanceDemand, Unrestricted = true)]
public ref class Assembly abstract : _Assembly, IEvidenceFactory, 
	ICustomAttributeProvider, ISerializable
[<AbstractClass>]
[<SerializableAttribute>]
[<ClassInterfaceAttribute(ClassInterfaceType.None)>]
[<ComVisibleAttribute(true)>]
[<PermissionSetAttribute(SecurityAction.InheritanceDemand, Unrestricted = true)>]
type Assembly = 
    class
        interface _Assembly
        interface IEvidenceFactory
        interface ICustomAttributeProvider
        interface ISerializable
    end
<SerializableAttribute>
<ClassInterfaceAttribute(ClassInterfaceType.None)>
<ComVisibleAttribute(True)>
<PermissionSetAttribute(SecurityAction.InheritanceDemand, Unrestricted := True)>
Public MustInherit Class Assembly
	Implements _Assembly, IEvidenceFactory, ICustomAttributeProvider,
	ISerializable
NameDescription
System_CAPS_protmethod Assembly

Initializes a new instance of the Assembly class.

NameDescription
System_CAPS_pubproperty

Gets the location of the assembly as specified originally, for example, in an AssemblyName object.

System_CAPS_pubproperty

Gets a collection that contains this assembly's custom attributes.

System_CAPS_pubproperty

Gets a collection of the types defined in this assembly.

System_CAPS_pubproperty

Gets the entry point of this assembly.

System_CAPS_pubproperty

Gets the URI, including escape characters, that represents the codebase.

System_CAPS_pubproperty

Gets the evidence for this assembly.

System_CAPS_pubproperty

Gets a collection of the public types defined in this assembly that are visible outside the assembly.

System_CAPS_pubproperty

Gets the display name of the assembly.

System_CAPS_pubproperty

Gets a value indicating whether the assembly was loaded from the global assembly cache.

System_CAPS_pubproperty

Gets the host context with which the assembly was loaded.

System_CAPS_pubproperty

Gets a string representing the version of the common language runtime (CLR) saved in the file containing the manifest.

System_CAPS_pubproperty

Gets a value that indicates whether the current assembly was generated dynamically in the current process by using reflection emit.

System_CAPS_pubproperty

Gets a value that indicates whether the current assembly is loaded with full trust.

System_CAPS_pubproperty

Gets the full path or UNC location of the loaded file that contains the manifest.

System_CAPS_pubproperty

Gets the module that contains the manifest for the current assembly.

System_CAPS_pubproperty

Gets a collection that contains the modules in this assembly.

System_CAPS_pubproperty

Gets the grant set of the current assembly.

System_CAPS_pubproperty

Gets a Boolean value indicating whether this assembly was loaded into the reflection-only context.

System_CAPS_pubproperty

Gets a value that indicates which set of security rules the common language runtime (CLR) enforces for this assembly.

NameDescription
System_CAPS_pubmethod CreateInstance

Locates the specified type from this assembly and creates an instance of it using the system activator, using case-sensitive search.

System_CAPS_pubmethod CreateInstance

Locates the specified type from this assembly and creates an instance of it using the system activator, with optional case-sensitive search.

System_CAPS_pubmethod CreateInstance

Locates the specified type from this assembly and creates an instance of it using the system activator, with optional case-sensitive search and having the specified culture, arguments, and binding and activation attributes.

System_CAPS_pubmethod System_CAPS_static CreateQualifiedName

Creates the name of a type qualified by the display name of its assembly.

System_CAPS_pubmethod Equals

Determines whether this assembly and the specified object are equal.(Overrides ObjectEquals.)

System_CAPS_protmethod Finalize

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethod System_CAPS_static GetAssembly

Gets the currently loaded assembly in which the specified type is defined.

System_CAPS_pubmethod System_CAPS_static GetCallingAssembly

Returns the Assembly of the method that invoked the currently executing method.

System_CAPS_pubmethod GetCustomAttributes

Gets all the custom attributes for this assembly.

System_CAPS_pubmethod GetCustomAttributes

Gets the custom attributes for this assembly as specified by type.

System_CAPS_pubmethod GetCustomAttributesData

Returns information about the attributes that have been applied to the current Assembly, expressed as CustomAttributeData objects.

System_CAPS_pubmethod System_CAPS_static GetEntryAssembly

Gets the process executable in the default application domain. In other application domains, this is the first executable that was executed by AppDomainExecuteAssembly.

System_CAPS_pubmethod System_CAPS_static GetExecutingAssembly

Gets the assembly that contains the code that is currently executing.

System_CAPS_pubmethod GetExportedTypes

Gets the public types defined in this assembly that are visible outside the assembly.

System_CAPS_pubmethod GetFile

Gets a FileStream for the specified file in the file table of the manifest of this assembly.

System_CAPS_pubmethod GetFiles

Gets the files in the file table of an assembly manifest.

System_CAPS_pubmethod GetFiles

Gets the files in the file table of an assembly manifest, specifying whether to include resource modules.

System_CAPS_pubmethod GetHashCode

Returns the hash code for this instance.(Overrides ObjectGetHashCode.)

System_CAPS_pubmethod GetLoadedModules

Gets all the loaded modules that are part of this assembly.

System_CAPS_pubmethod GetLoadedModules

Gets all the loaded modules that are part of this assembly, specifying whether to include resource modules.

System_CAPS_pubmethod GetManifestResourceInfo

Returns information about how the given resource has been persisted.

System_CAPS_pubmethod GetManifestResourceNames

Returns the names of all the resources in this assembly.

System_CAPS_pubmethod GetManifestResourceStream

Loads the specified manifest resource from this assembly.

System_CAPS_pubmethod GetManifestResourceStream

Loads the specified manifest resource, scoped by the namespace of the specified type, from this assembly.

System_CAPS_pubmethod GetModule

Gets the specified module in this assembly.

System_CAPS_pubmethod GetModules

Gets all the modules that are part of this assembly.

System_CAPS_pubmethod GetModules

Gets all the modules that are part of this assembly, specifying whether to include resource modules.

System_CAPS_pubmethod GetName

Gets an AssemblyName for this assembly.

System_CAPS_pubmethod GetName

Gets an AssemblyName for this assembly, setting the codebase as specified by copiedName.

System_CAPS_pubmethod GetObjectData

Gets serialization information with all of the data needed to reinstantiate this assembly.

System_CAPS_pubmethod GetReferencedAssemblies

Gets the AssemblyName objects for all the assemblies referenced by this assembly.

System_CAPS_pubmethod GetSatelliteAssembly

Gets the satellite assembly for the specified culture.

System_CAPS_pubmethod GetSatelliteAssembly

Gets the specified version of the satellite assembly for the specified culture.

System_CAPS_pubmethod GetType

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethod GetType

Gets the Type object with the specified name in the assembly instance.

System_CAPS_pubmethod GetType

Gets the Type object with the specified name in the assembly instance and optionally throws an exception if the type is not found.

System_CAPS_pubmethod GetType

Gets the Type object with the specified name in the assembly instance, with the options of ignoring the case, and of throwing an exception if the type is not found.

System_CAPS_pubmethod GetTypes

Gets the types defined in this assembly.

System_CAPS_pubmethod IsDefined

Indicates whether or not a specified attribute has been applied to the assembly.

System_CAPS_pubmethod System_CAPS_static Load

Loads an assembly given its AssemblyName.

System_CAPS_pubmethod System_CAPS_static Load

Obsolete. Loads an assembly given its AssemblyName. The assembly is loaded into the domain of the caller using the supplied evidence.

System_CAPS_pubmethod System_CAPS_static Load

Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly. The assembly is loaded into the application domain of the caller.

System_CAPS_pubmethod System_CAPS_static Load

Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly, optionally including symbols for the assembly. The assembly is loaded into the application domain of the caller.

System_CAPS_pubmethod System_CAPS_static Load

Obsolete. Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly, optionally including symbols and evidence for the assembly. The assembly is loaded into the application domain of the caller.

System_CAPS_pubmethod System_CAPS_static Load

Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly, optionally including symbols and specifying the source for the security context. The assembly is loaded into the application domain of the caller.

System_CAPS_pubmethod System_CAPS_static Load

Loads an assembly given the long form of its name.

System_CAPS_pubmethod System_CAPS_static Load

Obsolete. Loads an assembly given its display name, loading the assembly into the domain of the caller using the supplied evidence.

System_CAPS_pubmethod System_CAPS_static LoadFile

Loads the contents of an assembly file on the specified path.

System_CAPS_pubmethod System_CAPS_static LoadFile

Obsolete. Loads an assembly given its path, loading the assembly into the domain of the caller using the supplied evidence.

System_CAPS_pubmethod System_CAPS_static LoadFrom

Loads an assembly given its file name or path.

System_CAPS_pubmethod System_CAPS_static LoadFrom

Loads an assembly given its file name or path, hash value, and hash algorithm.

System_CAPS_pubmethod System_CAPS_static LoadFrom

Obsolete. Loads an assembly given its file name or path and supplying security evidence.

System_CAPS_pubmethod System_CAPS_static LoadFrom

Obsolete. Loads an assembly given its file name or path, security evidence, hash value, and hash algorithm.

System_CAPS_pubmethod LoadModule

Loads the module, internal to this assembly, with a common object file format (COFF)-based image containing an emitted module, or a resource file.

System_CAPS_pubmethod LoadModule

Loads the module, internal to this assembly, with a common object file format (COFF)-based image containing an emitted module, or a resource file. The raw bytes representing the symbols for the module are also loaded.

System_CAPS_pubmethod System_CAPS_static LoadWithPartialName

Obsolete. Loads an assembly from the application directory or from the global assembly cache using a partial name.

System_CAPS_pubmethod System_CAPS_static LoadWithPartialName

Obsolete. Loads an assembly from the application directory or from the global assembly cache using a partial name. The assembly is loaded into the domain of the caller using the supplied evidence.

System_CAPS_protmethod MemberwiseClone

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethod System_CAPS_static ReflectionOnlyLoad

Loads the assembly from a common object file format (COFF)-based image containing an emitted assembly. The assembly is loaded into the reflection-only context of the caller's application domain.

System_CAPS_pubmethod System_CAPS_static ReflectionOnlyLoad

Loads an assembly into the reflection-only context, given its display name.

System_CAPS_pubmethod System_CAPS_static ReflectionOnlyLoadFrom

Loads an assembly into the reflection-only context, given its path.

System_CAPS_pubmethod ToString

Returns the full name of the assembly, also known as the display name.(Overrides ObjectToString.)

System_CAPS_pubmethod System_CAPS_static UnsafeLoadFrom

Loads an assembly into the load-from context, bypassing some security checks.

NameDescription
System_CAPS_pubevent ModuleResolve

Occurs when the common language runtime class loader cannot resolve a reference to an internal module of an assembly through normal means.

NameDescription
System_CAPS_puboperator System_CAPS_static Equality

Indicates whether two Assembly objects are equal.

System_CAPS_puboperator System_CAPS_static Inequality

Indicates whether two Assembly objects are not equal.

NameDescription
System_CAPS_pubinterface System_CAPS_privmethod _AssemblyGetType

Returns the type of the current instance.

NameDescription
System_CAPS_pubmethod GetCustomAttribute

Overloaded. Retrieves a custom attribute of a specified type that is applied to a specified assembly.(Defined by CustomAttributeExtensions.)

System_CAPS_pubmethod GetCustomAttribute

Overloaded. Retrieves a custom attribute of a specified type that is applied to a specified assembly.(Defined by CustomAttributeExtensions.)

System_CAPS_pubmethod GetCustomAttributes

Overloaded. Retrieves a collection of custom attributes that are applied to a specified assembly.(Defined by CustomAttributeExtensions.)

System_CAPS_pubmethod GetCustomAttributes

Overloaded. Retrieves a collection of custom attributes of a specified type that are applied to a specified assembly.(Defined by CustomAttributeExtensions.)

System_CAPS_pubmethod IsDefined

Overloaded. Indicates whether custom attributes of a specified type are applied to a specified assembly.(Defined by CustomAttributeExtensions.)

Use the Assembly class to load assemblies, to explore the metadata and constituent parts of assemblies, to discover the types contained in assemblies, and to create instances of those types.

To get an array of Assembly objects representing the assemblies currently loaded into an application domain (for example, the default application domain of a simple project), use the AppDomainGetAssemblies method.

To load assemblies dynamically, the Assembly class provides the following static methods (Shared methods in Visual Basic). Assemblies are loaded into the application domain where the load operation occurs.

  • The recommended way to load assemblies is to use the Load method, which identifies the assembly to be loaded by its display name (for example, "System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"). The search for the assembly follows the rules described in How the Runtime Locates Assemblies.

  • The ReflectionOnlyLoad and ReflectionOnlyLoadFrom methods enable you to load an assembly for reflection, but not for execution. For example, an assembly that targets a 64-bit platform can be examined by code that is running on a 32-bit platform.

  • The LoadFile and LoadFrom methods are provided for rare scenarios in which an assembly must be identified by path.

To get an Assembly object for the currently executing assembly, use the GetExecutingAssembly method.

Many members of the Assembly class provide information about an assembly. For example:

The GetTypes method lists all the types in the assembly. The GetExportedTypes method lists the types that are visible to callers outside the assembly. The GetType method can be used to search for a particular type in the assembly. The CreateInstance method can be used to search for and create instances of types in the assembly.

For more information on assemblies, see the "Application Domains and Assemblies" section in the Application Domains topic.

The following code example shows how to obtain the currently executing assembly, create an instance of a type contained in that assembly, and invoke one of the type's methods with late binding. For this purpose, the code example defines a class named Example, with a method named SampleMethod. The constructor of the class accepts an integer, which is used to compute the return value of the method.

The code example also demonstrates the use of the GetName method to obtain an AssemblyName object that can be used to parse the full name of the assembly. The example displays the version number of the assembly, the property, and the property.

using System;
using System.Reflection;
using System.Security.Permissions;

[assembly:AssemblyVersionAttribute("1.0.2000.0")]

public class Example
{
    private int factor;
    public Example(int f)
    {
        factor = f;
    }

    public int SampleMethod(int x) 
    { 
        Console.WriteLine("\nExample.SampleMethod({0}) executes.", x);
        return x * factor;
    }

    public static void Main()
    {
        Assembly assem = typeof(Example).Assembly;

        Console.WriteLine("Assembly Full Name:");
        Console.WriteLine(assem.FullName);

        // The AssemblyName type can be used to parse the full name.
        AssemblyName assemName = assem.GetName();
        Console.WriteLine("\nName: {0}", assemName.Name);
        Console.WriteLine("Version: {0}.{1}", 
            assemName.Version.Major, assemName.Version.Minor);

        Console.WriteLine("\nAssembly CodeBase:");
        Console.WriteLine(assem.CodeBase);

        // Create an object from the assembly, passing in the correct number
        // and type of arguments for the constructor.
        Object o = assem.CreateInstance("Example", false, 
            BindingFlags.ExactBinding, 
            null, new Object[] { 2 }, null, null);

        // Make a late-bound call to an instance method of the object.    
        MethodInfo m = assem.GetType("Example").GetMethod("SampleMethod");
        Object ret = m.Invoke(o, new Object[] { 42 });
        Console.WriteLine("SampleMethod returned {0}.", ret);

        Console.WriteLine("\nAssembly entry point:");
        Console.WriteLine(assem.EntryPoint);
    }
}

/* This code example produces output similar to the following:

Assembly Full Name:
source, Version=1.0.2000.0, Culture=neutral, PublicKeyToken=null

Name: source
Version: 1.0

Assembly CodeBase:
file:///C:/sdtree/AssemblyClass/cs/source.exe

Example.SampleMethod(42) executes.
SampleMethod returned 84.

Assembly entry point:
Void Main()
 */
Imports System
Imports System.Reflection
Imports System.Security.Permissions

<assembly: AssemblyVersionAttribute("1.0.2000.0")>

Public Class Example
    Private factor As Integer

    Public Sub New(ByVal f As Integer) 
        factor = f
    End Sub 

    Public Function SampleMethod(ByVal x As Integer) As Integer 
        Console.WriteLine(vbCrLf & "Example.SampleMethod({0}) executes.", x)
        Return x * factor
    End Function 

    Public Shared Sub Main() 
        Dim assem As Assembly = GetType(Example).Assembly

        Console.WriteLine("Assembly Full Name:")
        Console.WriteLine(assem.FullName)

        ' The AssemblyName type can be used to parse the full name.
        Dim assemName As AssemblyName = assem.GetName()
        Console.WriteLine(vbLf + "Name: {0}", assemName.Name)
        Console.WriteLine("Version: {0}.{1}", assemName.Version.Major, _
            assemName.Version.Minor)

        Console.WriteLine(vbLf + "Assembly CodeBase:")
        Console.WriteLine(assem.CodeBase)

        ' Create an object from the assembly, passing in the correct number
        ' and type of arguments for the constructor.
        Dim o As Object = assem.CreateInstance("Example", False, _
            BindingFlags.ExactBinding, Nothing, _
            New Object() { 2 }, Nothing, Nothing)

        ' Make a late-bound call to an instance method of the object.    
        Dim m As MethodInfo = assem.GetType("Example").GetMethod("SampleMethod")
        Dim ret As Object = m.Invoke(o, New Object() { 42 })
        Console.WriteLine("SampleMethod returned {0}.", ret)

        Console.WriteLine(vbCrLf & "Assembly entry point:")
        Console.WriteLine(assem.EntryPoint)

    End Sub 
End Class 

' This code example produces output similar to the following:
'
'Assembly Full Name:
'source, Version=1.0.2000.0, Culture=neutral, PublicKeyToken=null
'
'Name: source
'Version: 1.0
'
'Assembly CodeBase:
'file:///C:/sdtree/AssemblyClass/vb/source.exe
'
'Example.SampleMethod(42) executes.
'SampleMethod returned 84.
'
'Assembly entry point:
'Void Main()
' 
using namespace System;
using namespace System::Reflection;
using namespace System::Security::Permissions;

[assembly:AssemblyVersionAttribute("1.0.2000.0")];

public ref class Example
{
private: 
    int factor;

public:
    Example(int f)
    {
        factor = f;
    }

    int SampleMethod(int x) 
    { 
        Console::WriteLine("\nExample->SampleMethod({0}) executes.", x);
        return x * factor;
    }
};

void main()
{
    Assembly^ assem = Example::typeid->Assembly;

    Console::WriteLine("Assembly Full Name:");
    Console::WriteLine(assem->FullName);

    // The AssemblyName type can be used to parse the full name.
    AssemblyName^ assemName = assem->GetName();
    Console::WriteLine("\nName: {0}", assemName->Name);
    Console::WriteLine("Version: {0}.{1}", 
        assemName->Version->Major, assemName->Version->Minor);

    Console::WriteLine("\nAssembly CodeBase:");
    Console::WriteLine(assem->CodeBase);

    // Create an object from the assembly, passing in the correct number and
    // type of arguments for the constructor.
    Object^ o = assem->CreateInstance("Example", false, 
        BindingFlags::ExactBinding, 
        nullptr, gcnew array<Object^> { 2 }, nullptr, nullptr);

    // Make a late-bound call to an instance method of the object.    
    MethodInfo^ m = assem->GetType("Example")->GetMethod("SampleMethod");
    Object^ ret = m->Invoke(o, gcnew array<Object^> { 42 });
    Console::WriteLine("SampleMethod returned {0}.", ret);

    Console::WriteLine("\nAssembly entry point:");
    Console::WriteLine(assem->EntryPoint);
}

/* This code example produces output similar to the following:

Assembly Full Name:
source, Version=1.0.2000.0, Culture=neutral, PublicKeyToken=null

Name: source
Version: 1.0

Assembly CodeBase:
file:///C:/sdtree/AssemblyClass/cpp/source.exe

Example->SampleMethod(42) executes.
SampleMethod returned 84.

Assembly entry point:
UInt32 _mainCRTStartup()
 */
SecurityActionInheritanceDemand

for full trust for inheritors. This class cannot be inherited by partially trusted code.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1

This type is thread safe.

Return to top