System.int32[*] to System.int32[] explicit cast problems

  • Thread starter Thread starter northerntechie
  • Start date Start date
N

northerntechie

Ok, I don't normally post (I would rather rummage around in the
thoughts and frustrations of others) but this one has got me stumped.

I am using MS VB 2005 Express and I am using a COM object reference
that will not allow me to read back an array of System.int32 through a
byref parameter.

In the older VB6 program I would simply declare a long (int32) array
with no dimension and the COM object method would, by reference, pass
back an array and assign dimension to it.

It now seems that extra work is required to migrate the uninitialized
arrays that were used as reference pointers (I hate using the term,
but that is essentially what they are) in the older VB6 COM objects to
work with the newer interop COM object.

Any ideas on where to start.

Much appreciated and many thanks.
 
Ok, I don't normally post (I would rather rummage around in the
thoughts and frustrations of others) but this one has got me stumped.

I am using MS VB 2005 Express and I am using a COM object reference
that will not allow me to read back an array of System.int32 through a
byref parameter.

In the older VB6 program I would simply declare a long (int32) array
with no dimension and the COM object method would, by reference, pass
back an array and assign dimension to it.

It now seems that extra work is required to migrate the uninitialized
arrays that were used as reference pointers (I hate using the term,
but that is essentially what they are) in the older VB6 COM objects to
work with the newer interop COM object.

Any ideas on where to start.


You can't cast between int32[] and int32[*] because they are
considered different types. The former (which is used for regular
arrays iun VB) is assumed to be zero-based, the latter can have any
lower and upper bound. You can either work with the array using the
System.Array class, or declare a regular int[] (i.e. Integer()) and
then copy over the members using for example System.Buffer.BlockCopy.


Mattias
 
Back
Top