A customer was adding an interface to their out-of-process COM server. They added their interface to the project’s existing IDL file and recompiled the resulting proxy stub DLL. But when they tried to connect to the server, the connection failed with error 0x80040155
, also known as REGDB_
: Interface not registered.
They realized that they forgot to register the interface’s proxy, so they added an entry to [HKCR\
Upon trying again, the connection still failed. This time with the error 0x80004002
, the often-encountered E_
: No such interface supported.
We learned that one cause of this is a missing marshaler.
“But that doesn’t apply in this case, because I registered the interface and pointed it to the proxy DLL that holds the marshaler!”
Does that proxy DLL hold the marshaler?
We looked at the interface declaration.
[
object,
local,
uuid(iid)
]
interface IWidgetFactory : IUnknown
{
⟦ ... ⟧
}
The interface is marked as local
. A local interface is one that never leaves its home apartment and therefore never needs to be marshalled. The IDL compiler does not generate marshallers for local interface because they would never be needed.
I don’t know the history here. It’s possible that this interface started out as local because it was originally designed as an in-apartment object, but then the team decided to move the widget factory out of process (which now requires a marshaller) and forgot to remove the local
attribute.
Or maybe the local
was just a copy-pasta from elsewhere in the IDL file that they forgot to remove. (Or they didn’t realize what it meant.)
As the old saying goes, anything that can be explained by a copy/paste error requires no further explanation.