Freigeben über


Assembly.GetExecutingAssembly-Methode

Ruft die Assembly ab, die den derzeit ausgeführten Code enthält.

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

Syntax

'Declaration
Public Shared Function GetExecutingAssembly As Assembly
'Usage
Dim returnValue As Assembly

returnValue = Assembly.GetExecutingAssembly
public static Assembly GetExecutingAssembly ()
public:
static Assembly^ GetExecutingAssembly ()
public static Assembly GetExecutingAssembly ()
public static function GetExecutingAssembly () : Assembly

Rückgabewert

Eine Assembly, die die Assembly mit dem derzeit ausgeführten Code darstellt.

Hinweise

Wenn Sie die Assembly mit der Methode abrufen möchten, die den derzeit ausgeführten Code aufgerufen hat, verwenden Sie GetCallingAssembly.

Beispiel

Im folgenden Beispiel wird die Assembly des derzeit ausgeführten Codes abgerufen.

    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
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);
Assembly^ SampleAssembly;
// Instantiate a target object.
Int32 Integer1(0);
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= {0}", Assembly::GetExecutingAssembly()->FullName );
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);

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

Assembly-Klasse
Assembly-Member
System.Reflection-Namespace