Discussion:
Class Not Registered using MFC/ATL and COM with CoCreateInstance
(too old to reply)
MouthOfMadness
2006-01-13 21:23:01 UTC
Permalink
I written an ATL Service and a MFC Client where I'm using COM to communicate
between them.

i.e.
hr = CoCreateInstance (CLSID, NULL, CLSCTX_ALL, IID_IUknown, (void**)&pIunk);

In the MFC client, I'm trying to CoCreateInstance a CLSID from the ATL
Service, but receive Class Not Registered. If I start the ATL Service first
(as a local server) , I connect the MFC client just fine, but fails if I
register and start the ATL Server as a NT Service.

I've create a second test ATL Service and I connect the MFC client to the
second service without incidence, using CoCreateInstance.

I've done some wiffdiffs on both ATL Services, but they look ok and I've
also rebooted any changes.

Everything was wizard generated and I don't think I've commited any bloopers
as I'm fairly comfortable with ATL/MFC (10+ years).

I'd appreciate any insight?
Alexander Nickolov
2006-01-13 23:50:32 UTC
Permalink
Check the GUIDs in the RGS files. VC6 ATL wizard used to have
a bug mixing these up. I think it was fixed in VC 7.1, but checking
wouldn't hurt. They must match the coclass GUIDs in the IDL file.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: ***@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
Post by MouthOfMadness
I written an ATL Service and a MFC Client where I'm using COM to communicate
between them.
i.e.
hr = CoCreateInstance (CLSID, NULL, CLSCTX_ALL, IID_IUknown,
(void**)&pIunk);
In the MFC client, I'm trying to CoCreateInstance a CLSID from the ATL
Service, but receive Class Not Registered. If I start the ATL Service first
(as a local server) , I connect the MFC client just fine, but fails if I
register and start the ATL Server as a NT Service.
I've create a second test ATL Service and I connect the MFC client to the
second service without incidence, using CoCreateInstance.
I've done some wiffdiffs on both ATL Services, but they look ok and I've
also rebooted any changes.
Everything was wizard generated and I don't think I've commited any bloopers
as I'm fairly comfortable with ATL/MFC (10+ years).
I'd appreciate any insight?
MouthOfMadness
2006-01-16 23:36:04 UTC
Permalink
Thank you for replying Alexander.

I can remember this bug, but I don't think I've fallen victim to it as I can
successfully CoCreateInstance to the running instance (run it from a
different debugger or double click the exe and see it in taskmgr) and query
for the IID_MyInterface.

I will confirm the rgs file, but I can remember some cursory examination of
it and I though it checked out along with the MIDL generated .h & _i.c files.


I tried to follow the registration path using Ole/View but it keeps dying on
me when I open the tree. Perhaps I'll just do it the ol' fashion way and
trace throught he registry using regedit, but I don't think this is the error.

A co-worker suggested that perhaps I was missing something (like a DLL) on
startup and that caused a failure, but this doesn't quite hold true as I have
the partial success I mentioned earlier.

