Re: using Mathematica to plot in visual studio 2005

*To*: mathgroup at smc.vnet.net*Subject*: [mg55466] Re: using Mathematica to plot in visual studio 2005*From*: "Hans Michel" <hmichel at sdc.cox.net>*Date*: Thu, 24 Mar 2005 03:42:12 -0500 (EST)*References*: <d1rgvo$42m$1@smc.vnet.net>*Reply-to*: "Hans Michel" <hmichel at sdc.cox.net>*Sender*: owner-wri-mathgroup at wolfram.com

Siddharth Jain The following is straight from the .NETLink API. "Launches the default Mathematica kernel and returns a link to it. [Visual Basic]Overloads Public Shared Function CreateKernelLink() As IKernelLink [C#] public static IKernelLink CreateKernelLink(); Return Value The created link. Remarks Use this method if you want to launch the kernel. This is probably the most commonly-used method in this class. It looks in the Windows registry for the location of the most recently-installed copy of Mathematica. Exceptions..." If you have the CreateKernelLink or CreateMathLink() methods somewhere in your code then the problem lies in Method not finding where your latest copy of Mathematica is located from the Registry. If it can't be found you can explicitly tell it where it is. Read the .NET/Link API again. you might need to do something like this string mlArgs = "-linkmode launch -linkname \"c:/path/to/my/mathematica/mathkernel.exe\""; IKernelLink ml = MathLinkFactory.CreateKernelLink(mlArgs); Some once pointed out how to verify if your .NET/Link programs will find the correct path from just registry setting or if you have to write out the path yourself. It is a command you run from Mathematica if it fails the you have to write out the path I think Todd Gayley knows more on this. Hans "Siddharth Jain" <siddharth_jain_1 at rediffmail.com> wrote in message news:d1rgvo$42m$1 at smc.vnet.net... > Hello > > I am using Visual Studio 2005 beta and Mathematica 5.0. > I was trying to make an application (in c#) which would allow me to use > Mathematica functions like Plot[], ListPlot[] etc and show the > resulting plot in a picturebox in the form. > > I read the .NETLink API and tried to run the sample code: > > private void computeButton_Click(object sender, System.EventArgs e) > { > if (mathKernel.IsComputing) { mathKernel.Abort();} > else { > computation.resultBox.Text = ""; > messagesBox.Text = ""; > printBox.Text = ""; > graphicsBox.Image = null; > computeButton.Text = "Abort"; > > mathKernel.Compute(inputBox.Text); > computeButton.Text = "Compute"; > > // Populate the various boxes with results. > resultBox.Text = (string) mathKernel.Result; > foreach (string msg in mathKernel.Messages) > messagesBox.Text += (msg + "\r\n"); > foreach (string p in mathKernel.PrintOutput) > printBox.Text += p; > if (mathKernel.Graphics.Length > 0) > graphicsBox.Image = mathKernel.Graphics[0]; > } > } > > > But when I run this application and press the compute button, a window > opens up which says "Choose a MathLink program to launch" and asks me > to select an exe file. > I have no idea what is happening. > > Could someone please guide me on what to do. > > Thanks in advance. > > Siddharth Jain >