CoCreateInstance returns E_NOINTERFACE from COM service (service restart fixes it)

Kwesi Ackon
Kwesi Ackon used Ask the Experts™
on
CoCreateInstance returns E_NOINTERFACE from COM service (service restart fixes it)

Once in a while, my COM ATL server service will get into a state whereby my C++ client application (also a windows COM ATL service) will start failing to create a COM object due to a E_NOINTERFACE error. But when I connect to this same COM server via a C++ client application (console) it is able to connect to it. Also, when I restart my COM ATL server service, my COM ATL service (client) is able to connect to the server.

I've have attached a file (sensitive information), explaining the problem more in depth.COMATLServiceIssue.docx

edit by Scott Fell. EE Moderator - adding content from word file
Once in a while, my COM ATL server service will get into a state whereby my C++ client application (also a windows COM ATL service) will start failing to create a COM object due to a E_NOINTERFACE error. But when I connect to this same COM server via a C++ client application (console) it is able to connect to it. Also, when I restart my COM ATL server service, my COM ATL service (client) is able to connect to the server.

This is an out-of-process setup.

The Server, is, namely, VafDbService:

The Client, is, namely, VacDocAutoSetup:

Setup in production as below:

Services
Capture.JPGCode in VacDocAuto Service whereby I get the E_NOINTERFACE error, after being able to obtain a COM handle to VafDBService for most of the day.
COSERVERINFO cSI = {0};
cSI.dwReserved1 = 0;
cSI.dwReserved2 = 0;
cSI.pAuthInfo = NULL;
cSI.pwszName = (wchar_t*)m_bsDBServiceServer;

MULTI_QI MQI[1];
MQI[0].pIID = &IID_ICommonDB;
MQI[0].pItf = NULL;
MQI[0].hr = 0;

DWORD dwMQICount = 1;

if(hr = CoCreateInstanceEx(
	CLSID_CommonDB
	, NULL
	, CLSCTX_SERVER
	, &cSI
	, dwMQICount
	, &MQI[0]))

Open in new window

#CoCreateInstanceEx fails with E_NOINTERFACE after a while.
Being a new developer in the team, my hutch is that the issue is with production releases of VafDBService, and COM is not marshalled properly between the services, but I don’t understand why it works for a certain period during the day, and all of a sudden starts failing.
Below is the properties setup of VafDBService:

Capture.JPGDuring  production of releases VafDBservice:
1)      VafDBService is stopped
2)      The new VafDBService.exe is copied over the old

Capture.JPGI believe the problem may be not registering the .tlb file that goes with the new production release of VafDBService, but it still doesn’t explain why it works for a certain period during the day, and all of a sudden starts failing.  And more importantly, how I’m able to connect to VafDBService from a console C++ test Application, while I’m getting this failure.
Very critical production issue, so any help would be welcomed. Thanks in advance.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
did you stop the C++ Client Service before updating the VafDBService? if yes, did you give the new VafDBService some time to be ready for accepting new connections?

note, a service is installed and normally is not dependent on a executable file while running. so if you didn't stop the service correctly or didn't wait before it was unloaded, the new service might be loaded but could be unable to accept connetcions. same applies for the c++ client which might have no code for reconnect after failure.

Sara

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial