473,568 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2587
>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.B lockCopy.
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
5600
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 object of type System.__ComObject to type System.Data.DataSet. Server stack trace: at servidor.IclaseSvr.prueba2(DataSet ds) at
6
19188
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) { System.Data.SqlTypes.SqlInt32 myTestInt;
0
2748
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 some information from an Access database. It worked fine when I ran on my home computer. I use a datagrid witha a dataset and a parameterized query...
1
4861
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 specifiying my code: The Code used in Visual Studio: Function GetRank(ByVal ID As Integer, ByVal Comp As String, ByVal Sec As String, ByVal...
3
2055
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() {Type.GetType("System.Int32")}) Dim key As Object = keyci.Invoke(New Object() {"123"}) however it doesn't seem to work....
3
10244
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 'System.String'.
0
4406
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 download huge files, i.e., over 100MB with no problems. Actuate also has a utility (c# win app) that has no issues with a .net 1.1 version.
1
1343
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 String FunctionName(Object obj) { return obj.GetType().ToString(); } Int32 testObj = 0; FunctionName(testObj); //returns "System.Int32"
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7916
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6275
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
932
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.