[Mono-list] Could not lookup zero argument constructor for class Ninject.StandardKernel
mimi
zachary.xu at jomediainc.com
Tue Mar 3 20:57:03 UTC 2015
I embedded Mono to my c++ code and tested with basic stuffs (invoke c#
methods wiht parameters and from multiple DLLs). I am trying to add Ninject
stuff to my code
(https://github.com/ninject/Ninject/blob/master/src/Ninject/StandardKernel.cs).
The following is the code segmrnt:
MonoAssembly * assembly = NULL;
assembly = mono_domain_assembly_open (domain,
"/Users/mac1/Downloads/zachary/TestLib/libs/TestCarlos/Ninject.dll");
MonoImage * image = NULL;
image = mono_assembly_get_image(assembly);
MonoClass* classStandardKernel = NULL;
classStandardKernel = mono_class_from_name(image, "Ninject",
"StandardKernel");
MonoObject* instanceClass1 = NULL;
instanceClass1 = mono_object_new(domain, classStandardKernel);
if (!instanceClass1)
{
printf("Get object error\n");
}
else
{
printf("Get object successfully\n");
}
mono_runtime_object_init(instanceClass1);
printf("object initialized\n");
Here is the console output:
Debugging starts
Get object successfully
Could not lookup zero argument constructor for class Ninject.StandardKernel
Debugging has finished
I looked at the method:
void
mono_runtime_object_init (MonoObject *this)
{
MonoMethod *method = NULL;
MonoClass *klass = this->vtable->klass;
method = mono_class_get_method_from_name (klass, ".ctor", 0);
if (!method)
g_error ("Could not lookup zero argument constructor for class %s",
mono_type_get_full_name (klass));
if (method->klass->valuetype)
this = mono_object_unbox (this);
mono_runtime_invoke (method, this, NULL, NULL);
}
And can't figure out why the mono runtime can't find the default
constructor. I tested with Visual Studio c# project and it works fine.
Another question is, with embedded Mono, can we access all the
functionalities the Ninject provides?
Thanks for any help!
Mimi
--
View this message in context: http://mono.1490590.n4.nabble.com/Could-not-lookup-zero-argument-constructor-for-class-Ninject-StandardKernel-tp4665563.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list
mailing list