Automation object wants a safe array of DWORDS?

  • Thread starter Thread starter Robin Tucker
  • Start date Start date
R

Robin Tucker

My automation object (COM) wants a safe array of DWORDS passed into it, but
VB.NET tells me what I'm passing in is invalid. I assumed all basic arrays
in .NET were implicitly System.Array's and that the marshaller would
automatically convert it to the required SAFEARRAY. This appears not to be
the case, unless Im doing something totally dumb:

Dim thePalette(256) As System.UInt32

theDocument.GetPalette(256, CType(thePalette, System.Array))


the "GetPalette" method requires an integer and a reference to a
System.Array.

Any thoughts?
 
Hi,

VB.Net does not like to pass uint32 to a com object try using an
integer instead.

Ken
 
Yes, I first tried with integer, ie:

Dim thePalette(256) As Integer

theDocument.GetPalette(256, CType(thePalette, System.Array))

But same problem. What is the usual way a SAFEARRAY(DWORD) would be passed
into a method? (its IDL entry looks like this:)

HRESULT GetPalette([in] int nRes, [out] SAFEARRAY(DWORD)* rgb);
 
Hmmm, I'm guessing the problem here is that the importer doesn't know how to
create a System.Array type with DWORD. I will get my collegue to change it
from DWORD to int and see if that works.

Robin Tucker said:
Yes, I first tried with integer, ie:

Dim thePalette(256) As Integer

theDocument.GetPalette(256, CType(thePalette, System.Array))

But same problem. What is the usual way a SAFEARRAY(DWORD) would be passed
into a method? (its IDL entry looks like this:)

HRESULT GetPalette([in] int nRes, [out] SAFEARRAY(DWORD)* rgb);



Ken Tucker said:
Hi,

VB.Net does not like to pass uint32 to a com object try
using
an
integer instead.

Ken
 
Ok, ok, wasn't anything wrong particularly with what I was doing, my
colleague did look into it at his end though:

"Oops. It turns out that the type library and the code disagreed. The code
was returning VT_I4 and the type library was advertising VT_UI4 (or
whatever). Both are now signed"


Robin Tucker said:
Hmmm, I'm guessing the problem here is that the importer doesn't know how to
create a System.Array type with DWORD. I will get my collegue to change it
from DWORD to int and see if that works.

Robin Tucker said:
Yes, I first tried with integer, ie:

Dim thePalette(256) As Integer

theDocument.GetPalette(256, CType(thePalette, System.Array))

But same problem. What is the usual way a SAFEARRAY(DWORD) would be passed
into a method? (its IDL entry looks like this:)

HRESULT GetPalette([in] int nRes, [out] SAFEARRAY(DWORD)* rgb);



Ken Tucker said:
Hi,

VB.Net does not like to pass uint32 to a com object try
using
an
integer instead.

Ken
---------------
message My automation object (COM) wants a safe array of DWORDS passed into it,
but
VB.NET tells me what I'm passing in is invalid. I assumed all basic
arrays
in .NET were implicitly System.Array's and that the marshaller would
automatically convert it to the required SAFEARRAY. This appears
not
 
Back
Top