|
-
May 25th, 2007, 04:03 PM
#1
COM Registration Question
I have an ATL COM Exe with many interfaces. Every time I try to start my COM server I get an error.
If I use this method:
Code:
CComPtr<IContextManager> icm;
hr = icm.CoCreateInstance(__uuidof(CContextManager));
My HRESULT value is 0x80080005 (Server execution failed)
If I use this method:
Code:
IContextManager *icm;
hr = CoCreateInstance(CLSID_CContextManager, NULL, CLSCTX_INPROC_SERVER, IID_IContextManager, reinterpret_cast<void**>(&icm));
My HRESULT value is 0x80040154 (Class not registered)
I have tried running regsvr32 with the exe and I don't receivie any errors, but I still get the above errors when attempting to run the executable. Also, I do see the values stored in the registry correctly so I am confused as to what might be going on.
Any help is greatly appreciated!
Thank you.
-
May 25th, 2007, 04:31 PM
#2
Re: COM Registration Question
Is that all your calling application does ? I am trying to see if there are other variables that could be contributing the problem. Would be good if you write a very very simple application which only does this CoCreateInstance.
BTW, what OS ? Also, have you made sure you called CoInitialize ( I doubt, since you would see some other error in that case ).
Also, you say it is a COM exe. This would be registered using [exename].exe /RegServer.
regsvr32 is used for dll components. Please clarify
-
May 25th, 2007, 09:05 PM
#3
Re: COM Registration Question
OS: Windows XP SP2 (32-bit)
I guess I should be a little more clear at where this is happening. Initially I tried to do this in a simple client test application, but that was failing so I tried to do this call within the actual exe. It throws these errors in both cases.
Possibly I need to start over with my project. I created this project as a standard ATL server and added simple ATL com objects through the wizard within Visual Studio 2005. After I was done I manually modified some of the GUID's. I assume this is where my problem lies, but I wasn't sure.
Thanks for your help!
-
May 26th, 2007, 03:16 AM
#4
Re: COM Registration Question
 Originally Posted by drm15
I have an ATL COM Exe with many interfaces. Every time I try to start my COM server I get an error.
. . .
I have tried running regsvr32 with the exe and I don't receivie any errors, but I still get the above errors when attempting to run the executable. Also, I do see the values stored in the registry correctly so I am confused as to what might be going on.
For your information, regsvr32 registers only in-proc (.dll) COM servers. COM out-proc (.exe) server gets registered absolutely different way:
<your_COM_server>.exe /regserver
Best regards,
Igor
-
May 26th, 2007, 04:20 AM
#5
Re: COM Registration Question
Don't forget to call CoInitialize and CoUninitialize when using COM.
Oh, I see kirants had also mentioned this.
-
May 29th, 2007, 07:27 AM
#6
Re: COM Registration Question
To answer both questions with one reply:
"<your_COM_server>.exe /regserver " - This is what I was doing, but it does not produce any errors.
and
Yes, I had called CoInitialize and CoUninitialize, but I didn't post it in my original code.
I am still curious if changing the GUID's has anything to do with my problem.
Thanks again for your help.
-
May 29th, 2007, 07:44 AM
#7
Re: COM Registration Question
 Originally Posted by drm15
After I was done I manually modified some of the GUID's. I assume this is where my problem lies, but I wasn't sure.
Yes, this does not sound like a good idea to me.
Why did you manually modify GUIDs?
-
May 29th, 2007, 07:48 AM
#8
Re: COM Registration Question
A specification document I was given before I started coding contained interface names and their associated GUID's. The fine print stated that GUID's could be unique, but that the interface names had to match the specifications.
I missed the fine print until after I read the spec the second time. Lesson learned!
-
May 29th, 2007, 07:51 AM
#9
Re: COM Registration Question
The GUIDs are guaranteed to be unique when created by the Wizard (that directly or indirectly uses API CoCreateGuid to generate them). The moment you modify a GUID, not only is it not guaranteed to be unique but you would need to modify relevant entries in all the places where the Wizard used the GUIDs. Stuff probably stopped working because of an inconsistency.
Things would probably be a lot faster if you just added a new "Simple ATL Object" and used it as your COM Class henceforth (without editing any GUID of course... ).
Last edited by Siddhartha; May 29th, 2007 at 08:14 AM.
-
May 30th, 2007, 11:50 AM
#10
Re: COM Registration Question
Now I am really confused and stuck - can anyone provide an example or tutorial for how to make an ATL exe with interfaces? I have steped through the basic examples and I cannot figure out how to get my exe to stay running and the interfaces to be recognized.
Below is my code for Run:
Code:
HRESULT Run(int nShowCmd = SW_HIDE)
{
HRESULT hr;
HANDLE hnd;
LONG lockNum;
DWORD dwd;
hr = CMayoCCOWModule::RegisterServer(TRUE);
hr = CMayoCCOWModule::RegisterClassObjects(CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE);
hr = CMayoCCOWModule::RegisterAppId();
lockNum = CMayoCCOWModule::Lock();
hnd = CMayoCCOWModule::StartMonitor();
// CMayoCCOWModule::Run(nShowCmd);
CMayoCCOWModule::RunMessageLoop();
// CMayoCCOWModule::MonitorShutdown();
CloseHandle(hnd);
lockNum = CMayoCCOWModule::Unlock();
return S_OK;
}
I guess I am confused about registration? HRESULT is S_OK throughout this code - is this correct? I need the exe to stay running because it has many other functions then just responding to interface requests.
Thank you in advance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|