[Mono-list] mono embedding in c++: how to get a array from C# code?

sunsflower ssfxtr at outlook.com
Mon Nov 9 00:22:24 UTC 2015


//I reckon that mono_field_get_value will return a MonoArray,
//Try something a bit like this:
//
//MonoArray* monoArray = NULL;
//mono_field_get_value(obj, field, monoArrayl);
//MonoString *monoString = mono_array_get(monoArray, MonoString *, 0)
//char *s = mono_string_to_utf8(monoString); // copy this into a buffer that
you manage
//mono_free(s);

and how can I pass a pointer to mono?...
<code>
stuct test
{
        int index;
        string name;
};


MonoMethod* method = mono_class_get_method_from_name(klass, "testfunc", 2);
MonoException* ex;
typedef int(__stdcall *func)(MonoObject*, test*, MonoException**);
func f1 = (func)(mono_method_get_unmanaged_thunk(method));
test t1;
</code>
something like this? but C# won't accept a pointer except in unsafe context.
is there some other way of doing this - to read from a pointer to a struct
in C# and change it? or should I just pass the struct as a value?



--
View this message in context: http://mono.1490590.n4.nabble.com/mono-embedding-in-c-how-to-get-a-array-from-C-code-tp4666903p4666907.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list