Assembly.Location-Eigenschaft

Ruft den Pfad oder UNC-Pfad der geladenen Datei ab, die das Manifest enthält.

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

Syntax

'Declaration
Public Overridable ReadOnly Property Location As String
'Usage
Dim instance As Assembly
Dim value As String

value = instance.Location
public virtual string Location { get; }
public:
virtual property String^ Location {
    String^ get ();
}
/** @property */
public String get_Location ()
public function get Location () : String

Eigenschaftenwert

Der Speicherort der geladenen Datei, die das Manifest enthält. Wenn eine Schattenkopie der geladenen Datei erstellt wurde, entspricht der Speicherort dem der Datei nach dem Erstellen der Schattenkopie. Wenn die Assembly aus einem Bytearray geladen wurde, z. B. bei Verwendung der Überladung der Load(Byte[])-Methode, ist der zurückgegebene Wert eine leere Zeichenfolge ("").

Hinweise

Wenn Sie den Speicherort vor dem Erstellen einer Schattenkopie der Datei abrufen möchten, verwenden Sie die CodeBase-Eigenschaft.

Beispiel

Im folgenden Beispiel wird der Speicherort der geladenen Datei angezeigt, die das Manifest enthält.

    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 physical location of the assembly containing the manifest.
    Console.WriteLine(("Location=" + SampleAssembly.Location))
End Sub 'Snippet3
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 physical location of the assembly containing the manifest.
Console.WriteLine("Location=" + SampleAssembly.Location);
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 physical location of the assembly containing the manifest.
Console::WriteLine( "Location= {0}", SampleAssembly->Location );
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 physical location of the assembly containing the manifest.
Console.WriteLine("Location=" + SampleAssembly.Location);

.NET Framework-Sicherheit

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

Siehe auch

Referenz

Assembly-Klasse
Assembly-Member
System.Reflection-Namespace