I have programmed this example for the last 6 years with various versions of Mathematica and .NET. This year I have moved to Version 10.0.2 and it doesn't work. I am using Visual Studio 12 for C#. My C# code is unremarkable:
string[] mlArgs = { "-linkmode", "launch", "-linkname", @"C:\Program Files\Wolfram Research\Mathematica\10.0\SystemFiles\Kernel\Binaries\Windows-x86-64\MathKernel.exe" };
IKernelLink ml = null;
try
{
ml = MathLinkFactory.CreateKernelLink(mlArgs);
ml.WaitAndDiscardAnswer();
string result = ml.EvaluateToOutputForm("2+2", 0);
txtFirst.Text = result;
}
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}
finally
{
if (ml != null)
ml.Close();
}
The ERROR I receive is:
"The type initializer for 'Wolfram.NETLink.Internal.NativeLink' threw an exception."
along with:
"Unable to load DLL 'ml32i4.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"
Any help much appreciated!
Thank you,
Kieran
ml32i4.dll
is found in the following directory:\Mathematica\10.0\SystemFiles\Links\MathLink\DeveloperKit\Windows\SystemAdditions
-- can you confirm that this file is present in your installation? $\endgroup$%PATH%
if it's to be found after linking. Is it? (N.B. this is a solution to your problem as well as a question.) $\endgroup$