473,395 Members | 1,418 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,395 software developers and data experts.

InvokeMember and byte[] parameter



Hi,

I am trying to invoke a method from a COM dll using InvokeMember which
has the following signature:

int GetStatus(ref byte[] scannedBytes, System.Int32 length);

However when I try and call this method using a byte[] parameter, I get
a type mismatch error.
The code that I am using here is:

byte[] scannedBytes = GetData(); // Internally returns a byte array

Type type = Assembly.LoadFrom("Interop.Scanner.dll").GetType() ;
object obj = Activator.CreateInstance(type);
object[] args = new object[]{scannedBytes,scannedBytes.length);

ParameterModifier[] mods = new ParameterModifier[2];
bool[] byref = {true,false};
for (int i = 0; i < 2; i++)
{
ParameterModifier m = new ParameterModifier(1);
m[0] = byRef[i];
mods[i] = m;
}

This is the line I am getting "type mismatch" exception.
int result =
type.InvokeMember("GetStatus",BindingFlags.InvokeM ethod,null,obj,args,mo
ds,null,new string[]{"scannedBytes","length"});

Can some one please tell me what am I doing wrong.

Thanks,
George

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
1 1966


Hello Folks,

I am stuck. Any help will be highly appreciated.

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #2

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

Similar topics

2
by: Robert May | last post by:
We have a VB6 COM component that I don't have control over. All of the values are returned from method calls using byref parameters. They frequently break binary compatibility, in fact, there are...
1
by: mike | last post by:
hello, Using Type.InvokeMember to call a method of a class,Which method has byref parameter,It seems that there is no way to return the changed value of that byref parameter by the method of...
0
by: David | last post by:
Hi, I have a program in which I used invokemember to late bind to a component. In my code I use: SetupInfo setup; Object objTem = callLateBinding ("BackOfficeServer.BackOffice",...
1
by: Robert May | last post by:
We have a VB6 COM component that I don't have control over. All of the values are returned from method calls using byref parameters. They frequently break binary compatibility, in fact, there are...
5
by: Chris | last post by:
boolResult = (bool)typeofobj.InvokeMember("ReadString",BindingFlags.InvokeMethod, null, newobj, new object{HKEY_CURRENT_USER, "Software\\Example Reg Path", "Example String Value", strResult}); ...
0
by: eirik hoem | last post by:
I have a problem using InvokeMember. I have a client application that loads a set of assemblies runtime. It creates instances of them and calls a method which I specify in a XML file. What...
0
by: eirik hoem | last post by:
case-block was followed by a ; that's what you get for 13hrs straight ------------------------ I have a problem using InvokeMember. I have a client application that loads a set of assemblies...
3
by: Pat Ireland | last post by:
The following code shows what I am trying to do. The normal invocation of the CalcByRef produces the correct results, however, using the InvokeMember fails to correctly pass the single argument by...
4
by: Howard Kaikow | last post by:
I am trying to retrive some WMI properties using Option Strict On. This requires the use of InvokeMember. I know that there are alternative ways to get the values, but I want to learn how to...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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
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...

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.