Re: REPOST with Correct Address: SAFEARRAYs of interfaces other than IDispatch/IUnknown
From: M Thomas (Mark.C.Thomas_at_newsgroup.nospam)
Date: 03/16/05
- Next message: Henrik K: "problems implementing IAMWstDecoder COM interface in dotnet"
- Previous message: SB: "Re: string passing from c# to unmanaged c++: unicode?"
- In reply to: Peter Huang: "Re: REPOST with Correct Address: SAFEARRAYs of interfaces other than IDispatch/IUnknown"
- Next in thread: Peter Huang: "Re: REPOST with Correct Address: SAFEARRAYs of interfaces other than IDispatch/IUnknown"
- Reply: Peter Huang: "Re: REPOST with Correct Address: SAFEARRAYs of interfaces other than IDispatch/IUnknown"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 16 Mar 2005 11:43:25 -0000
Hi Peter
Thanks for getting back to me. When will this bug be fixed? I thought that
the transition from COM to .NET was almost meant to be seamless and I don't
think that it's such a strange thing to want to marshal a safearray of
interfaces. Why is it not supported?
Consider the following:-
interface IProblemParameter : IUnknown
{
HRESULT CallMe();
}
interface IProblemParameterGetter : IUnknown
{
HRESULT GetProblemParameters([out, retval] SAFEARRAY(IProblemParameter*)*
outArray);
}
Create a type library, import the type library to an interop assembly.
Then, implement the two interfaces in C#. Regasm it to be able to create it
as a COM object in C++. Now, on calling GetProblemParameters on
IProblemParameterGetter interface, all C++ sees is IID_IUnknown as the types
of the interfaces as this is the description in the safearray. However, if
we QI each of these interfaces for IUnknown, we get a different pointer (in
my experience 4 bytes different address as it's really the interface pointer
of the CCW of IProblemParameter). Now, this breaks the rules of COM.
Since in the above case, you are marshaling the interface pointer that i
requested but telling me it's IUnknown by the GUID, then I can only assume
that you have the type information there and then when you put the interface
pointers in to the safearray. So I can only assume that it should be easy
for you to get hold of the GUID to correctly set in the safearray and
provide a totally generic mechanism for all to use. Is this not the case?
Or, is it a problem for the users of COM interop to have to go to the
efforts of writing custom marshalers for each specific case. Like, for
example, I would have to write a custom marshaler for every single safearray
of different interface pointer types that I wanted to marshal when Microsoft
must be able to do it generically.
At our company, we use Microsoft technologies extensively and have many COM
objects and have eagerly adopted .NET technology and therefore have many
type libraries that we'd like to provide implementations for in .NET.
However, given this simple problem I've not got the greatest confidence that
this is achievable without much effort.
Kind regards
Mark
SunGard Trading & Risk Systems
""Peter Huang" [MSFT]" <v-phuang@online.microsoft.com> wrote in message
news:%236sAIYTKFHA.3600@TK2MSFTNGXA02.phx.gbl...
> Hi
>
> I am sorry for delay responding.
> Based on the research of product team, I think actually ¨C it doesnĄ¯t
> look
> the CLR supports the SafeArray IID.
>
> Best regards,
>
> Peter Huang
> Microsoft Online Partner Support
>
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
- Next message: Henrik K: "problems implementing IAMWstDecoder COM interface in dotnet"
- Previous message: SB: "Re: string passing from c# to unmanaged c++: unicode?"
- In reply to: Peter Huang: "Re: REPOST with Correct Address: SAFEARRAYs of interfaces other than IDispatch/IUnknown"
- Next in thread: Peter Huang: "Re: REPOST with Correct Address: SAFEARRAYs of interfaces other than IDispatch/IUnknown"
- Reply: Peter Huang: "Re: REPOST with Correct Address: SAFEARRAYs of interfaces other than IDispatch/IUnknown"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|