Any other suggestions? At this point, I think my only recourse is to dump
weeks & weeks of development and restart.
Post by Alexander Nickolov
Check the GUIDs in the RGS files. VC6 ATL wizard used to have
a bug mixing these up. I think it was fixed in VC 7.1, but checking
wouldn't hurt. They must match the coclass GUIDs in the IDL file.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
Post by MouthOfMadness
I written an ATL Service and a MFC Client where I'm using COM to communicate
between them.
i.e.
hr = CoCreateInstance (CLSID, NULL, CLSCTX_ALL, IID_IUknown,
(void**)&pIunk);
In the MFC client, I'm trying to CoCreateInstance a CLSID from the ATL
Service, but receive Class Not Registered. If I start the ATL Service first
(as a local server) , I connect the MFC client just fine, but fails if I
register and start the ATL Server as a NT Service.
I've create a second test ATL Service and I connect the MFC client to the
second service without incidence, using CoCreateInstance.
I've done some wiffdiffs on both ATL Services, but they look ok and I've
also rebooted any changes.
Everything was wizard generated and I don't think I've commited any bloopers
as I'm fairly comfortable with ATL/MFC (10+ years).
I'd appreciate any insight?
Alexander Nickolov
2006-01-17 03:30:12 UTC
Permalink
Next I'd check the DCOMCnfg registration of your service, what
account it runs under, who can launch and access it, etc. Sorry,
nothing obvious at this point... (I presume you've looked into
possible marshaling issues already.)
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: ***@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
Post by MouthOfMadness
Thank you for replying Alexander.
I can remember this bug, but I don't think I've fallen victim to it as I can
successfully CoCreateInstance to the running instance (run it from a
different debugger or double click the exe and see it in taskmgr) and query
for the IID_MyInterface.
I will confirm the rgs file, but I can remember some cursory examination of
it and I though it checked out along with the MIDL generated .h & _i.c files.
I tried to follow the registration path using Ole/View but it keeps dying on
me when I open the tree. Perhaps I'll just do it the ol' fashion way and
trace throught he registry using regedit, but I don't think this is the error.
A co-worker suggested that perhaps I was missing something (like a DLL) on
startup and that caused a failure, but this doesn't quite hold true as I have
the partial success I mentioned earlier.
Any other suggestions? At this point, I think my only recourse is to dump
weeks & weeks of development and restart.
Post by Alexander Nickolov
Check the GUIDs in the RGS files. VC6 ATL wizard used to have
a bug mixing these up. I think it was fixed in VC 7.1, but checking
wouldn't hurt. They must match the coclass GUIDs in the IDL file.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
Post by MouthOfMadness
I written an ATL Service and a MFC Client where I'm using COM to communicate
between them.
i.e.
hr = CoCreateInstance (CLSID, NULL, CLSCTX_ALL, IID_IUknown, (void**)&pIunk);
In the MFC client, I'm trying to CoCreateInstance a CLSID from the ATL
Service, but receive Class Not Registered. If I start the ATL Service first
(as a local server) , I connect the MFC client just fine, but fails if I
register and start the ATL Server as a NT Service.
I've create a second test ATL Service and I connect the MFC client to the
second service without incidence, using CoCreateInstance.
I've done some wiffdiffs on both ATL Services, but they look ok and I've
also rebooted any changes.
Everything was wizard generated and I don't think I've commited any bloopers
as I'm fairly comfortable with ATL/MFC (10+ years).
I'd appreciate any insight?
MouthOfMadness
2006-01-17 12:27:04 UTC
Permalink
Before I wrote, I did check dcomcnfg and compared it to a working entry and
they appeared identifical.

In terms of marshaling issues I'll need a hint or two since I'm not sure
what to look for as I'm thinking the IUnknown pointer shouldn't be having
mashaling issues on the CoCreate.

