型の読み込み中にエラーが発生した場合に例外をスローするかどうかを指定して、指定したサーバーの指定したクラス ID (CLSID) に関連付けられた型を取得します。
Overloads Public Shared Function GetTypeFromCLSID( _
ByVal clsid As Guid, _ ByVal server As String, _ ByVal throwOnError As Boolean _) As Type
[C#]
public static Type GetTypeFromCLSID(Guidclsid,stringserver,boolthrowOnError);
[C++]
public: static Type* GetTypeFromCLSID(Guidclsid,String* server,boolthrowOnError);
[JScript]
public static function GetTypeFromCLSID(
clsid : Guid,server : String,throwOnError : Boolean) : Type;
パラメータ
clsid
取得する型の CLSID。server
型の読み込み元のサーバー。サーバー名が null 参照 (Visual Basic では Nothing) の場合、このメソッドは自動的にローカル マシンの名前を使用します。throwOnError
発生した例外をすべてスローする場合は true 。または
発生した例外をすべて無視する場合は false 。
戻り値
CLSID が有効かどうかに関係なく System.__ComObject 。
解説
throwOnError を true に指定すると OutOfMemoryException などの例外がスローされますが、CLSID が未登録でも失敗することはありません。
使用例
[Visual Basic, C#, C++] 型の読み込み中にエラーが発生した場合に例外をスローするかどうかを指定して、ローカル ホストの CLSID に対応する型を取得する例を次に示します。
' Create a GUID.
Dim myGuid3 As New Guid("8D8529D3-625D-4496-8354-3DAD630ECC1B")
' Get the type associated with the CLSID
' from the local host and specify whether to throw an exception if an
' error occurs while loading the type.
Dim myType3 As Type = Type.GetTypeFromCLSID(myGuid3, ".", True)
Console.WriteLine("The GUID associated with myType3 is {0}.", myType3.GUID.ToString())
Console.WriteLine("The type of the GUID is {0}.", myType3.ToString())
[C#]
// Create a GUID.
Guid myGuid3 = new Guid("8D8529D3-625D-4496-8354-3DAD630ECC1B");
// Get the type associated with the CLSID
// from the local host and specify whether to throw an exception if an
// error occurs while loading the type.
Type myType3 =Type.GetTypeFromCLSID(myGuid3, ".", true);
Console.WriteLine("The GUID associated with myType3 is {0}.", myType3.GUID);
Console.WriteLine("The type of the GUID is {0}.", myType3.ToString());
[C++]
// Create a GUID.
Guid myGuid3 = Guid(S"8D8529D3-625D-4496-8354-3DAD630ECC1B");
// Get the type associated with the CLSID
// from the local host and specify whether to throw an exception if an
// error occurs while loading the type.
Type* myType3 = Type::GetTypeFromCLSID(myGuid3, S".", true);
Console::WriteLine(S"The GUID associated with myType3 is {0}.",__box( myType3->GUID));
Console::WriteLine(S"The type of the GUID is {0}.", myType3);
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
Type クラス | Type メンバ | System 名前空間 | Type.GetTypeFromCLSID オーバーロードの一覧