Assembly.Location Eigenschap

Definitie

Hiermee wordt het volledige pad of de UNC-locatie opgehaald van het geladen bestand dat het manifest bevat.

public:
 virtual property System::String ^ Location { System::String ^ get(); };
public virtual string Location { get; }
member this.Location : string
Public Overridable ReadOnly Property Location As String

Waarde van eigenschap

De locatie van het geladen bestand dat het manifest bevat. Als de assembly wordt geladen vanuit een bytematrix, zoals bij gebruik Load(Byte[]), is de geretourneerde waarde een lege tekenreeks ("").

Implementeringen

Uitzonderingen

De huidige assembly is een dynamische assembly, vertegenwoordigd door een AssemblyBuilder object.

Voorbeelden

In het volgende voorbeeld wordt de locatie weergegeven van het geladen bestand dat het manifest bevat.

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);
// The example displays the following output:
//   Location=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll
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))
' The example displays the following output:
'    Location=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll

Opmerkingen

In .NET 5 en hoger is de geretourneerde waarde voor gebundelde assembly's een lege tekenreeks.

alleen .NET Framework: Als het geladen bestand is shadow-copied, is de locatie die van het bestand nadat het schaduwkop is gekopieerd. Gebruik de CodeBase eigenschap om de locatie op te halen voordat het bestand schaduwkop is gekopieerd.

Van toepassing op

Zie ook