다음을 통해 공유


AssemblyName.GetAssemblyName 메서드

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

네임스페이스: System.Reflection
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Public Shared Function GetAssemblyName ( _
    assemblyFile As String _
) As AssemblyName
‘사용 방법
Dim assemblyFile As String
Dim returnValue As AssemblyName

returnValue = AssemblyName.GetAssemblyName(assemblyFile)
public static AssemblyName GetAssemblyName (
    string assemblyFile
)
public:
static AssemblyName^ GetAssemblyName (
    String^ assemblyFile
)
public static AssemblyName GetAssemblyName (
    String assemblyFile
)
public static function GetAssemblyName (
    assemblyFile : String
) : AssemblyName

매개 변수

  • assemblyFile
    AssemblyName을 가져올 어셈블리 파일입니다.

반환 값

지정된 파일을 나타내는 AssemblyName 개체입니다.

예외

예외 형식 조건

ArgumentNullException

assemblyFile이 Null 참조(Visual Basic의 경우 Nothing)인 경우

ArgumentException

assemblyFile이 잘못된 경우(예: 잘못된 culture를 사용하는 어셈블리)

FileNotFoundException

assemblyFile이 없는 경우

SecurityException

호출자에게 경로 검색 권한이 없는 경우

BadImageFormatException

assemblyFile이 올바른 어셈블리가 아닌 경우

FileLoadException

서로 다른 두 개의 증명 정보를 사용하여 어셈블리 또는 모듈이 두 번 로드된 경우

설명

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

예제

다음 코드 예제에서는 디스크에 있는 어셈블리의 AssemblyName을 가져옵니다. 코드를 실행하려면 "MyAssembly.exe" 문자열을 하드 디스크에 있는 어셈블리의 파일 이름(필요한 경우 경로 포함)으로 바꿔야 합니다. 이 코드 예제를 "MyAssembly.exe"로 컴파일할 수도 있습니다.

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

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 'Main 
End Class 'AssemblyName_GetAssemblyName 
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());
   }
}
#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 );
}
import System.*;
import System.Reflection.*;
import System.Text.RegularExpressions.*;

public class AssemblyNameGetAssemblyName
{
    public static void main(String[] args)
    {
        // Get the type of 'System.Object'.
        Type myType = Object.class.ToType();

        // Get the path of 'System.dll'.
        String system = Regex.Replace(myType.get_Assembly().get_CodeBase(), 
            "mscorlib.dll", "System.dll");
        system = Regex.Replace(system, "file:///", "");

        // Get the assembly information and display to the console.
        AssemblyName myAssemblyName = AssemblyName.GetAssemblyName(system);
        Console.WriteLine("\nDisplaying the assembly information of "
            + "'System.dll'\n");
        Console.WriteLine(myAssemblyName.ToString());
    } //main
} //AssemblyNameGetAssemblyName

.NET Framework 보안

플랫폼

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

AssemblyName 클래스
AssemblyName 멤버
System.Reflection 네임스페이스