Export (0) Print
Expand All

Assembly::GetAssembly Method

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

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

static Assembly^ GetAssembly(
	Type^ type


Type: System::Type

An object representing a class in the assembly that will be returned.

Return Value

Type: System.Reflection::Assembly
The assembly in which the specified class is defined.


type is nullptr.

In order to call this method, you must have a Type object, which means that the assembly in which the class is defined must already be loaded.

The following example retrieves the assembly of a specified class.

using namespace System;
using namespace System::Reflection;

void main()
   // Instantiate a target object. 
   int integer1 = 1632;
   // Instantiate an Assembly class to the assembly housing the Integer type.
   Assembly^ systemAssembly = integer1.GetType()->Assembly;
   // Get the location of the assembly using the file: protocol.
   Console::WriteLine("CodeBase = {0}", systemAssembly->CodeBase);
// The example displays output like the following: 
//   CodeBase = file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft