Export (0) Print
Expand All

Assembly.GetExecutingAssembly Method

Gets the Assembly that the current code is running from.

[Visual Basic]
Public Shared Function GetExecutingAssembly() As Assembly
[C#]
public static Assembly GetExecutingAssembly();
[C++]
public: static Assembly* GetExecutingAssembly();
[JScript]
public static function GetExecutingAssembly() : Assembly;

Return Value

The assembly that the current code is running from.

Example

The following example gets the assembly of the currently running code.

[Visual Basic] 
Dim SampleAssembly As [Assembly]
' Instantiate a target object.
Dim Integer1 As New Int32()
Dim Type1 As Type
' 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())
' Display the name of the assembly currently executing
Console.WriteLine(("GetExecutingAssembly=" + [Assembly].GetExecutingAssembly().FullName))
        End Sub 'Snippet5

[C#] 
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());
// Display the name of the assembly currently executing
Console.WriteLine("GetExecutingAssembly=" + Assembly.GetExecutingAssembly().FullName);

[C++] 
Assembly* SampleAssembly;
// Instantiate a target object.
Int32 Integer1(0);
Type* Type1;
// Set the Type instance to the target class type.
Type1 = __box(Integer1)->GetType();
// Instantiate an Assembly class to the assembly housing the Integer type.  
SampleAssembly = Assembly::GetAssembly(__box(Integer1)->GetType());
// Display the name of the assembly currently executing
Console::WriteLine(S"GetExecutingAssembly= {0}", Assembly::GetExecutingAssembly()->FullName);

[JScript] 
var SampleAssembly : Assembly;
// Instantiate a target object.
var Integer1 : Int32 = 0;
var Type1 : Type;
// 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());
// Display the name of the assembly currently executing
Console.WriteLine("GetExecutingAssembly=" + Assembly.GetExecutingAssembly().FullName);

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

.NET Framework Security: 

See Also

Assembly Class | Assembly Members | System.Reflection Namespace

Show:
© 2014 Microsoft