Module.GetType 메서드

정의

지정된 형식을 반환합니다.

오버로드

GetType(String)

대/소문자 구분을 수행하여 지정된 형식을 반환합니다.

GetType(String, Boolean)

지정된 형식을 반환하고 지정된 대/소문자를 사용하여 모듈을 검색합니다.

GetType(String, Boolean, Boolean)

모듈을 검색할 때 대/소문자를 구분할지 여부와 형식을 찾을 수 없을 때 예외를 throw할지 여부를 지정하여 지정된 형식을 반환합니다.

GetType(String)

대/소문자 구분을 수행하여 지정된 형식을 반환합니다.

public:
 virtual Type ^ GetType(System::String ^ className);
public virtual Type? GetType (string className);
public virtual Type GetType (string className);
[System.Runtime.InteropServices.ComVisible(true)]
public virtual Type GetType (string className);
override this.GetType : string -> Type
[<System.Runtime.InteropServices.ComVisible(true)>]
override this.GetType : string -> Type
Public Overridable Function GetType (className As String) As Type

매개 변수

className
String

찾을 형식의 이름입니다. 이름은 네임스페이스를 포함하는 정규화된 이름이어야 합니다.

반환

Type

형식이 이 모듈에 있으면 지정된 형식을 나타내는 Type 개체이고, 그렇지 않으면 null입니다.

특성

예외

className이(가) null인 경우

클래스 이니셜라이저가 호출되고 예외를 throw되는 경우

className 이 빈 문자열입니다.

className 에 종속 어셈블리가 필요하지만 이 어셈블리를 찾을 수 없습니다.

className에 종속 어셈블리가 필요하며 이 어셈블리를 찾았지만 로드할 수 없습니다.

또는 현재 어셈블리가 리플렉션 전용 컨텍스트에 로드되었으며 className에 종속 어셈블리가 필요하지만 이 어셈블리가 미리 로드되지 않았습니다.

className에 종속 어셈블리가 필요하지만 파일이 유효한 어셈블리가 아닙니다.

또는 className에 현재 로드된 버전보다 높은 런타임 버전용으로 컴파일된 종속 어셈블리가 필요합니다.

예제

다음은 지정한 모듈에 있는 형식의 이름을 표시하는 예제입니다.

using namespace System;
using namespace System::Reflection;

namespace ReflectionModule_Examples
{
   public ref class MyMainClass{};

}

int main()
{
   array<Module^>^moduleArray;
   moduleArray = ReflectionModule_Examples::MyMainClass::typeid->Assembly->GetModules( false );
   
   //In a simple project with only one module, the module at index
   // 0 will be the module containing these classes.
   Module^ myModule = moduleArray[ 0 ];
   Type^ myType;
   myType = myModule->GetType( "ReflectionModule_Examples.MyMainClass" );
   Console::WriteLine( "Got type: {0}", myType );
}
using System;
using System.Reflection;

namespace ReflectionModule_Examples
{
    class MyMainClass
    {
        static void Main()
        {
            Module[] moduleArray;
            
            moduleArray = typeof(MyMainClass).Assembly.GetModules(false);
            
            //In a simple project with only one module, the module at index
            // 0 will be the module containing these classes.
            Module myModule = moduleArray[0];

            Type myType;

            myType = myModule.GetType("ReflectionModule_Examples.MyMainClass");
            Console.WriteLine("Got type: {0}", myType.ToString());
        }
    }
}
Imports System.Reflection

'This code assumes that the root namespace is set to empty("").
Namespace ReflectionModule_Examples
    Class MyMainClass
        Shared Sub Main()
            Dim moduleArray() As [Module]

            moduleArray = GetType(MyMainClass).Assembly.GetModules(False)

            'In a simple project with only one module, the module at index
            ' 0 will be the module containing these classes.
            Dim myModule As [Module] = moduleArray(0)

            Dim myType As Type

            myType = myModule.GetType("ReflectionModule_Examples.MyMainClass")
            Console.WriteLine("Got type: {0}", myType.ToString())
        End Sub
    End Class
End Namespace 'ReflectionModule_Examples

설명

참고

형식이 다른 어셈블리로 전달된 경우에도 이 메서드에서 반환됩니다. 형식 전달에 대한 자세한 내용은 공용 언어 런타임의 형식 전달을 참조하세요.

를 사용하여 Module.GetType특정 모듈에서 형식을 검색할 수 있습니다. 매니페스트가 포함된 모듈을 호출 Module.GetType 해도 전체 어셈블리가 검색되지 않습니다. 어셈블리에 있는 모듈에 관계없이 어셈블리에서 형식을 검색하려면 .Assembly.GetType

적용 대상

GetType(String, Boolean)

지정된 형식을 반환하고 지정된 대/소문자를 사용하여 모듈을 검색합니다.

public:
 virtual Type ^ GetType(System::String ^ className, bool ignoreCase);
