首页 > 解决方案 > 从.net 调用mathematica

问题描述

我正在使用 C# 从 Visual Studio 调用 Mathematica。我面临错误 -

“错误代码:1012。协议不可用”。

我正在使用 Windows 窗体从设备获取数据并将其发送到 Mathematica 工具并进行一些处理,并且需要将处理后的数据返回到 Windows 窗体 UI。请看下面的代码。

            private void button1_Click(object sender, System.EventArgs e)

            {

            // This launches the Mathematica kernel:
            IKernelLink ml = MathLinkFactory.CreateKernelLink();

            ml.WaitAndDiscardAnswer();

            // Now compute 2+2 

            string result = ml.EvaluateToOutputForm("2+2", 0);
            Console.WriteLine("2 + 2 = " + result);

            ml.Close();

            // Wait for user to close window.
            Console.WriteLine("Press Return to exit...");
            Console.Read();

           }

标签: c#wolfram-mathematica

解决方案


推荐阅读