[Mono-dev] Obtaining class from the assembly or one of the referenced assemblies
Robert Jordan
robertj at gmx.net
Fri Dec 7 22:05:02 UTC 2012
Hi,
On 07.12.2012 07:49, Bartosz Przygoda wrote:
> Hi,
>
> Currently I am obtaining the MonoClass* objects via mono_class_from_name
> which acts upon the MonoImage of provided assembly.
>
> However, I am planning my project to span throughout few assemblies and I
> still want the native host to be able to load classes by name. Do I have to
> track the loaded assemblies, and when class is requested, iterate over all
> of them and look for it in each one?
Yes, you have to, but you could reuse BCL's Type.GetType
by implementing the following code in a helper assembly
and mono_runtime_invoke it:
// returns the MonoType* of the specified type name
public static IntPtr GetType (string typeName)
{
return Type.GetType (typeName, true).TypeHandle.Value;
}
Then use assembly qualified type names as "typeName", e.g.
"Namespace.Class, SomeAssemblyNameWithoutDllExtension"
Robert
More information about the Mono-devel-list
mailing list