[Mono-dev] Invoking .net interface method from c api

Robert Jordan robertj at gmx.net
Fri Aug 21 10:42:57 UTC 2015

On 21.08.2015 11:43, zebrajap wrote:
> Oh. I got your point.
> The build output have System.dll in multiple places.
> ./lib/mono/2.0/System.dll
> ./lib/mono/4.5/System.dll
> *./lib/mono/gac/System/*
> ./lib/mono/4.0/System.dll
> I was loading it from ./lib/mono/4.0/System.dll. I am loading it as follows.
> 	mono_set_dirs("<Build Path>/lib", "<Build Path>/etc");
> 	pDomain = mono_jit_init_version("BuildDomain", "v4.0.30319" ); // Init the
> JIT Engine
> 	mono_config_parse(NULL);
> 	MonoAssembly* pSystemAssembly = mono_domain_assembly_open (pDomain, "<Build
> Path>/lib/mono/4.0/System.dll");
> 	pSystemImage = mono_assembly_get_image (pSystemAssembly);
> The file in gac seems to have the implementation.
> How to make it load from gac without providing absolute path? Please note
> that I cannot install it here.

Use one of the mono_assembly_load_*() functions because they
are obeying the usual CLR assembly binding rules (those rules C#
programmers are used to).

A good start is mono_assembly_load_with_partial_name () which
can be as simple as:

MonoImageOpenStatus status;
asm = mono_assembly_load_with_partial_name("System", &status);


More information about the Mono-devel-list mailing list