[Mono-list] passing MonoArray from c#

Robert Jordan robertj at gmx.net
Sat May 2 07:40:16 EDT 2009


fozzie wrote:
>         public override Link[] Pack(System.UInt32 packFlags)

...

>         MonoObject *retVal = mMonoClass->invoke("Pack", args);
>         MonoArray *retLinks = (MonoArray *)mono_object_unbox(retVal);

Since the return type of Pack is an array (a reference),
you must not unpack it. You can start accessing it:

DataLink *elem0 = mono_array_get (retLinks, DataLink*, 0);
DataLink *elem1 = mono_array_get (retLinks, DataLink*, 1);
...

> Unfortunately the assert is triggered since valuetype is 0. I'm not sure
> that i'm handling the WCHAR*/IntPtr properly, but it seems there is another
> issue. Any help appreciated!

It depends what the IntPtr actually is. If it's the result
of Marshal.StringToHGlobalUni() then it's most likely OK.

Robert



More information about the Mono-list mailing list