MathLinkFactoryCreateKernelLink(String) Method

Creates a link to a Wolfram Language kernel based on MathLink/WSTP parameters supplied as a single string.

Definition

Namespace: Wolfram.NETLink
Assembly: Wolfram.NETLink (in Wolfram.NETLink.dll) Version: 2.0.0.0
C#
public static IKernelLink CreateKernelLink(
	string cmdLine
)

Parameters

cmdLine  String
The string providing MathLink arguments.

Return Value

IKernelLink
The created link.

Remarks

Use this method if you want to specify the path to the kernel, or if you want to establish a listen/connect link instead of launching the kernel.

You can use standard MathLink/WSTP specifications for establishing a link, for example the -linkprotocol, -linkname, and -linkmode switches.

An example of a string argument would be:
C#
string mlArgs = "-linkmode listen -linkname foo";
IKernelLink ml = MathLinkFactory.CreateKernelLink(mlArgs);
If you give a pathname, make sure you surround it with quotes. Also, to avoid needing to use 4 \ characters for directory separators, use a forward slash (/) in the path:
C#
string mlArgs = "-linkmode launch -linkname \"c:/path/to/my/Wolfram/WolframKernel.exe\"";
IKernelLink ml = MathLinkFactory.CreateKernelLink(mlArgs);

Exceptions

MathLinkExceptionIf the opening of the link fails.

See Also