[Mono-list] Embedded API: Method signature not found with generic parameter

jonathan at mugginsoft.com jonathan at mugginsoft.com
Sun Jul 14 12:49:39 UTC 2013

On 12 Jul 2013, at 21:48, jonathan at mugginsoft.com wrote:

> Can I obtain the generic template type from my ObjectSet MonoObject pointer rather than having to obtain it from a const char*.
> I am trying to write a "generic" routine for calling generic methods.
Perhaps another helper method is the way to go as working with generics directly through the embedded API seems so unpalatable.
This seems to work.

        public static Type[] GenericArgumentTypes(Type t)
            Type[] types = null;
            if (t.ContainsGenericParameters) {
                types = t.GetGenericArguments ();
            return types;

        public static IntPtr GenericArgumentTypeAtIndex(Type t, int index)
            Type argType = null;
            Type[] genericTypes = t.GetGenericArguments();
            if (genericTypes != null & index < genericTypes.Length) {
                argType = genericTypes[index];
            return argType.TypeHandle.Value;

I presume it will be slower invoking the C# rather than wrestling with the runtime API directly but in my case the final method is cached in a Judy array so it is a one time hit for each method signature called during the lifetime of the domain.


More information about the Mono-list mailing list