Module.GetTypeとは? わかりやすく解説

Module.GetType メソッド (String, Boolean)

指定した大文字小文字の区別の扱いに従ってモジュールを検索し、指定した型を返します。

名前空間: System.Reflection
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<ComVisibleAttribute(True)> _
Public Overridable Function
 GetType ( _
    className As String, _
    ignoreCase As Boolean _
) As Type
Dim instance As Module
Dim className As String
Dim ignoreCase As Boolean
Dim returnValue As Type

returnValue = instance.GetType(className, ignoreCase)
[ComVisibleAttribute(true)] 
public virtual Type GetType (
    string className,
    bool ignoreCase
)
[ComVisibleAttribute(true)] 
public:
virtual Type^ GetType (
    String^ className, 
    bool ignoreCase
)
/** @attribute ComVisibleAttribute(true) */ 
public Type GetType (
    String className, 
    boolean ignoreCase
)
ComVisibleAttribute(true) 
public function GetType (
    className : String, 
    ignoreCase : boolean
) : Type

パラメータ

className

検索する型の名前。この名前は、名前空間を含む完全修飾名であることが必要です。

ignoreCase

大文字小文字を区別しない検索を行う場合は true。それ以外の場合は false。

戻り値
型がこのモジュールに含まれている場合は、指定された型を表す Type オブジェクト。それ以外の場合は null 参照 (Visual Basic では Nothing)。

例外例外
例外の種類条件

ArgumentNullException

className が null 参照 (Visual Basic では Nothing) です。

TargetInvocationException

クラス初期化子が呼び出され、例外がスローされます。

ArgumentException

className が無効です。たとえば、無効な文字が含まれているか、長さが 0 の文字列です。

SecurityException

呼び出し元が必要なリフレクション アクセス許可を持たずに、パブリックではない型にリフレクションしようとしました。

使用例使用例

指定したモジュールの型の名前を表示する例を次に示します。この例では、大文字と小文字を区別するため ignoreCase パラメータに false を指定します。

Imports System
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 = [Assembly].GetExecutingAssembly().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 'Main
    End Class 'MyMainClass
End Namespace 'ReflectionModule_Examples
using System;
using System.Reflection;

namespace ReflectionModule_Examples
{
    class MyMainClass
    {
        static void Main()
        {
            Module[] moduleArray;
            
            moduleArray = Assembly.GetExecutingAssembly().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());
        }
    }
}
using namespace System;
using namespace System::Reflection;

namespace ReflectionModule_Examples
{
   public ref class MyMainClass{};

}

int main()
{
   array<Module^>^moduleArray;
   moduleArray = Assembly::GetExecutingAssembly()->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 );
}

package ReflectionModule_Examples; 
import System.*;
import System.Reflection.*;

class MyMainClass
{

    public static void main(String[]
 args)
    {
        Module moduleArray[];
        moduleArray = Assembly.GetExecutingAssembly().GetModules(false);

        //In a simple project with only one module, the module at index
        // 0 will be the module containing these classes.
        Module myModule = (Module)moduleArray.get_Item(0);
        Type myType;
        myType = myModule.GetType("ReflectionModule_Examples.MyMainClass",
 
            false);
        Console.WriteLine("Got type: {0}", myType.ToString());
    } //main
} //MyMainClass   
.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Module.GetType メソッド


Module.GetType メソッド (String, Boolean, Boolean)

大文字小文字を区別したモジュール検索を実行するかどうか、および型が見つからない場合に例外をスローするかどうかを指定して、指定された型を返します。

名前空間: System.Reflection
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<ComVisibleAttribute(True)> _
Public Overridable Function
 GetType ( _
    className As String, _
    throwOnError As Boolean, _
    ignoreCase As Boolean _
) As Type
Dim instance As Module
Dim className As String
Dim throwOnError As Boolean
Dim ignoreCase As Boolean
Dim returnValue As Type

returnValue = instance.GetType(className, throwOnError, ignoreCase)
[ComVisibleAttribute(true)] 
public virtual Type GetType (
    string className,
    bool throwOnError,
    bool ignoreCase
)
[ComVisibleAttribute(true)] 
public:
virtual Type^ GetType (
    String^ className, 
    bool throwOnError, 
    bool ignoreCase
)
/** @attribute ComVisibleAttribute(true) */ 
public Type GetType (
    String className, 
    boolean throwOnError, 
    boolean ignoreCase
)
ComVisibleAttribute(true) 
public function GetType (
    className : String, 
    throwOnError : boolean, 
    ignoreCase : boolean
) : Type

パラメータ

className

検索する型の名前。この名前は、名前空間を含む完全修飾名であることが必要です。

throwOnError

型が見つからなかったときに例外をスローする場合は true。null 参照 (Visual Basic では Nothing) を返す場合は false。

ignoreCase

大文字小文字を区別しない検索を行う場合は true。それ以外の場合は false。

戻り値
型がこのモジュールで宣言されている場合は、指定された型を表す Type オブジェクト。それ以外の場合は null 参照 (Visual Basic では Nothing)。

例外例外
例外の種類条件

ArgumentNullException

