>But it doesn't compile and gives the following error
>C2682: cannot use __try_cast to convert from 'LPSTREAM' to
>'System::Runtime::InteropServices::UCOMIStream __gc *'
Instead of using __try_cast directly, try calling
Marshal::GetObjectForIUnknown, pass in the LPSTREAM (cast to an
IntPtr) and cast the resulting RCW object to UCOMIStream.
Mattias

Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
PRASENJIT BURMAN - 22 Feb 2006 06:35 GMT
Thanks it worked.
I had another doubt since GetObjectForIUnknown calls AddRef on the COM
interface pointer Do I need to call Release on the underlying interface
pointer before calling on ReleaseCOMObject() on the RCW object. Since
references of the RCW to the COM object is maintained by the runtime while
that of the COM interface is maintained seperately.
Prasen
Mattias Sjögren - 22 Feb 2006 18:53 GMT
>Do I need to call Release on the underlying interface
>pointer before calling on ReleaseCOMObject() on the RCW object.
No you don't, it will be taken care of when you call ReleaseComObject
or when the RCW is finalized.
Mattias

Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.