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

classNamenull 参照 (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

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

ignoreCase

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

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

例外例外
例外種類条件

ArgumentNullException

classNamenull 参照 (Visual Basic では Nothing) です。

TargetInvocationException

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

ArgumentException

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

TypeLoadException

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

SecurityException

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

解説解説

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

classNamenull 参照 (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セキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Module.GetType」の関連用語

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

   

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



Module.GetTypeのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS