[Mono-dev] Make mono work with CoreCLR

nelson nelson.cabral at gmail.com
Sun Apr 7 19:22:52 UTC 2013

I've been trying to produce a version of the .net 4.5 profile with
SecurityAttributes injected with Mono's Tuner (Mono.Tuner), and then use
this version in a C++ app with an embedded mono. If successfull I would like
to produce a github project as a starting point for anybody wanting to do
the same thing (which you would expect from someone doing this).

It worked at first, but I do not know how, I broke something. Now the
produced mscorlib produces a nice error when loading first (calling
mono_jit_init_version) :

Unhandled exception at 0x65b4416d in EmbeddedMonoTest.exe: 0xC0000005:
Access violation writing location 0x0000000c.

I've been trying to resolve this error since two weeks but the error in
undebuggable. Does someone has an idea on how to debug this ? 

I'm working on Windows with Cygwin.

The test c++ app : 

// EmbeddedMonoTest.cpp : Defines the entry point for the console

#include "stdafx.h"
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/exception.h>
#include <mono/jit/jit.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/appdomain.h>
#include <mono/utils/mono-publib.h>
#include <string>

bool hasEnding (std::string const &fullString, std::string const &ending)
	if (fullString.length() >= ending.length()) {
		return (0 == fullString.compare (fullString.length() - ending.length(),
ending.length(), ending));
	} else {
		return false;

mono_bool is_platform_code (const char *image_name)
	std::string libname(image_name);
	if( hasEnding(libname, "ClassLibrary1.dll") )
		return false;
	return true;

int _tmain(int argc, _TCHAR* argv[])
		mono_security_set_core_clr_platform_callback (is_platform_code);
		mono_security_enable_core_clr ();
		MonoDomain* domain = mono_jit_init_version ("ClassLibrary1",
"v4.0.30319"); // crashes here 

		MonoAssembly* assembly	= mono_domain_assembly_open (domain,
		mono_assembly_get_image(mono_domain_assembly_open (domain,
		MonoImage* image = mono_assembly_get_image (assembly);
		MonoClass* klass = mono_class_from_name(image, "ClassLibrary1", "Class1");
		MonoMethod* test = mono_class_get_method_from_name(klass, "Test", 0);

		MonoObject* ex;
		mono_runtime_invoke(test, NULL, NULL, &ex); 


	return 0;

View this message in context: http://mono.1490590.n4.nabble.com/Make-mono-work-with-CoreCLR-tp4659254.html
Sent from the Mono - Dev mailing list archive at Nabble.com.

More information about the Mono-devel-list mailing list