Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Has anyone have any luck running .NET/Link on Mono?

When I run .NET/Link to call Mathematica from within a Mono program, this is the error message I receive.

Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for Wolfram.NETLink.Internal.NativeLink ---> System.DllNotFoundException: mathlink
  at (wrapper managed-to-native) Wolfram.NETLink.Internal.MacMathLinkAPIProvider:MLBegin (intptr)
  at Wolfram.NETLink.Internal.MacMathLinkAPIProvider.extMLBegin (IntPtr zero) [0x00000] in <filename unknown>:0 
  at Wolfram.NETLink.Internal.NativeLink..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at Wolfram.NETLink.MathLinkFactory.createMathLink0 (System.String cmdLine, System.String[] argv) [0x00000] in <filename unknown>:0 
  at Wolfram.NETLink.MathLinkFactory.CreateMathLink (System.String cmdLine) [0x00000] in <filename unknown>:0 
  at Wolfram.NETLink.MathLinkFactory.createKernelLink0 (System.String cmdLine, System.String[] argv) [0x00000] in <filename unknown>:0 
  at Wolfram.NETLink.MathLinkFactory.CreateKernelLink (System.String cmdLine) [0x00000] in <filename unknown>:0 

Now the C# code for calling Mathematica is:

    _kl = MathLinkFactory.CreateKernelLink("-linkmode launch -linkname '\"/Applications/\" -mathlink'");

The same argument worked for J/Link, but for some reason does not work on NETLink.

share|improve this question
up vote 14 down vote accepted

To use .NET/Link from a Mono program, you need to make sure that the system can find the MathLink shared library. This generally means adding the appropriate path to an environment variable that the system uses for library lookups. You can do this is in the standard way that is appropriate for your OS/shell program, either in a shell config file or on the command line. For example:


mono MyProgram

On Linux:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/Wolfram/Mathematica/9.0/SystemFiles/Libraries/Linux
mono MyProgram

Most of .NET/Link works fine with Mono.

share|improve this answer
It's incredible to me that this works, although I have not tried it myself. – Liam Aug 18 '15 at 22:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.