[Mono-list] Help with embedded mono: mono_runtime_object_init

Robert Jordan robertj at gmx.net
Tue May 17 14:00:47 EDT 2011


Hi Rod,

On 17.05.2011 19:20, Rod wrote:
>          // Instantiate a class in .NET land
>
>          MonoImage * image = ::mono_assembly_get_image(assembly);
>
>          MonoClass * klass =
> ::mono_class_from_name(image,"EmbeddedMonoExampleAssembly","ExampleClass");
>
>          MonoObject* instance = ::mono_object_new (domain, klass);
>
>          ::mono_runtime_object_init (instance);<----- fail here

This function is asserting if it doesn't find the default ctor.
Check that the class you're trying to initialize is actually
implementing the default ctor itself. If it doesn't then
you can't use mono_runtime_object_init (). Invoke the non-default
ctor directly using mono_runtime_invoke.

I'm aware that the sample you've post does have a default
ctor, but you mentioned that the actual code is just
looking like the sample ;)

Robert



More information about the Mono-list mailing list