AssemblyName.GetAssemblyName(String) 메서드

정의

지정된 파일의 AssemblyName을 가져옵니다.

public:
 static System::Reflection::AssemblyName ^ GetAssemblyName(System::String ^ assemblyFile);
public static System.Reflection.AssemblyName GetAssemblyName (string assemblyFile);
static member GetAssemblyName : string -> System.Reflection.AssemblyName
Public Shared Function GetAssemblyName (assemblyFile As String) As AssemblyName

매개 변수

assemblyFile
String

AssemblyName이 반환될 어셈블리의 경로입니다.

반환

AssemblyName

제공된 어셈블리 파일을 나타내는 개체입니다.

예외

assemblyFile이(가) null인 경우

assemblyFile이 잘못된 경우(예: 잘못된 문화권을 사용하는 어셈블리)

assemblyFile 가 없는 경우

호출자에게 경로 검색 권한이 없습니다.

assemblyFile는 유효한 어셈블리가 아닙니다.

어셈블리 또는 모듈이 서로 다른 두 증명 정보 집합으로 두 번 로드되었습니다.

예제

다음 예제에서는 디스크의 AssemblyName 어셈블리에 대한 값을 가져옵니다. "MyAssembly.exe" 문자열을 하드 디스크의 어셈블리 파일 이름(필요한 경우 경로 포함)으로 대체하지 않으면 실행되지 않습니다. 또는 이 예제를 "MyAssembly.exe"로 컴파일할 수 있습니다.

#using <system.dll>

using namespace System;
using namespace System::Reflection;
int main()
{
   
   // Replace the string "MyAssembly.exe" with the name of an assembly,
   // including a path if necessary. If you do not have another assembly
   // to use, you can use whatever name you give to this assembly.
   //
   AssemblyName^ myAssemblyName = AssemblyName::GetAssemblyName( "MyAssembly.exe" );
   Console::WriteLine( "\nDisplaying assembly information:\n" );
   Console::WriteLine( myAssemblyName );
}

using System;
using System.Reflection;

public class AssemblyName_GetAssemblyName
{
   public static void Main()
   {
      // Replace the string "MyAssembly.exe" with the name of an assembly,
      // including a path if necessary. If you do not have another assembly
      // to use, you can use whatever name you give to this assembly.
      //
      AssemblyName myAssemblyName = AssemblyName.GetAssemblyName("MyAssembly.exe");
      Console.WriteLine("\nDisplaying assembly information:\n");
      Console.WriteLine(myAssemblyName.ToString());
   }
}
Imports System.Reflection

Public Class AssemblyName_GetAssemblyName
   
   Public Shared Sub Main()
      
      ' Replace the string "MyAssembly.exe" with the name of an assembly,
      ' including a path if necessary. If you do not have another assembly
      ' to use, you can use whatever name you give to this assembly.
      '
      Dim myAssemblyName As AssemblyName = AssemblyName.GetAssemblyName("MyAssembly.exe")
      Console.WriteLine(vbCrLf & "Displaying assembly information:" & vbCrLf)
      Console.WriteLine(myAssemblyName.ToString())
   End Sub
End Class

설명

이 작업은 파일에 어셈블리 매니페스트가 포함된 경우에만 작동합니다. 이 메서드를 사용하면 파일을 열고 닫을 수 있지만 어셈블리는 이 도메인에 추가되지 않습니다.

적용 대상