Sunday, 15 September 2013

Assembly.GetExecutingAssembly() not working in embedded mono? -



Assembly.GetExecutingAssembly() not working in embedded mono? -

i'm trying embed mono in c++ executable, , mono crashes on assembly.getexecutingassembly. thought of missed ?

edit : using mono 3.0.3

embeddedmonotest.cpp :

// embeddedmonotest.cpp : defines entry point console application. // #include "stdafx.h" #include <mono/metadata/debug-helpers.h> #include <mono/metadata/exception.h> #include <mono/jit/jit.h> #include <mono/metadata/assembly.h> int _tmain(int argc, _tchar* argv[]) { monodomain* domain = mono_jit_init_version ("classlibrary1", "v4.0.30319"); monoassembly* _assembly_fbmonoengine = mono_domain_assembly_open (domain, "classlibrary1.dll"); monoimage* _image_fbmonoengine = mono_assembly_get_image (_assembly_fbmonoengine); monoclass* klass = mono_class_from_name(_image_fbmonoengine, "classlibrary1", "class1"); monomethod* test = mono_class_get_method_from_name(klass, "test" , 0); mono_runtime_invoke(test, null, null, null); homecoming 0; }

class1.cs :

using system; using system.collections.generic; using system.linq; using system.text; using system.reflection; namespace classlibrary1 { public class class1 { public static void test() { assembly.getexecutingassembly(); } } }

the error :

unhandled exception @ 0x65ad2148 in embeddedmonotest.exe: 0xc0000005: access violation reading location 0x`00000008.

you're not executing assembly in program, executingassembly in context has no meaning (a improve error needed, though). need provide usual static main() entry point in assembly , execute mono_runtime_exec_main().

mono

No comments:

Post a Comment