|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Re: CoMarshalInterThreadInterfaceInStream and WinXP
From: Chuck Bell (chuckb
MICROSOFT.COM)
Date: Thu Jul 28 2005 - 13:48:21 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Palaniappa,
The error code is most likely being passed along and your snippet of
code has nothing to do with the error other than it happen to be passed
the error code.
WindowsXP has much stricter security settings than NT 4.0 or even W2K
did. One of these settings is most likely causing the failure.
Changing threading model from apartment to free does NOT mean all thread
marshalling is automatically handled by COM. It simply tells COM that
your application will take care of ALL threading issues, so don't bother
marshalling between threads.
NT4 was the first OS to ship with GlobalInterfaceTable support. The
GlobalInterfaceTable can provide better perf if you need the same
interface in more than one other apartment. However it is using the
same method of marshalling, and will most likely fail with the same
error code.
Casting interfaces is a bad idea but that's how the COM APIs are
provided.
-Chuck
-----Original Message-----
From: Distributed COM-Based Code [mailto:DCOM
DISCUSS.MICROSOFT.COM] On
Behalf Of Yavor Stoyanov
Sent: Thursday, July 28, 2005 9:38 AM
To: DCOM
DISCUSS.MICROSOFT.COM
Subject: Re: CoMarshalInterThreadInterfaceInStream and WinXP
Hello Palaniappa,
Few comments & suggestions:
- From error code "Castrofic failure" and code provided I'm assuming
you're using apartment-threaded COM model, right? If you don't have
requirement to use apartment threaded model, you could CoInitializeEx to
multithreaded.
After that all thread marshalling is automatically handled by COM.
- Casting interfaces is a bad idea. You need to QueryInterface:
CComPtr<IUnknown> sp = m_vec.GetAt( nConnectionIndex );
CComPtr<IDispatch> spDispatch; hr = sp->QueryInterface(spDispatch);
- instead of using CoMarshalInterThreadInterfaceInStream, try with
GlobalInterfaceTable - registering interface in GIT you get a cookie,
then from other thread you could query GIT for that interface. As I
remember GlobalInterfaceTable wasn't available in NT4, so that might be
a problem if you need to support it.
HTH and good luck,
-Yavor
----- Original Message -----
From: "Palaniappa Babu" <palaniappababu
HOTMAIL.COM>
To: <DCOM
DISCUSS.MICROSOFT.COM>
Sent: Tuesday, July 26, 2005 6:02 PM
Subject: CoMarshalInterThreadInterfaceInStream and WinXP
Hi
We have created a multi-threaded application which works without any
problems on
a NT-4.0 Workstation.
When I try to run the same application in Windows XP, I get an error in
a
call
to CoMarshalInterThreadInterfaceInStream which returns -2147418113.
This problem can be duplicated with different machines running Windows
XP.
I have provided a snippet of the code below where the call fails in
Windows
XP
//----------------------------------------------------------------------
----------------------------
CComPtr<IUnknown> sp = m_vec.GetAt( nConnectionIndex );
IDispatch* pDispatch = reinterpret_cast<IDispatch*>( sp.p );
CComPtr<IDispatch> piDispatch;
LPSTREAM m_pStream;
//hResPutStream returns -2147418113
HRESULT hResPutStream =
CoMarshalInterThreadInterfaceInStream(
IID_IDispatch,pDispatch,&m_pStream );
HRESULT hResGetStream = CoGetInterfaceAndReleaseStream(
m_pStream,IID_IDispatch,reinterpret_cast<void**>( &piDispatch ) );
//----------------------------------------------------------------------
----------------------------
Environment - Windows-XP,SP-2,Visual Studio 6.0,SP-4,ATL-3.0
Should I be doing anything different in Windows XP?
----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.html
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:DCOM-signoff-request
DISCUSS.MICROSOFT.COM
----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.html
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:DCOM-signoff-request
DISCUSS.MICROSOFT.COM
----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.html
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:DCOM-signoff-request
DISCUSS.MICROSOFT.COM
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]