Assembly.Location 속성

정의

매니페스트가 포함된 로드된 파일의 전체 경로나 UNC 위치를 가져옵니다.

public:
 virtual property System::String ^ Location { System::String ^ get(); };
public virtual string Location { get; }
member this.Location : string
Public Overridable ReadOnly Property Location As String

속성 값

String

매니페스트가 포함된 로드된 파일의 위치입니다. 사용 시 Load(Byte[])와 같이 바이트 배열에서 어셈블리를 로드하는 경우 반환되는 값은 빈 문자열("")입니다.

구현

예외

현재 어셈블리가 AssemblyBuilder 개체로 표현되는 동적 어셈블리입니다.

예제

다음 예제에서는 매니페스트를 포함하는 로드된 파일의 위치를 표시합니다.

Assembly^ SampleAssembly;
// Instantiate a target object.
Int32 Integer1(0);
Type^ Type1;
// Set the Type instance to the target class type.
Type1 = Integer1.GetType();
// Instantiate an Assembly class to the assembly housing the Integer type.  
SampleAssembly = Assembly::GetAssembly( Integer1.GetType() );
// Display the physical location of the assembly containing the manifest.
Console::WriteLine( "Location= {0}", SampleAssembly->Location );
// The example displays the following output:
//    Location=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll
Assembly SampleAssembly;
// Instantiate a target object.
Int32 Integer1 = new Int32();
Type Type1;
// Set the Type instance to the target class type.
Type1 = Integer1.GetType();
// Instantiate an Assembly class to the assembly housing the Integer type.
SampleAssembly = Assembly.GetAssembly(Integer1.GetType());
// Display the physical location of the assembly containing the manifest.
Console.WriteLine("Location=" + SampleAssembly.Location);
// The example displays the following output:
//   Location=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll
Dim SampleAssembly As [Assembly]
' Instantiate a target object.
Dim Integer1 As New Int32()
Dim Type1 As Type
' Set the Type instance to the target class type.
Type1 = Integer1.GetType()
' Instantiate an Assembly class to the assembly housing the Integer type.  
SampleAssembly = [Assembly].GetAssembly(Integer1.GetType())
' Display the physical location of the assembly containing the manifest.
Console.WriteLine(("Location=" + SampleAssembly.Location))
' The example displays the following output:
'    Location=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll

설명

.NET 5 이상 버전에서 번들 어셈블리의 경우 반환되는 값은 빈 문자열입니다.

.NET Framework 전용: 로드된 파일이 섀도 복사된 경우 위치는 섀도 복사 후 파일의 위치입니다. 파일이 섀도 복사되기 전에 위치를 얻으려면 속성을 사용합니다 CodeBase .

적용 대상

추가 정보