Re: Raising events quickly from DLL server crashes the client
 
Following the thread suggest to me:
http://groups.google.com/group/microsoft.public.vc.atl/browse_frm/thread/e564bae8f5c3497d
I would ask this...
My CComDynamicUnkArray_GIT::Add(IUnknown* pUnk) is the same as the one
written by Michael Lindig in his article.
The value returned CComDynamicUnkArray::Add, which is the array index,
is used to store the cookie retreived from the GIT-
RegisterInterfaceInGlobal into a map<DWORD,DWORD> where the key is
that index.
Now, I think the problem came in the CComDynamicUnkArray_GIT::GetAt in
the way explained by Igor in the thread he has posted before.
So, since the CComDynamicUnkArray::Add returns the array position,
I've thought to solve the problem simply use the nIndex as it is: the
array index
CComPtr<IUnknown> GetAt(int nIndex)
{
  if( nIndex == 0 ) return NULL;
  if( CookieMap.find( nIndex ) == CookieMap.end() )
  {
    return NULL;
  }
  if( GIT != NULL )
  {
    CComPtr<IUnknown>   ppv;
    HRESULT hr = GIT->GetInterfaceFromGlobal(
                      CookieMap[nIndex],              //Cookie
identifying the desired global
                                                        //interface
and its object
                      __uuidof(IUnknown),               //IID of the
registered global interface
                      reinterpret_cast< void** >(&ppv)  //Indirect
pointer to the desired interface
                      );
    if( hr == S_OK )
    {
        return ppv;
    }
  }
  return NULL;
}
When I run the code at "GIT->GetInterfaceFromGlobal" I get the error:
0x800401F0 "CoInitialize has not been called"
But, CoInitialize[Ex] is not called by the client (in my case is VB6)?
Where I should call it in my DLL?
Could someone give me some suggestion?
Thanks!
Daniele.