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

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.
 
M

Mattias Sjögren

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top