Assembly.GetAssembly Method
.NET Framework 3.0
Gets the currently loaded assembly in which the specified class is defined.
Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Assembly: mscorlib (in mscorlib.dll)
public static Assembly GetAssembly ( Type type )
public static function GetAssembly ( type : Type ) : Assembly
Not applicable.
Parameters
- type
A Type object representing a class in the assembly that will be returned.
Return Value
The assembly in which the specified class is defined.The following example retrieves the assembly of a specified class.
Assembly SampleAssembly; // Instantiate a target object. Int32 Integer1 = new Int32(); Type Type1; // Set the Type instance to the target class type. Type1 = Integer1.GetType(); // Instantiate an Assembly class to the assembly housing the Integer type. SampleAssembly = Assembly.GetAssembly(Integer1.GetType()); // Gets the location of the assembly using file: protocol. Console.WriteLine("CodeBase=" + SampleAssembly.CodeBase);
- ReflectionPermission when invoked late-bound through mechanisms such as Type.InvokeMember. Associated enumeration: ReflectionPermissionFlag.MemberAccess.
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.