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

Definición

Obtiene la ubicación del ensamblado tal como se especificó originalmente, por ejemplo, en un 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 de propiedad

Ubicación del ensamblado tal y como se especificó originalmente.The location of the assembly as specified originally.

Implementaciones

Ejemplos

En el ejemplo siguiente se CodeBase usa la propiedad.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

Comentarios

Para obtener la ruta de acceso absoluta al archivo que contiene el manifiesto cargado, Assembly.Location use la propiedad en su lugar.To get the absolute path to the loaded manifest-containing file, use the Assembly.Location property instead.

Si el ensamblado se cargó como una matriz de bytes, mediante una Load sobrecarga del método que toma una matriz de bytes, esta propiedad devuelve la ubicación del llamador del método, no la ubicación del ensamblado cargado.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.

Seguridad

FileIOPermission
para acceder a la ruta de acceso.for access to the path. Enumeración asociada:PathDiscoveryAssociated enumeration: PathDiscovery

Se aplica a