The NGWS runtime provides a standard class factory implementation that is capable of creating instances of any NGWS object. The runtime DLL (mscoree.dll) has an entry point for DllGetClassObject that creates can class factories for managed types as necessary. When NGWS classes are registered with RegAsm, mscoree.dll is supplied as the InProcServer32. This makes it possible for a COM clients to get a class factory for a NGWS class in exactly the same way they would get one for a COM class.
In order to actually create an instance of the NGWS class, the runtime must first locate the assembly that contains the class implementation. The runtime uses the information placed in the registry by RegAsm to locate the assembly that contains the NGWS class.
Given the CLSID passed to DllGetClassObject, the runtime opens the CLSID key in the registry and reads the class value from the key to determine the name of the class being requested. The runtime first checks with the loader to determine if an implementation of the named class is already loaded. If so, the runtime returns a reference to the object’s existing class factory to the caller of DllGetClassObject.
If a class with the specified name is not already loaded, the runtime reads the Assembly value from the registry and passes in on to the runtimes assembly resolver. The assembly resolver attempts to locate the assembly based on the assembly name. In order for the assembly resolver to locate the assembly, the assembly must be signed and installed in the runtimes assembly cache or it must be found along the application path. Assemblies loaded from the application path are only accessible from that application. Shared assemblies must be signed and installed in the assembly cache.
For complete details on how managed assemblies are located, see the spec on How the NGWS runtime Locates Assemblies
Once an assembly is located, the runtime loads the assembly and tries to locate the class’s metadata within the assembly. If the assembly contains a description of the class being requested, the runtime return a class factory object for the given class from DllGetClassObject.
After getting a class factory for a NGWS class from the runtime, the final step in activating an object is to call IClassFactory::CreateInstance. The same class factory object can be used to create any number of instances of the same class but each type of class requires a different class factory.