[Mono-dev] Embedded API: mono_array_element_size issue

Robert Jordan robertj at gmx.net
Wed Oct 2 13:06:10 UTC 2013


Jonathan,

On 02.10.2013 12:21, jonathan at mugginsoft.com wrote:
> The following raises so I presume that I have used it incorrectly:
>
>      MonoClass *arrayClass = mono_get_byte_class();
>      int32_t elementSize = mono_array_element_size(arrayClass);
>
> * Assertion at class.c:8201, condition `ac->rank' not met
>

This is because arrayClass is not the MonoClass of a MonoArray.

You need something like that:

// assign the mono array
uintptr_t byteLength = [self length];
MonoArray *monoArray = mono_array_new(mono_domain_get(), 
mono_get_byte_class(), byteLength);
int32_t elementSize = 
mono_array_element_size(mono_object_get_class((MonoObject*)monoArray);

Robert




More information about the Mono-devel-list mailing list