C# Type GetTypeFromCLSID(Guid, Boolean)

Description

Type GetTypeFromCLSID(Guid, Boolean) gets the type associated with the specified class identifier (CLSID), specifying whether to throw an exception if an error occurs while loading the type.

Syntax

Type.GetTypeFromCLSID(Guid, Boolean) has the following syntax.


public static Type GetTypeFromCLSID(
  Guid clsid,
  bool throwOnError
)

Parameters

Type.GetTypeFromCLSID(Guid, Boolean) has the following parameters.

  • clsid - The CLSID of the type to get.
  • throwOnError - true to throw any exception that occurs.
  • throwOnError - -or-
  • throwOnError - false to ignore any exception that occurs.

Returns

Type.GetTypeFromCLSID(Guid, 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.


using System;/* w ww . ja  v a  2  s.com*/
class MyGetTypeFromCLSIDSample
{
    public static void Main()
    {
            Guid myGuid1 = new Guid("1DCD0010-0B41-00D3-A565-00C04F8EF6E3");
            Type myType1 =Type.GetTypeFromCLSID(myGuid1, true);
            Console.WriteLine(myType1.GUID);
            Console.WriteLine(myType1.ToString());
     }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version