[Mono-list] C to Mono interop passing a byte array

Mike D desaro at gmail.com
Fri May 20 05:00:11 EDT 2011


I am trying to pass a byte array (image data) from C/Obj-C to managed
using mono_runtime_invoke.  I can get a hold of the MonoMethod which
has a byte[] as a parameter and I can call the method but when I try
to use the byte[] in any way on the C# end I get an instant crash.
Are there any examples out there of sending a byte[] or any other
pointers on pulling this off?


NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle]
pathForResource:@"someImage.png" ofType:nil]];
int size = data.length;			
void *arg[2] = { (void*)data.bytes, &size };
mono_runtime_invoke( method, NULL, args, NULL );

My managed method signature is like this:

public static void testBytes( byte[] input, int length )

Mike


More information about the Mono-list mailing list