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

Definition

Ruft den ursprünglich angegebenen Speicherort der Assembly ab, z. B. in einem AssemblyName-Objekt.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

Eigenschaftswert

Der Speicherort der Assembly, der ursprünglich angegeben wurde.The location of the assembly as specified originally.

Implementiert

Beispiele

Im folgenden Beispiel wird die CodeBase -Eigenschaft verwendet.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

Hinweise

Verwenden Sie die Assembly.Location -Eigenschaft, um den absoluten Pfad zur geladenen Manifest-Datei zu erhalten.To get the absolute path to the loaded manifest-containing file, use the Assembly.Location property instead.

Wenn die Assembly mithilfe einer Überladung der Load -Methode, die ein Bytearray annimmt, als Bytearray geladen wurde, gibt diese Eigenschaft den Speicherort des Aufrufers der Methode zurück, nicht den Speicherort der geladenen Assembly.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.

Sicherheit

FileIOPermission
für den Zugriff auf den Pfad.for access to the path. Zugehörige Enumeration:PathDiscoveryAssociated enumeration: PathDiscovery

Gilt für: