Assembly.CodeBase Özellik

Tanım

Derlemenin konumunu, örneğin bir AssemblyName nesnede başlangıçta belirtildiği gibi alır.

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

Özellik Değeri

Derlemenin özgün olarak belirtildiği konum.

Uygulamalar

Özel durumlar

Yalnızca .NET Core ve .NET 5+ : Her durumda.

Örnekler

Aşağıdaki örnekte özelliği kullanılır CodeBase .

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

Açıklamalar

Yüklenen bildirim içeren dosyanın mutlak yolunu almak için bunun yerine özelliğini kullanın Assembly.Location .

Derleme bayt dizisi olarak yüklendiyse, bayt dizisi alan yöntemin Load aşırı yüklemesi kullanılarak, bu özellik yüklenen derlemenin konumunu değil yöntemini çağıranın konumunu döndürür.

.NET 5 ve sonraki sürümlerinde, paketlenmiş derlemeler için bu özellik bir özel durum oluşturur.

Şunlara uygulanır