InvokeMember and byte[] parameter

G

George Lewis

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;
mods = 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top