className が null 参照 (Visual Basic では Nothing) です。

TargetInvocationException

クラス初期化子が呼び出され、例外がスローされます。

ArgumentException

className が無効です。たとえば、無効な文字が含まれているか、長さが 0 の文字列です。

TypeLoadException

throwOnError が true であり、型を見つけることができません。

SecurityException

呼び出し元が必要なリフレクション アクセス許可を持たずに、パブリックではない型にリフレクションしようとしました。

解説解説

throwOnError パラメータは、型が見つからなかった場合の動作にのみ影響します。スローされる可能性のあるその他の例外には影響しません。特に、型が見つかっても読み込むことができない場合は、throwOnError が false であっても TypeLoadException がスローされます。

使用例使用例

指定したモジュールの型の名前を表示する例を次に示します。throwOnError パラメータと ignoreCase パラメータは false に指定できます。

Imports System
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 = [Assembly].GetExecutingAssembly().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 'Main
    End Class 'MyMainClass
End Namespace 'ReflectionModule_Examples
using System;
using System.Reflection;

namespace ReflectionModule_Examples
{
    class MyMainClass
    {
        static void Main()
        {
            Module[] moduleArray;
            
            moduleArray = Assembly.GetExecutingAssembly().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());
        }
    }
}
using namespace System;
using namespace System::Reflection;

namespace ReflectionModule_Examples
{
   public ref class MyMainClass{};

}

int main()
{
   array<Module^>^moduleArray;
   moduleArray = Assembly::GetExecutingAssembly()->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 );
}

package ReflectionModule_Examples; 

import System.*;
import System.Reflection.*;

class MyMainClass
{

    public static void main(String[]
 args)
    {
        Module moduleArray[];
        moduleArray = Assembly.GetExecutingAssembly().GetModules(false);
        //In a simple project with only one module, the module at index
        // 0 will be the module containing this class.
        Module myModule = (Module)moduleArray.get_Item(0);
        Type myType;
        myType = myModule.GetType("ReflectionModule_Examples.MyMainClass"
,
            false, false);
        Console.WriteLine("Got type: {0}", myType.ToString());
    } //main
} //MyMainClass   
.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Module.GetType メソッド (String)

大文字小文字を区別する検索を実行して、指定された型を返します。

名前空間: System.Reflection
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<ComVisibleAttribute(True)> _
Public Overridable Function
 GetType ( _
    className As String _
) As Type
Dim instance As Module
Dim className As String
Dim returnValue As Type

returnValue = instance.GetType(className)
[ComVisibleAttribute(true)] 
public virtual Type GetType (
    string className
)
[ComVisibleAttribute(true)] 
public:
virtual Type^ GetType (
    String^ className
)
/** @attribute ComVisibleAttribute(true) */ 
public Type GetType (
    String className
)
ComVisibleAttribute(true) 
public function GetType (
    className : String
) : Type

パラメータ

className

検索する型の名前。この名前は、名前空間を含む完全修飾名であることが必要です。

戻り値
型がこのモジュールに含まれている場合は、指定された型を表す Type オブジェクト。それ以外の場合は null 参照 (Visual Basic では Nothing)。

例外例外
例外の種類条件

ArgumentNullException

className が null 参照 (Visual Basic では Nothing) です。

TargetInvocationException

クラス初期化子が呼び出され、例外がスローされます。

ArgumentException

className が無効です。たとえば、無効な文字が含まれているか、長さが 0 の文字列です。

SecurityException

呼び出し元が必要なリフレクション アクセス許可を持たずに、パブリックではない型にリフレクションしようとしました。

使用例使用例

指定したモジュールの型の名前を表示する例を次に示します。

Imports System
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 = [Assembly].GetExecutingAssembly().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 'Main
    End Class 'MyMainClass
End Namespace 'ReflectionModule_Examples
using System;
using System.Reflection;

namespace ReflectionModule_Examples
{
    class MyMainClass
    {
        static void Main()
        {
            Module[] moduleArray;
            
            moduleArray = Assembly.GetExecutingAssembly().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());
        }
    }
}
using namespace System;
using namespace System::Reflection;

namespace ReflectionModule_Examples
{
   public ref class MyMainClass{};

}

int main()
{
   array<Module^>^moduleArray;
   moduleArray = Assembly::GetExecutingAssembly()->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 );
}

package ReflectionModule_Examples;
import System.*;
import System.Reflection.*;

class MyMainClass
{

    public static void main(String[]
 args)
    {
        Module moduleArray[];
        moduleArray = Assembly.GetExecutingAssembly().GetModules(false);
        //In a simple project with only one module, the module at index
        // 0 will be the module containing these classes.
        Module myModule = (Module)moduleArray.get_Item(0);
        Type myType;
        myType = myModule.GetType("ReflectionModule_Examples.MyMainClass");
        Console.WriteLine("Got type: {0}", myType.ToString());
    } //main
} //MyMainClass   
.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からModule.GetTypeを検索した結果を表示しています。
Weblioに収録されているすべての辞書からModule.GetTypeを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からModule.GetType を検索

英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「Module.GetType」の関連用語

Module.GetTypeのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Module.GetTypeのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS