[Mono-list] MonoObject of type System.Type to MonoClass (C)

Robert Jordan robertj at gmx.net
Fri Dec 15 04:36:14 EST 2006


Maciej Piechotka wrote:
> I have a collection which I got from dll. However I have a objects of
> System.Type and I want to have MonoClass.


System.Type is represented by MonoReflectionType* in the embedded
API. Unfortunately there is no documented/public way to obtain
the MonoType* from a MonoReflectionType*, at least I didn't
find one.

The workaround is to declare this in your code:


/*
  * FIXME: propose mono_reflection_type_get_XYZ () accessors.
  */
struct _MonoReflectionType {
	MonoObject object;
	MonoType  *type;
};


Supposing your System.Type is in the var `obj', you can
obtain the MonoClass* this way:

mono_class_from_mono_type ((MonoReflectionType*)obj)->type);

Robert



More information about the Mono-list mailing list