# Running .NET/Link on Mono (On MacOS or any UNIX or Linux Distro)

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:
--- End of inner exception stack trace ---


Now the C# code for calling Mathematica is:

    _kl = MathLinkFactory.CreateKernelLink("-linkmode launch -linkname '\"/Applications/Mathematica.app/Contents/MacOS/MathKernel\" -mathlink'");


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

-

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:

On OSX:

export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Applications/Mathematica.app/Contents/Frameworks/mathlink.framework 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.

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