Why do I get E_NOINTERFACE when creating an object that supports that interface?

Raymond Chen

I’ve seen a few questions from people who call the CoCreateInstance function, asking for an interface that they know the object supports, yet receiving error E_NOINTERFACE. What’s going on?

You’re seeing the same problem as the missing IMarshal, just from the other side.

If your threading model is incompatible with the threading model of the object you’re creating, then COM marshalling kicks in. And if the marshalling stuff isn’t there, the error that comes out is E_NOINTERFACE, because the marshalling interface is missing.

A common source of this is attempting to use COM objects provided by the shell from a multi-threaded apartment. Remember that shell COM objects are, for the most part, apartment-threaded, not free-threaded. If you want to use shell objects, you should do so from single-threaded apartments.

0 comments

Discussion is closed.

Feedback usabilla icon