Assembly.CodeBase 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
개체 AssemblyName 와 같이 원래 지정된 어셈블리의 위치를 가져옵니다.
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
속성 값
원래 지정된 어셈블리의 위치입니다.
구현
예외
.NET Core 및 .NET 5+만: 모든 경우에.
예제
다음 예제에서는 속성을 사용합니다 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
설명
로드된 매니페스트 포함 파일의 절대 경로를 얻으려면 대신 속성을 사용합니다 Assembly.Location .
바이트 배열을 사용하는 메서드의 Load 오버로드를 사용하여 어셈블리를 바이트 배열로 로드한 경우 이 속성은 로드된 어셈블리의 위치가 아니라 메서드 호출자의 위치를 반환합니다.
.NET 5 이상 버전에서 번들 어셈블리의 경우 이 속성은 예외를 throw합니다.