[Mono-dev] using coreclr in mono embedding sample project

Lucas Meijer lucas at lucasmeijer.com
Sat Jun 13 19:34:53 EDT 2009


Hey,

In order to figure out how to properly use the new coreclr 
functionality, verifiers etc, I've taken the
test-metadata.c  sample that shows how to simply embed mono,  and I'm 
adding some coreclr stuff to it.

The sample works and runs fine with core clr disabled.

If I add:

mono_security_enable_core_clr ();

before mono_jit_init(),  the mscorlib fails to load. When stepping 
trough the program with a debugger,
the point where these two (with coreclr and without) diverge,  is that 
line 465 of coree.c:

ModuleHandle = LoadLibrary(FileName);

returns a valid handle when coreclr is turned off, and it returns 0 when 
coreclr is turned on.

This is on windows, with r135921 runtime+corlib, using msvc2008 built 
mono using the stock msvc projectfile.

I'm a bit surprised by this actually, as I wouldn't expect a call into 
the win32 api to behave differently based on the
coreclr settings. (the FileName variable is identical in both cases).

Am I doing something wrong?


A verifier related question:  in do_mono_image_load(),  there are these 
calls:

mono_verifier_verify_pe_data().   this one requires image->raw_data_len 
to be set.  (in verify_msdos_header)
mono_verifier_load_pe_data().   this one actually sets 
image->raw_data_len.  (in do_load_header)

they're executed in the order above, which causes the first one to 
always fail for me.

Bye, Lucas


More information about the Mono-devel-list mailing list