473,507 Members | 3,112 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parameter count mismatch??? passing an array to Invoke

This is fairly simple code, what am I missing or is there a potential
workaround?

It fails when passing someParms to Invoke with "Parameter count
mismatch". I created a test with an empty form and a single button.
Thanks in advance.

By the way, in case you're wondering why... I want to call into the
form from a different thread to update controls.
Private Delegate Sub MyDelegate(ByVal parm() As Object)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim myDel As MyDelegate
myDel = New MyDelegate(AddressOf AProcedure)

Dim someParms(2) As Object
someParms(0) = "abc"
someParms(1) = "def"

myDel.Invoke(someParms) 'WORKS!

Invoke(myDel, someParms) ' doesn't work :(
End Sub

Private Sub AProcedure(ByVal parm() As Object)
MessageBox.Show(parm.Length)
End Sub

Jun 14 '06 #1
2 15906
> Dim someParms(2) As Object

Should be someParms(1) if you only have two parameters.

Invoke(myDel, someParms) ' doesn't work :(


Try

Invoke(myDel, New Object() {someParms})
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jun 14 '06 #2
Yes, thank you!

Mattias Sjögren wrote:
Dim someParms(2) As Object


Should be someParms(1) if you only have two parameters.

Invoke(myDel, someParms) ' doesn't work :(


Try

Invoke(myDel, New Object() {someParms})
Mattias

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


Jun 14 '06 #3

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

Similar topics

1
6367
by: Andreas Paasch | last post by:
I've got somehow a little peculiar problem and can't seem to find the right solution so I could use a hand/hint or two. On toppings.php I have - among others: <a...
5
7598
by: Raju V.K | last post by:
I am developing a web site which requires a set og unique values be transferred between pages and server many times. There fore i decided to put the values in an array so that only one reference to...
4
14051
by: Laszlo Csabi | last post by:
Hi Folks, Can someone explain me why I'm getting the following error? The error message I got is : "Parameter count does not match Parameter Value count."
0
1520
by: KK | last post by:
Hi MCPP gurus' I have a small problem in parameter passing.This is my situation namespace Abc { public __gc class ClassAbc { public: String* Hello(String* str) {
4
8421
by: dogalacar | last post by:
Hi All, I am trying to pass array of structures from a C dll to C# as msdn sample does(outarrayofstructs sample) but PtrToStructure function gives error : --> "structure must not be a value...
2
4127
by: Neil Munro | last post by:
I'm having some "type" difficulty in passing a .NET array (byref) to a COM based API (Autodesk Inventor). In VB6 the code to return an array of tolerance values is: Dim ToleranceCount As Long...
3
3288
by: shobu | last post by:
passing array checkbox value and update the database <?include 'dbconnect.php'; error_reporting(0);$update_qr="update...
2
4348
by: jonpb | last post by:
Using .NET 3.5, I need to pass an array of structs as parameter to a C++ unmanaged function. The C++ dll stores some data in an unmanaged cache, the function writes the values into the array of...
4
15656
by: puzzlecracker | last post by:
I am going to post the most relavent code that causes this behavior: Here I try to invoke a static method of TestProgram Class...
0
7221
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,...
0
7109
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...
0
7313
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,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7029
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...
0
7481
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5619
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,...
1
5039
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.