[Mono-dev] Embedding Mono

Robert Jordan robertj at gmx.net
Thu Mar 10 04:54:50 EST 2011

On 10.03.2011 08:26, vinay_rk wrote:
> I' am trying to Embed Mono with C/C++ and so far I've been able to compile
> and link my c++ project with the required Mono headers and lib.  My code
> looks something like this:
> MonoDomain *domain;
> 	MonoAssembly *assembly;

This will initialize the runtime with its default
profile. Depending on the Mono version, this is either
2.0 or 4.0:
>      domain = mono_jit_init ("system");

You should use mono_jit_init_version () instead and
specify "v4.0.30319" or "v2.0.50727".

Maybe your assembly was compiled for the 4.0 profile:

> 	assembly = mono_domain_assembly_open (domain, "TestManagedAssembly.exe");
> 	if (!assembly)
> 		printf("Error");
> 	else
> 	{
> 		mono_jit_exec (domain, assembly,0, NULL);

This is wrong. mono_jit_exec expects that the file name of the
assembly is passed as the first argument.


More information about the Mono-devel-list mailing list