I have created a sample c++ app that uses dynamic linking to embed mono (as described here http://www.mono-project.com/Embedding_Mono) and use C# for scripting. It works well, as long as mono is installed in the global assembly cache (GAC).

Is there a way to bundle mono with my c++ executable so that I can install it alongside my c++ executable ?

I have been looking at mkbundle but it looks like it packages mono with c# apps.

EDIT : answer below reformatted

#include <cstdlib>
_putenv("MONO_GAC_PREFIX=C:\\cygwin\\usr\\local\\bin\\");
mono_set_dirs("C:\\cygwin\\usr\\local\\lib","C:\\cygwin\\usr\\local\\etc");

EDIT : Corrected : I just need to copy/paste mono-2.0.dll in the executable's folder and use mono_set_dirs("C:\\cygwin\\usr\\local\\lib","C:\\cygwin\\usr\\local\\etc"); to force the use of a specific framework

有帮助吗?

解决方案

Mono consists of 2 distinct parts:

  • the base runtime written in C, embeddable as mentioned in your OQ
  • lots of class libraries, mostly written in C#. These are not embedded together with the runtime, but reside in the GAC

Basically you need to provide your own GAC - this is easyily done by taking it with you into your app folder structure, then setting the MONO_GAC_PREFIX environment variable to wherever you are installed.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top