[Mono-list] Calling method with complex arguments (embedded)

Robert Jordan robertj at gmx.net
Wed Mar 25 13:47:42 EDT 2009

Robert Bielik wrote:
> I'm trying to call a function with prototype:
> void process(List< double[] >  ins,
>             ref List<double[]> outs);
> from my c++ code, but I'm a bit stumped on how to create the arguments?
> Tried to retrieve the MonoClass* for System.Collections.Generic.List via
> mono_class_from_name(mono_get_corlib(), "System.Collection.Generic", "List") but it
> returns NULL. 
> Probably thinking wrong here?

MonoClass *klass = mono_class_from_name(mono_get_corlib(),
	"System.Collection.Generic", "List`1");

Now obtain the MonoReflectionType of this class:

MonoReflectionType *t = mono_type_get_object (mono_class_get_type (klass));

Then invoke t.MakeGenericType (new Type [] {typeof (double[]) })
with mono_runtime_invoke to obtain the constricted type

BTW, It's easier to do this work with a managed helper method:

public static Type MakeGenericType (Type type, Type[] parms)
	return type.MakeGenericType (parms);


More information about the Mono-list mailing list