Re: Conformant IDL array trouble



_Never_ #import a type library containing interfaces that
are not Automation-compatible! Chances are some interface
is defined in a way that cannot be preserved in the type library.
Examples of such constructs are: local methods or local/call_as
pairs, local interfaces, methods with REFIID parameters. The
list is of course longer...

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

<cribface@xxxxxxxxx> wrote in message
news:1158759271.458465.201000@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi!

I'm trying to send an array of structs (actually pointers to structs)
which themselves contains arrays of structs across process boundaries
(see IDL below). The problem is that only the first element of the
array (visRects) inside the struct (PageState) gets marshalled. The
other elements are garbage. I'm not trying to be automation compatible
and I've registered and built the proxy/stub for the interface. When
I'm using this interface I'm #importing the typelib and I've checked
that the generated header file contains #pragma pack(push, 4)/#pragma
pack(pop) wrapped around the struct definitions. I've read that the
lack these #pragmas could cause problems.

Any suggestions what could be causing this? Any help is very much
appreciated!

Here's my IDL:

import "oaidl.idl";
import "ocidl.idl";
[
uuid(DA64440E-2FF1-4E06-A43B-F908D4A5E3F3),
version(1.0)
]
library MyLib
{
importlib("stdole2.tlb");

[uuid(B42E70BF-F909-47bc-A221-69834A548C47)]
struct tagVisRect {
long left;
long top;
long right;
long bottom;
};
typedef struct tagVisRect VisRect;

[uuid(D86AAF38-6169-4aaf-8625-CCD5123D309B)]
struct tagPageState {
long startSec;
long startMicroSec;
long stopSec;
long stopMicroSec;
long x;
long y;
int visRectsSize;
[unique, size_is(visRectsSize)] struct tagVisRect *visRects; // Only
the first element in this array is valid!
};
typedef struct tagPageState PageState;

[uuid(36D8C2F8-FF02-4d42-A5FB-1EA8E1714CEF)]
interface IDatabaseProxy2 : IUnknown {
HRESULT SendPageStates([in, size_is(pageStatesSize)] PageState*
pageStates[], [in] long pageStatesSize);
};
};

Regards,

Christoffer



.



Relevant Pages

  • Re: Can this be automation compatible?
    ... the interface is probably marshaled ... and it cannot be the Automation interface of an ActiveX ... > according to his question it's part of a dual interface. ... > Chapters Pointer to an array of chapters per title. ...
    (microsoft.public.win32.programmer.ole)
  • [Patch 5/8] taskstats interface
    ... separate out taskstats interface from delay accounting completely including ... Create a "taskstats" interface based on generic netlink ... * The struct is versioned. ...
    (Linux-Kernel)
  • [PATCH] usbmon: add binary interface
    ... USB records are stored in a liked list, alike current text interface implementation, so most code is shared from binary and text interface. ... unsigned int cmd, unsigned long arg) ... struct urb *urb, char ev_type) ...
    (Linux-Kernel)
  • [Patch 5/8] taskstats interface
    ... separate out taskstats interface from delay accounting completely including ... Create a "taskstats" interface based on generic netlink ... +Linux task defined by struct task_struct. ...
    (Linux-Kernel)
  • [updated] [Patch 5/8] taskstats interface
    ... separate out taskstats interface from delay accounting completely including ... Create a "taskstats" interface based on generic netlink ... +Linux task defined by struct task_struct. ...
    (Linux-Kernel)