Assembly.CodeBase 속성

정의

주의

Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location instead.

예를 들어 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(); };
[System.Obsolete("Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location instead.", DiagnosticId="SYSLIB0012", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual string? CodeBase { get; }
public virtual string CodeBase { get; }
public virtual string? CodeBase { get; }
[<System.Obsolete("Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location instead.", DiagnosticId="SYSLIB0012", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
member this.CodeBase : string
member this.CodeBase : string
Public Overridable ReadOnly Property CodeBase As String

속성 값

String

원래 지정된 어셈블리 위치입니다.The location of the assembly as specified originally.

구현

특성

예제

다음 예제에서는 속성을 사용 합니다 CodeBase .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

설명

로드 된 매니페스트를 포함 하는 파일의 절대 경로를 가져오려면 Assembly.Location 대신 속성을 사용 합니다.To get the absolute path to the loaded manifest-containing file, use the Assembly.Location property instead.

어셈블리가 바이트 배열로 로드 된 경우 바이트 배열을 사용 하는 메서드의 오버 로드를 사용 하 여 Load 이 속성은 로드 된 어셈블리의 위치가 아니라 메서드의 호출자 위치를 반환 합니다.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.

.NET 5.0 이상 버전에서 번들 어셈블리의 경우이 속성은 예외를 throw 합니다.In .NET 5.0 and later versions, for bundled assemblies, this property throws an exception.

적용 대상