|
|
|
date: Thu, 20 Mar 2008 00:12:16 -0700 (PDT),
group: microsoft.public.platformsdk.com_ole
back
Get over fatal error 0x8002802b
I search through all groups for an COM error 0x8002802b without any
similar case. Now I've got over my problem, but I still don't know
why. I would like to share my case so that if anyone knows why this
got happen please tell me . I will be very appriciate.
The environment : windows 2003 server SP2.
There are two services. A and B. one in proc server C.
After A is started, A creates a thread to monitor something. A will
call B and C when something changes. At first, I test it in my
computer which is windows xp, it seems ok. But when I deploy them in
the target machine which is Windows 2003 server, I got 0x8002802B
errors when creating both B and C
CComPtr<INotifyEquipment> pNotify;
hr = pNotify.CoCreateInstance(progID);
if(FAILED(hr))
{
logger.Error(_T("Failed to create Object; ProgID=%s; Error Info: 0x
%x"), (TCHAR*)progID, hr);
_com_issue_error(hr);
}
It failed when CreateInstance.
I checked the whole source codes and found in the very beginning of
the thread, there was a call :
HRESULT hr = CoInitialize(NULL);
I also noticed in Registry, C's ThreadingModel is free. So I think I
mighe be some inconsistant with threading model.
I changed the call of CoInitialize to CoInitializeEx(NULL,
COINIT_MULTITHREADED); Then it worked to C. Unfortunately, the calling
to B was still an error.
I added ThreadingModel Free to B in registry. But it didn't work.
When I was wandering the source code of B to try to find something, I
suddenly found the definition of B:
// CEquipmentChange
class ATL_NO_VTABLE CEquipmentChange :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CEquipmentChange, &CLSID_NotifyEquipment>,
public ISupportErrorInfo,
public IDispatchImpl<INotifyEquipment, &IID_INotifyEquipment,
&LIBID_RTDBCORELib>
{
....
}
See, it derives from CComSingleThreadModel rather than
CComMultiThreadModel. I had a sence this was the reason, so I modified
it without regarding to whether it should be SingleThreadModel or
MultithreadModel...
I problem was solve as I guessed.
But I still have no idea about why this got happen? And why can't I
use SingleThreadModel? Service to Service, must be multithread?
I
date: Thu, 20 Mar 2008 00:12:16 -0700 (PDT)
author: HL
|
|