GIT GetInterfaceFromGlobal returns E_UNEXPECTED with reg-free COM

261 views
Skip to first unread message

gscott2112

unread,
Oct 26, 2007, 11:54:01 AM10/26/07
to
I'm trying to developer a reg-free COM object using side-by-side assemblies,
but I am having problems with the GlobalInterfaceTable when using the object
in a reg-free environment.

My object is failing to send out events. I am using the ATLCPImplMT
connection point implementation which stores the connections in the
GlobalInterfaceTable. If I register my object using regsvr32 everything
works normally. Likewise if I use that standard ATL IConnectionPointImpl
everything works normally.

When I try to use the GIT base ATLCPIMplMT, the GIT GetInterfaceFromGlobal
is always returning E_UNEXPECTED.

Any ideas what is causing this?

Alexander Nickolov

unread,
Oct 28, 2007, 2:16:47 PM10/28/07
to
You need to register marshaling support for your interfaces.
You do so by:

LoadLibrary for your P/S DLL
GetProcAddress for DllGetClassObject
Call DllGetClassObject for each IID
CoRegisterClassObject for each IID
CoRegisterPSClsid for each IID

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================

"gscott2112" <gscot...@discussions.microsoft.com> wrote in message
news:141BB1DF-C660-4141...@microsoft.com...

gscott2112

unread,
Nov 1, 2007, 2:08:02 PM11/1/07
to
Interesting. I've never used CoRegisterClassObject or CoRegisterPSClsid
before.
I'll see if I can find some examples of this.

In the meantime, we modified ATLCPImplMT.h to store IUnknown references in
the GIT instead of the IID of the event interface. The implementation is
using IUnknown in it's vector anyways, and this seems to work well.

gscott2112

unread,
Nov 1, 2007, 2:27:01 PM11/1/07
to
Alexander,

Since we are trying to use reg-free COM, could I in theory use this method
to register all my COM objects during application startup as opposed to using
application manifests and embedded dll manifests?

Alexander Nickolov

unread,
Nov 2, 2007, 12:54:21 PM11/2/07
to
Well, that's what we do and it works for us. E.g. it works in
practice, I'll leave the theoretical part to you... :)

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================

"gscott2112" <gscot...@discussions.microsoft.com> wrote in message

news:E7712A3B-A3D7-4834...@microsoft.com...

ofer shor

unread,
Nov 22, 2010, 5:31:17 AM11/22/10
to
I had the same problem when working with a Connection point site from IE . IE is dynamicly create a site for my events and advise it to my COM object.the register/read operations of this site on the GIT fail inside the ATLCPImplMT.h file, in order to solve the problem i have change the code in two places:

Advise function:
m_pGIT->RegisterInterfaceInGlobal(p,iid,&dwGITCookie)

to

m_pGIT->RegisterInterfaceInGlobal(p,__uuidof(IDispatch), &dwGITCookie);

and

GetInterfaceAt function:

m_pGIT->GetInterfaceFromGlobal(dwGITCookie,iid, reinterpret_cast<void **>(&pUnk));

to

m_pGIT->GetInterfaceFromGlobal(dwGITCookie,__uuidof(IDispatch), reinterpret_cast<void **>(&pUnk));

In any case this solution should work for all cases due to the fact that the connection point is Disp Interface.

Hope this help to anyone that work with reg-free COM on multithreaded cases.


>> On Sunday, October 28, 2007 2:16 PM Alexander Nickolov wrote:

>> You need to register marshaling support for your interfaces.
>> You do so by:
>>
>> LoadLibrary for your P/S DLL
>> GetProcAddress for DllGetClassObject
>> Call DllGetClassObject for each IID
>> CoRegisterClassObject for each IID
>> CoRegisterPSClsid for each IID
>>
>> --
>> =====================================
>> Alexander Nickolov
>> Microsoft MVP [VC], MCSD
>> email: agnic...@mvps.org
>> MVP VC FAQ: http://vcfaq.mvps.org
>> =====================================
>>
>> "gscott2112" <gscot...@discussions.microsoft.com> wrote in message
>> news:141BB1DF-C660-4141...@microsoft.com...


>>> On Thursday, November 01, 2007 2:08 PM gscott211 wrote:

>>> Interesting. I've never used CoRegisterClassObject or CoRegisterPSClsid
>>> before.
>>> I'll see if I can find some examples of this.
>>>
>>> In the meantime, we modified ATLCPImplMT.h to store IUnknown references in
>>> the GIT instead of the IID of the event interface. The implementation is
>>> using IUnknown in it's vector anyways, and this seems to work well.
>>>
>>> "Alexander Nickolov" wrote:


>>>> On Thursday, November 01, 2007 2:27 PM gscott211 wrote:

>>>> Alexander,
>>>>
>>>> Since we are trying to use reg-free COM, could I in theory use this method
>>>> to register all my COM objects during application startup as opposed to using
>>>> application manifests and embedded dll manifests?
>>>>
>>>> "Alexander Nickolov" wrote:


>>>>> On Friday, November 02, 2007 12:54 PM Alexander Nickolov wrote:

>>>>> Well, that's what we do and it works for us. E.g. it works in
>>>>> practice, I'll leave the theoretical part to you... :)
>>>>>
>>>>> --
>>>>> =====================================
>>>>> Alexander Nickolov
>>>>> Microsoft MVP [VC], MCSD
>>>>> email: agnic...@mvps.org
>>>>> MVP VC FAQ: http://vcfaq.mvps.org
>>>>> =====================================
>>>>>
>>>>> "gscott2112" <gscot...@discussions.microsoft.com> wrote in message
>>>>> news:E7712A3B-A3D7-4834...@microsoft.com...


>>>>> Submitted via EggHeadCafe
>>>>> Client-server autodiscovery in C# and UDP Sockets
>>>>> http://www.eggheadcafe.com/tutorials/aspnet/9da74d3d-7415-4dfe-984e-2a5db900bdb2/clientserver-autodiscovery-in-c-and-udp-sockets.aspx

Reply all
Reply to author
Forward
0 new messages