Assembly.CodeBase Assembly.CodeBase Assembly.CodeBase Assembly.CodeBase Property

Definição

Obtém o local do assembly como especificado originalmente, por exemplo, em um objeto AssemblyName.Gets the location of the assembly as specified originally, for example, in an AssemblyName object.

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

Valor da propriedade

O local do assembly como especificado originalmente.The location of the assembly as specified originally.

Implementações

Exemplos

O exemplo a seguir usa CodeBase a propriedade.The following example uses the CodeBase property.

using namespace System;
using namespace System::Reflection;

void main()
{
   // Instantiate a target object.
   int integer1 = 1632;
   // Instantiate an Assembly class to the assembly housing the Integer type.
   Assembly^ systemAssembly = integer1.GetType()->Assembly;
   // Get the location of the assembly using the file: protocol.
   Console::WriteLine("CodeBase = {0}", systemAssembly->CodeBase);
}
// The example displays output like the following:
//   CodeBase = file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
using System;
using System.Reflection;

public class Example
{
   public static void Main()
   {
      // Instantiate a target object.
      Int32 integer1 = 1632;
      // Instantiate an Assembly class to the assembly housing the Integer type.
      Assembly systemAssembly = integer1.GetType().Assembly;
      // Get the location of the assembly using the file: protocol.
      Console.WriteLine("CodeBase = {0}", systemAssembly.CodeBase);
   }
}
// The example displays output like the following:
//    CodeBase = file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
Imports System.Reflection

Module Example
   Public Sub Main()
      ' Instantiate a target object.
      Dim integer1 As Integer = 1632
      ' Instantiate an Assembly class to the assembly housing the Integer type.
      Dim systemAssembly As Assembly = integer1.GetType().Assembly
      ' Get the location of the assembly using the file: protocol.
      Console.WriteLine("CodeBase = {0}", systemAssembly.CodeBase)
   End Sub
End Module
' The example displays output like the following:
'   CodeBase = file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll

Comentários

Para obter o caminho absoluto para o arquivo que contém o manifesto carregado, use Assembly.Location a propriedade em vez disso.To get the absolute path to the loaded manifest-containing file, use the Assembly.Location property instead.

Se o assembly foi carregado como uma matriz de bytes, usando uma sobrecarga do Load método que usa uma matriz de bytes, essa propriedade retorna o local do chamador do método, não o local do assembly carregado.If the assembly was loaded as a byte array, using an overload of the Load method that takes an array of bytes, this property returns the location of the caller of the method, not the location of the loaded assembly.

Segurança

FileIOPermission
para acessar o caminho.for access to the path. Enumeração associada: PathDiscoveryAssociated enumeration: PathDiscovery

Aplica-se a