Assembly.GetAssembly(Type) Assembly.GetAssembly(Type) Assembly.GetAssembly(Type) Method

정의

지정된 형식이 정의되어 있는 현재 로드된 어셈블리를 가져옵니다.Gets the currently loaded assembly in which the specified type is defined.

public:
 static System::Reflection::Assembly ^ GetAssembly(Type ^ type);
public static System.Reflection.Assembly GetAssembly (Type type);
static member GetAssembly : Type -> System.Reflection.Assembly

매개 변수

type
Type Type Type

어셈블리에서 반환될 형식을 나타내는 개체입니다.An object representing a type in the assembly that will be returned.

반환

지정된 형식이 정의되어 있는 어셈블리입니다.The assembly in which the specified type is defined.

예외

예제

다음 예제에서는 포함 된 어셈블리를 검색 합니다 Int32 형식과 해당 이름 및 파일 위치를 표시 합니다.The following example retrieves the assembly that contains the Int32 type and displays its name and file location.

using namespace System;
using namespace System::Reflection;

void main()
{
   // Get a Type object.
   Type^ t = int::typeid;
   // Instantiate an Assembly class to the assembly housing the Integer type.
   Assembly^ assem = Assembly::GetAssembly(t);
   // Display the name of the assembly.
   Console::WriteLine("Name: {0}", assem->FullName);
   // Get the location of the assembly using the file: protocol.
   Console::WriteLine("CodeBase: {0}", assem->CodeBase);
}
// The example displays output like the following:
//    Name: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
//    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
using System;
using System.Reflection;

public class Example
{
   public static void Main()
   {
      // Get a Type object.
      Type t = typeof(int);
      // Instantiate an Assembly class to the assembly housing the Integer type.
      Assembly assem = Assembly.GetAssembly(t);
      // Display the name of the assembly.
      Console.WriteLine("Name: {0}", assem.FullName);
      // Get the location of the assembly using the file: protocol.
      Console.WriteLine("CodeBase: {0}", assem.CodeBase);
   }
}
// The example displays output like the following:
//    Name: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
//    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
Imports System.Reflection

Module Example
   Public Sub Main()
      ' Get a Type object.
      Dim t As Type = GetType(Integer)
      ' Instantiate an Assembly class to the assembly housing the Integer type.
      Dim assem As Assembly = Assembly.GetAssembly(t)
      ' Display the name of the assembly.
      Console.WriteLine("Name: {0}", assem.FullName)
      ' Get the location of the assembly using the file: protocol.
      Console.WriteLine("CodeBase: {0}", assem.CodeBase)
   End Sub
End Module
' The example displays output like the following:
'    Name: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
'    CodeBase: file:'/C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll

설명

이 메서드 호출의 값을 검색 하는 것은 Type.Assembly 속성입니다.Calling this method is equivalent to retrieving the value of the Type.Assembly property. 그러나는 Type.Assembly 속성에는 일반적으로 뛰어난 성능을 제공 합니다.However, the Type.Assembly property typically offers superior performance.

이 메서드를 호출 하려면 있어야를 Type 개체 클래스 정의 되어 있는 어셈블리가 이미 로드 되어 있어야 함을 의미 합니다.In order to call this method, you must have a Type object, which means that the assembly in which the class is defined must already be loaded.

보안

ReflectionPermission
호출 될 때 런타임에 바인딩된 메커니즘을 통해 같은 InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[])합니다.when invoked late-bound through mechanisms such as InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[]). 연결 된 열거형: MemberAccessAssociated enumeration: MemberAccess

적용 대상