I have made my share of marshaling errors and can usually spot them, i.e.
using a worker thread to call back on a cache of interface's connection
points without marshaling the connection point (when firing the connection
points they don't check the hresult from the wizard generated code)

Any chance that the name I've chosen for the module doesn't work? I'll try
adding a second interface and removing the first interface from the module's
map and then see if I still have instantiation issues

I've tried isolating the ATL COM class from its module in my debugging, but
this should tell the tale.
Post by Alexander Nickolov
Next I'd check the DCOMCnfg registration of your service, what
account it runs under, who can launch and access it, etc. Sorry,
nothing obvious at this point... (I presume you've looked into
possible marshaling issues already.)
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
Post by MouthOfMadness
Thank you for replying Alexander.
I can remember this bug, but I don't think I've fallen victim to it as I can
successfully CoCreateInstance to the running instance (run it from a
different debugger or double click the exe and see it in taskmgr) and query
for the IID_MyInterface.
I will confirm the rgs file, but I can remember some cursory examination of
it and I though it checked out along with the MIDL generated .h & _i.c files.
I tried to follow the registration path using Ole/View but it keeps dying on
me when I open the tree. Perhaps I'll just do it the ol' fashion way and
trace throught he registry using regedit, but I don't think this is the error.
A co-worker suggested that perhaps I was missing something (like a DLL) on
startup and that caused a failure, but this doesn't quite hold true as I have
the partial success I mentioned earlier.
Any other suggestions? At this point, I think my only recourse is to dump
weeks & weeks of development and restart.
Post by Alexander Nickolov
Check the GUIDs in the RGS files. VC6 ATL wizard used to have
a bug mixing these up. I think it was fixed in VC 7.1, but checking
wouldn't hurt. They must match the coclass GUIDs in the IDL file.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
Post by MouthOfMadness
I written an ATL Service and a MFC Client where I'm using COM to communicate
between them.
i.e.
hr = CoCreateInstance (CLSID, NULL, CLSCTX_ALL, IID_IUknown, (void**)&pIunk);
In the MFC client, I'm trying to CoCreateInstance a CLSID from the ATL
Service, but receive Class Not Registered. If I start the ATL Service first
(as a local server) , I connect the MFC client just fine, but fails if I
register and start the ATL Server as a NT Service.
I've create a second test ATL Service and I connect the MFC client to the
second service without incidence, using CoCreateInstance.
I've done some wiffdiffs on both ATL Services, but they look ok and I've
also rebooted any changes.
Everything was wizard generated and I don't think I've commited any bloopers
as I'm fairly comfortable with ATL/MFC (10+ years).
I'd appreciate any insight?
MouthOfMadness
2006-01-17 17:00:03 UTC
Permalink
The test of adding a second interface and removing the contents of the first
interface resulted in Class not registered error as well.

At this point, I'm more tempted to believe that using the word Module, i.e.
SpellingModule as part of the ATLServer name is resulting in this error.

Recall that the ATL wizard used to add the comment You can derive a class
from the CServiceModule but do not change the name _Module (I no longer see
this comment in the static declaration of the app)

I suspect that deep down in the COM or ATL libraries there may be a bug when
using the name Module as part of your ATL server.
Post by Alexander Nickolov
Next I'd check the DCOMCnfg registration of your service, what
account it runs under, who can launch and access it, etc. Sorry,
nothing obvious at this point... (I presume you've looked into
possible marshaling issues already.)
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
Post by MouthOfMadness
Thank you for replying Alexander.
I can remember this bug, but I don't think I've fallen victim to it as I can
successfully CoCreateInstance to the running instance (run it from a
different debugger or double click the exe and see it in taskmgr) and query
for the IID_MyInterface.
I will confirm the rgs file, but I can remember some cursory examination of
it and I though it checked out along with the MIDL generated .h & _i.c files.
I tried to follow the registration path using Ole/View but it keeps dying on
me when I open the tree. Perhaps I'll just do it the ol' fashion way and
trace throught he registry using regedit, but I don't think this is the error.
A co-worker suggested that perhaps I was missing something (like a DLL) on
startup and that caused a failure, but this doesn't quite hold true as I have
the partial success I mentioned earlier.
Any other suggestions? At this point, I think my only recourse is to dump
weeks & weeks of development and restart.
Post by Alexander Nickolov
Check the GUIDs in the RGS files. VC6 ATL wizard used to have
a bug mixing these up. I think it was fixed in VC 7.1, but checking
wouldn't hurt. They must match the coclass GUIDs in the IDL file.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
Post by MouthOfMadness
I written an ATL Service and a MFC Client where I'm using COM to communicate
between them.
i.e.
hr = CoCreateInstance (CLSID, NULL, CLSCTX_ALL, IID_IUknown, (void**)&pIunk);
In the MFC client, I'm trying to CoCreateInstance a CLSID from the ATL
Service, but receive Class Not Registered. If I start the ATL Service first
(as a local server) , I connect the MFC client just fine, but fails if I
register and start the ATL Server as a NT Service.
I've create a second test ATL Service and I connect the MFC client to the
second service without incidence, using CoCreateInstance.
I've done some wiffdiffs on both ATL Services, but they look ok and I've
also rebooted any changes.
Everything was wizard generated and I don't think I've commited any bloopers
as I'm fairly comfortable with ATL/MFC (10+ years).
I'd appreciate any insight?
Loading...