Assembly.Location Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém o caminho completo ou a localização UNC do ficheiro carregado que contém o manifesto.
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
Valor de Propriedade
A localização do ficheiro carregado que contém o manifesto. Se o assembly for carregado a partir de um array de bytes, como ao usar Load(Byte[]), o valor devolvido é uma cadeia vazia ("").
Implementações
Exceções
O conjunto atual é um conjunto dinâmico, representado por um AssemblyBuilder objeto.
Exemplos
O exemplo seguinte mostra a localização do ficheiro carregado que contém o manifesto.
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
Observações
No .NET 5 e versões posteriores, para assemblies agrupados, o valor devolvido é uma string vazia.
.NET Framework apenas: Se o ficheiro carregado foi copyed, a localização é a do ficheiro após a shadow-copy. Para obter a localização antes do ficheiro ser copiado em sombra, use a CodeBase propriedade.