public virtual Type? GetType (string className, bool ignoreCase);
public virtual Type GetType (string className, bool ignoreCase);
[System.Runtime.InteropServices.ComVisible(true)]
public virtual Type GetType (string className, bool ignoreCase);
override this.GetType : string * bool -> Type
[<System.Runtime.InteropServices.ComVisible(true)>]
override this.GetType : string * bool -> Type
Public Overridable Function GetType (className As String, ignoreCase As Boolean) As Type

매개 변수

className
String

찾을 형식의 이름입니다. 이름은 네임스페이스를 포함하는 정규화된 이름이어야 합니다.

ignoreCase
Boolean

대/소문자를 구분하지 않는 검색의 경우는 true이고 대/소문자를 구분하는 검색의 경우는 false입니다.

반환

Type

형식이 이 모듈에 있으면 지정된 형식을 나타내는 Type 개체이고, 그렇지 않으면 null입니다.

특성

예외

className이(가) null인 경우

클래스 이니셜라이저가 호출되고 예외를 throw되는 경우

className 이 빈 문자열입니다.

className 에 종속 어셈블리가 필요하지만 이 어셈블리를 찾을 수 없습니다.

className에 종속 어셈블리가 필요하며 이 어셈블리를 찾았지만 로드할 수 없습니다.

또는 현재 어셈블리가 리플렉션 전용 컨텍스트에 로드되었으며 className에 종속 어셈블리가 필요하지만 이 어셈블리가 미리 로드되지 않았습니다.

className에 종속 어셈블리가 필요하지만 파일이 유효한 어셈블리가 아닙니다.

또는 className에 현재 로드된 버전보다 높은 런타임 버전용으로 컴파일된 종속 어셈블리가 필요합니다.

예제

다음 예제에서는 지정된 모듈에 있는 형식의 이름을 표시하여 매개 변수를 ignoreCase 지정하여 false 대/소문자를 무시하지 않도록 합니다.

using namespace System;
using namespace System::Reflection;

namespace ReflectionModule_Examples
{
   public ref class MyMainClass{};

}

int main()
{
   array<Module^>^moduleArray;
   moduleArray = ReflectionModule_Examples::MyMainClass::typeid->Assembly->GetModules( false );
   
   //In a simple project with only one module, the module at index
   // 0 will be the module containing these classes.
   Module^ myModule = moduleArray[ 0 ];
   Type^ myType;
   myType = myModule->GetType( "ReflectionModule_Examples.MyMainClass", false );
   Console::WriteLine( "Got type: {0}", myType );
}
using System;
using System.Reflection;

namespace ReflectionModule_Examples
{
    class MyMainClass
    {
        static void Main()
        {
            Module[] moduleArray;
            
            moduleArray = typeof(MyMainClass).Assembly.GetModules(false);
            
            //In a simple project with only one module, the module at index
            // 0 will be the module containing these classes.
            Module myModule = moduleArray[0];

            Type myType;
            myType = myModule.GetType("ReflectionModule_Examples.MyMainClass", false);
            Console.WriteLine("Got type: {0}", myType.ToString());
        }
    }
}
Imports System.Reflection

'This code assumes that the root namespace is set to empty("").
Namespace ReflectionModule_Examples
    Class MyMainClass
        Shared Sub Main()
            Dim moduleArray() As [Module]

            moduleArray = GetType(MyMainClass).Assembly.GetModules(False)

            'In a simple project with only one module, the module at index
            ' 0 will be the module containing these classes.
            Dim myModule As [Module] = moduleArray(0)

            Dim myType As Type
            myType = myModule.GetType("ReflectionModule_Examples.MyMainClass", False)
            Console.WriteLine("Got type: {0}", myType.ToString())
        End Sub
    End Class
End Namespace 'ReflectionModule_Examples

설명

참고

형식이 다른 어셈블리로 전달된 경우에도 이 메서드에서 반환됩니다. 형식 전달에 대한 자세한 내용은 공용 언어 런타임의 형식 전달을 참조하세요.

를 사용하여 Module.GetType특정 모듈에서 형식을 검색할 수 있습니다. 매니페스트가 포함된 모듈을 호출 Module.GetType 해도 전체 어셈블리가 검색되지 않습니다. 어셈블리에 있는 모듈에 관계없이 어셈블리에서 형식을 검색하려면 .Assembly.GetType

적용 대상

GetType(String, Boolean, Boolean)

모듈을 검색할 때 대/소문자를 구분할지 여부와 형식을 찾을 수 없을 때 예외를 throw할지 여부를 지정하여 지정된 형식을 반환합니다.

public:
 virtual Type ^ GetType(System::String ^ className, bool throwOnError, bool ignoreCase);
