C# Type GetTypeFromCLSID(Guid, String, Boolean)
Description
Type GetTypeFromCLSID(Guid, String, Boolean)
gets
the type associated with the specified class identifier (CLSID) from the
specified server, specifying whether to throw an exception if an error occurs
while loading the type.
Syntax
Type.GetTypeFromCLSID(Guid, String, Boolean)
has the following syntax.
public static Type GetTypeFromCLSID(
Guid clsid,/*w ww .j av a 2s.c om*/
string server,
bool throwOnError
)
Parameters
Type.GetTypeFromCLSID(Guid, String, Boolean)
has the following parameters.
clsid
- The CLSID of the type to get.server
- The server from which to load the type. If the server name is null, this method automatically reverts to the local machine.throwOnError
- true to throw any exception that occurs.throwOnError
- -or-throwOnError
- false to ignore any exception that occurs.
Returns
Type.GetTypeFromCLSID(Guid, String, Boolean)
method returns System.__ComObject regardless of whether the CLSID is valid.
Example
The following example retrieves the type associated with the CLSID from the local host, specifying whether to throw an exception if an error occurs while loading the type.
/* w w w. j a v a 2 s. com*/
using System;
public class MainClass{
public static void Main(String[] argv){
Guid myGuid3 = new Guid("8D8529D3-625D-1111-1111-3DAD630ECC1B");
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());
}
}
The code above generates the following result.