January 22nd, 2009

Why do I get the error REGDB_E_IIDNOTREG when I call a method that returns an interface?

This is another manifestation of the missing marshaller problem.

IContextMenu *pcm;
HRESULT hr = psf->GetUIObjectOf(hwnd, 1, &pidl,
               IID_IContextMenu, NULL, &pcm);
// fails with REGDB_E_IIDNOTREG

The IContextMenu interface does not have a proxy/stub factory (as of this writing). Recall that shell objects, as a rule, are apartment model. If you create the object from a multi-threaded apartment, COM needs to build a wrapper object which can marshal calls from off-thread back onto the original thread, in order to adhere to the threading rules for apartment-model objects.

And if the COM standard marshaler can’t find a proxy/stub factory for an interface, it returns the error REGDB_E_IIDNOTREG.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.