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

Robert Jordan robertj at gmx.net
Thu Aug 20 09:52:35 UTC 2015

On 20.08.2015 11:17, zebrajap wrote:
> The build machine does not have mono installed. So I have copied the dlls
> from another similar machine to
> /home/sameeraj/assemblies/mono/1.0/. (I am not sure why I had to copy in to
> mono/1.0 but if I don't when the program runs it complains mscorlib should
> be in that folder.)
> 	mono_set_dirs("/home/sameeraj/assemblies", ".");
> 	pDomain = mono_jit_init ("BuildDomain");
> 	MonoAssembly* pSystemAssembly = mono_domain_assembly_open (pDomain,
> "/home/sameeraj/assemblies/mono/1.0/System.dll");
> 	pSystemImage = mono_assembly_get_image (pSystemAssembly);
> 	MonoAssembly* pMscorlibAssembly = mono_domain_assembly_open (pDomain,
> "/home/sameeraj/assemblies/mono/1.0/mscorlib.dll");
> 	pMscorlibImage = mono_assembly_get_image (pMscorlibAssembly);
> Thanks.

Wow, I'm sensing a couple of issues here :)

1) your Mono is old. The 1.0 profile has been phased out a couple
of years ago.

2) the directory layout you're passing to mono_set_dirs
is most likely incorrect. Both dirs must contain a directory
"mono" with the contents taken from a full Mono installation
($prefix/lib/mono and $prefix/etc/mono).

3) the CodeDomProvider is necessitating even more of a Mono installation
because it must be able to invoke the C# compiler (mcs). Step (2)
is enough for this, though.

4) for complex things like CodeDomProvider you're supposed to
initially mono_jit_exec() an assembly that implements an entry
point (static void Main()).

Please do yourself a favor and start developing on a machine
with a full (and fresh) Mono.


More information about the Mono-devel-list mailing list