Re: SAFEARRAY(Interface)



Hello Brian,

thanks for jumping in.


This method definition is clearly not automation-compliant. So it means that a custom proxy-stub must be generated by the MIDL
compiler.

Out of the box, if you try to define the above COM interface method, the MIDL compiler give a warning message:

MIDL2456: SAFEARRAY(interface pointer) doesn't work using midl generated proxy.

I haven't explored this to any degree, but I'm sure this is an important warning: the proxy that is automatically generated won't
handle this correctly. This is really an indication that the MIDL compiler has reached its limits in implementation.

If you have any control over the definition of this method, obviously I highly recommend that you change this to something that
can be meaningfully marshaled. This could be a conformant array of interfaces (if using a proxy-stub) or a SAFEARRAY of IUnknown
pointers (if you want to be automation-compliant).

However, I'm guessing that this is a COM object that was developed by someone else and that you have no control over the method's
signature. If so, I'm speculating that this COM object's interface was designed not to be marshaled at all, and therefore the COM
object must live in the same apartment as its client. You may be having trouble simply because you are violating this assumption
on the author's part.

The interface we are accessing is a dual interface. Calling the method using
IDispatch doesn't work in our environment due to limitations that are beyond
our control. Calling the method from Visual Basic works perfectly. I assume
that VB reads the type library and properly wraps the parameter. What I
don't know is, if VB calls the method directly or if it uses IDispatch. The
server resides in another process, so marshalling does take place.


It's difficult to comment much more, because you have provided so little information. It would be helpful if you told us what
language you are using on the client side, what apartment the client is running in, and what threading model is defined by the COM
object.

I'll be back with more details.

Best regards,

Michael


.



Relevant Pages

  • Re: MIDL file query
    ... If/when I get my RPC to work with the MIDL V6 compiler output, ... This no longer works by default with XP SP2, so I need to update as I don't want to ask my users to allow unauthenticated RPC. ... The rpc headers supplied with my compiler show different parameters from those in the SDK, so I am trying to use the SDK headers and libs instead of those supplied with the compiler. ...
    (microsoft.public.vc.language)
  • Re: C# Interface methods gets wrong prototype when using COM interop
    ... Even though my problem isn't related to the MIDL compiler, ... Mattias Sjögren skrev: ... BUG: MIDL Changes the Case of Identifier in Generated Type Library ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: IDL to C#?
    ... but many attributes used in the oleidl.idl cant be parsed be ... > MIDL and TlbImp is the way to go. ... > interface declarations directly in C# instead. ...
    (microsoft.public.dotnet.languages.csharp)
  • Benutzung von Datentypen aus COM-Dlls
    ... Unser Kunde hat eine Typenbiliotek von der ich ... Wenn ich aber das Interface als parameter meiner Methode einbaue Gibts ... Kann mir jemand auf die Sprünge helfen damit der MIDL nicht mehr streikt? ... Next by Date: ...
    (microsoft.public.de.vc)
  • Re: HRESULT only required for Automation-compatible interfaces?
    ... Even in a interface, you are still limited to MIDL types (note ... for generating marshalling support - but you explicitly don't want it. ... to the same flavor of CRT DLL (otherwise, binary layout of the string ...
    (microsoft.public.vc.atl)

Loading