Ismail Hakan Uluyol
Ismail Hakan Uluyol

Reputation: 11

CoCreateInstance returns E_NOINTERFACE in one PC

I am using CoCreateInstance function to create a single object of the class associated with a specified CLSID. It returns E_NOINTERFACE.

I checked the registry and the CLSID is correct. The path of the called object dll is correct in registry and ThreadingModel is Apartment. In addition, the reference to the identifier of the interface is correct.

The newly created object context parameter is CLSCTX_INPROC_SERVER.

While this function call is working on one PC, it is not working on another. I tried to register the dll with regsvr32 again, but it has not solved the issue.

What could be the reason of the problem?

Upvotes: 0

Views: 718

Answers (1)

Soonts
Soonts

Reputation: 21956

Most probable cause — 32/64 bit incompatibility, i.e. you’re trying to create 32 bit in-process COM object in a 64 bit application, or vice versa. Note that regsvr32 is also platform-dependent, on Win64 there’s another one in C:\Windows\SysWOW64\regsvr32.exe for registering 32-bit COM servers on a 64-bit Windows.

Another possible cause — incompatible threading models. Read this for explanation.

Update: Another possible reason is that object internally might use some other COM object, and that dependent COM object isn’t registered, or is of a wrong version. Use SysInternals Process Monitor on the failing PC to see which files/registry keys your client app tries to open immediately before CreateInstance fails with E_NOINTERFACE. And/or use Process Explorer on the PC where it works, and see which DLLs are loaded as the result of that CreateInstance call.

Upvotes: 1

Related Questions