Type.GetTypeFromCLSID Method (Guid, String)
Gets the type associated with the specified class identifier (CLSID) from the specified server.
Assembly: mscorlib (in mscorlib.dll)
- Type: System.Guid
The CLSID of the type to get.
- Type: System.String
The server from which to load the type. If the server name is a null reference (Nothing in Visual Basic), this method automatically reverts to the local machine.
Return ValueType: System.Type
System.__ComObject regardless of whether the CLSID is valid.
The GetTypeFromCLSID method supports late-bound access to COM objects from .NET Framework apps when you know the object's class identifier (CLSID). The class identifier for COM classes is defined in the HKEY_CLASSES_ROOT\CLSID key of the registry. You can retrieve the value of the IsCOMObject property to determine whether the type returned by this method is a COM object.
You can call the GetTypeFromProgID method for late-bound access to COM objects whose programmatic identifier (ProgID) you know.
Instantiating a COM object from its CLSID is a two-step process:
Call the Activator.CreateInstance(Type) method to instantiate the COM object.
This method is intended for use when working with COM objects, not with .NET Framework objects. Although the method returns a Type object that corresponds to the GUID for .NET Framework objects, you can't use that Type object to create a type instance by calling the Activator.CreateInstance method, as the following example shows.
The following example uses the CLSID of the Microsoft Word Application object to retrieve a COM type that represents the Microsoft Word application from a server named computer17.central.contoso.com. It then instantiates the type by calling the Activator.CreateInstance method, and closes it by calling the Application.Quit method.