public virtual Type GetType (string className, bool throwOnError, bool ignoreCase);
public virtual Type? GetType (string className, bool throwOnError, bool ignoreCase);
[System.Runtime.InteropServices.ComVisible(true)]
public virtual Type GetType (string className, bool throwOnError, bool ignoreCase);
override this.GetType : string * bool * bool -> Type
[<System.Runtime.InteropServices.ComVisible(true)>]
override this.GetType : string * bool * bool -> Type
Public Overridable Function GetType (className As String, throwOnError As Boolean, ignoreCase As Boolean) As Type

매개 변수

className
String

찾을 형식의 이름입니다. 이름은 네임스페이스를 포함하는 정규화된 이름이어야 합니다.

throwOnError
Boolean

형식을 찾을 수 없는 경우 예외를 throw하려면 true이고, false을 반환하려면 null입니다.

ignoreCase
Boolean

대/소문자를 구분하지 않는 검색의 경우는 true이고 대/소문자를 구분하는 검색의 경우는 false입니다.

반환

Type

지정된 형식이 이 모듈에 선언된 경우 해당 형식을 나타내는 Type 개체이고, 그렇지 않으면 null입니다.

특성

예외

className이(가) null인 경우

클래스 이니셜라이저가 호출되고 예외를 throw되는 경우

className 이 빈 문자열입니다.

throwOnErrortrue이고 형식을 찾을 수 없습니다.

className 에 종속 어셈블리가 필요하지만 이 어셈블리를 찾을 수 없습니다.

className에 종속 어셈블리가 필요하며 이 어셈블리를 찾았지만 로드할 수 없습니다.

또는 현재 어셈블리가 리플렉션 전용 컨텍스트에 로드되었으며 className에 종속 어셈블리가 필요하지만 이 어셈블리가 미리 로드되지 않았습니다.

className에 종속 어셈블리가 필요하지만 파일이 유효한 어셈블리가 아닙니다.

또는 className에 현재 로드된 버전보다 높은 런타임 버전용으로 컴파일된 종속 어셈블리가 필요합니다.

예제

다음은 지정한 모듈에 있는 형식의 이름을 표시하는 예제입니다. 및 ignoreCase 매개 변수는 throwOnError .로 false지정됩니다.

using namespace System;
using namespace System::Reflection;

namespace ReflectionModule_Examples
{
   public ref class MyMainClass{};

}

int main()
{
   array<Module^>^moduleArray;
   moduleArray = ReflectionModule_Examples::MyMainClass::typeid->Assembly->GetModules( false );
   
   //In a simple project with only one module, the module at index
   // 0 will be the module containing this class.
   Module^ myModule = moduleArray[ 0 ];
   Type^ myType;
   myType = myModule->GetType( "ReflectionModule_Examples.MyMainClass", false, false );
   Console::WriteLine( "Got type: {0}", myType );
}
using System;
using System.Reflection;

namespace ReflectionModule_Examples
{
    class MyMainClass
    {
        static void Main()
        {
            Module[] moduleArray;
            
            moduleArray = typeof(MyMainClass).Assembly.GetModules(false);
            
            //In a simple project with only one module, the module at index
            // 0 will be the module containing this class.
            Module myModule = moduleArray[0];

            Type myType;
            myType = myModule.GetType("ReflectionModule_Examples.MyMainClass", false, false);
            Console.WriteLine("Got type: {0}", myType.ToString());
        }
    }
}
Imports System.Reflection

'This code assumes that the root namespace is set to empty("").
Namespace ReflectionModule_Examples
    Class MyMainClass
        Shared Sub Main()
            Dim moduleArray() As [Module]

            moduleArray = GetType(MyMainClass).Assembly.GetModules(False)

            'In a simple project with only one module, the module at index
            ' 0 will be the module containing this class.
            Dim myModule As [Module] = moduleArray(0)

            Dim myType As Type
            myType = myModule.GetType("ReflectionModule_Examples.MyMainClass", False, False)
            Console.WriteLine("Got type: {0}", myType.ToString())
        End Sub
    End Class
End Namespace 'ReflectionModule_Examples

설명

매개 변수는 throwOnError 형식을 찾을 수 없을 때 발생하는 동작에만 영향을 줍니다. throw될 수 있는 다른 예외에는 영향을 주지 않습니다. 특히 형식을 찾았지만 로드 TypeLoadException 할 수 없는 경우 있더라도 throwOnError falsethrow할 수 있습니다.

참고

형식이 다른 어셈블리로 전달된 경우에도 이 메서드에서 반환됩니다. 형식 전달에 대한 자세한 내용은 공용 언어 런타임의 형식 전달을 참조하세요.

를 사용하여 Module.GetType특정 모듈에서 형식을 검색할 수 있습니다. 매니페스트가 포함된 모듈을 호출 Module.GetType 해도 전체 어셈블리가 검색되지 않습니다. 어셈블리에 있는 모듈에 관계없이 어셈블리에서 형식을 검색하려면 .Assembly.GetType

적용 대상