473,320 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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.

Sep 13 '07 #1
1 2573
>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

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Sep 14 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Fidias Gil de Montes | last post by:
In a Distributed Windows application, I receive the following message when the client calls the server: ************** Exception Text ************** System.InvalidCastException: Unable to cast...
6
by: Jim Bancroft | last post by:
Hi everyone, I'm having some trouble with the code below. I receive a compile-time error on the second line saying "; expected": private static void myTestFunction(long myLong) { ...
0
by: silesius | last post by:
I've been using VS.NET 2003 to develop a webapplication using C#. Today I exported the application to another webserver I begun experiencing problems. It's a simple application that retrieves...
1
by: Hifni Shahzard | last post by:
Hi, I got a stored procedure, where it returns a value. But if I execute it. It gives an error as "Invalid cast from System.Int32 to System.Byte.". To make clear how do I execute this, below I'm...
3
by: Søren M. Olesen | last post by:
Hi How do I dynamically create a type of System.Int32 with the value 123?? I've tried the following: Dim keyci As ConstructorInfo = Type.GetType("System.Int32").GetConstructor(New Type()...
3
by: keithb | last post by:
What could be causing this? this code: String Com = ""; if (Com != (String)rw.ItemArray) fails at runtime with the error message: Unable to cast object of type 'System.Int32' to type...
0
by: AY | last post by:
Hello, We use a third party reporting system (Actuate) which provides soap services via WSDL. My web application was initially built in Visual Studio 2003 using .NET 1.1. I was able to...
1
by: ceestand | last post by:
I'm trying to make a change to an object depending contextually on it's type. The following code, even though I pass the Int32 into the function as an Object, still knows it's an Int32. public...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.