Assembly.Location Свойство

Определение

Получает полный путь либо UNC для расположения загруженного файла, содержащего манифест.

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

Значение свойства

String

Местоположение загруженного файла, содержащего манифест. Если сборка загружается из массива байтов, например при использовании Load(Byte[]), возвращаемое значение является пустой строкой ("").

Реализации

Исключения

Текущая сборка является динамической сборкой, представленной объектом AssemblyBuilder.

Примеры

В следующем примере показано расположение загруженного файла, содержащего манифест.

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

Комментарии

В .NET 5 и более поздних версиях для упакованных сборок возвращаемое значение является пустой строкой.

платформа .NET Framework только: если загруженный файл был скопирован теневым, расположение файла после копирования теневого копирования. Чтобы получить расположение перед копированием файла, используйте CodeBase свойство.

Применяется к

См. также раздел