InvokeMember and byte[] parameter
From: George Lewis (ge_lw_at_junia.com)
Date: 03/03/04
- Next message: Josua: "Calling VB Script from C# project."
- Previous message: Glen Grant: "Re: timer problem"
- Next in thread: George Lewis: "Re: InvokeMember and byte[] parameter"
- Reply: George Lewis: "Re: InvokeMember and byte[] parameter"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 02 Mar 2004 16:48:57 -0800
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.InvokeMethod,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!
- Next message: Josua: "Calling VB Script from C# project."
- Previous message: Glen Grant: "Re: timer problem"
- Next in thread: George Lewis: "Re: InvokeMember and byte[] parameter"
- Reply: George Lewis: "Re: InvokeMember and byte[] parameter"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|