.net interface to COM server fails with 0x80080005

cominteropnet

I have a native c++ COM server that exposes COM interfaces. I can successfully use a native c++ client application to get and use the exposed interfaces from the server.

When I use a .net client with a reference to the server, I get the error:

Retrieving the COM class factory for component with CLSID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).

…even though the COM server starts and runs successfully (and only takes about 1 or 2 seconds to startup).

BUT I get the above error only when the server is registered as a local server. If I register the server as a windows service, the .net client can successfully get and use the interfaces just fine.

I'm doing all this as an admin on Windows 7 64-bit. The COM server is on the local machine.

I checked the thread below, but no answers were offered:
Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80080005

Spent a day and a half on this one so far…what could be the problem?

More information:
I've had this working with vs2005. I recently updated to vs2010 and am now running into this issue. I've tried building the .net client targeting frameworks 2.0, 3.5, and 4.0 with the same results.

Thanks

Best Answer

I was seeing this error when using a .net app running on x64 to try to connect to a 32 bit COM app. I was able to fix it easily by switching my .net app to x86 (32 bit).