Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm wondering if its possible push output from a .NET console application to an existing Notebook that is open in Mathematica.

The reason I'd like this is that I want to use Mathematica as a "debugging console" for intermediate calculations that I am performing in .NET, by pushing out text, graphics, etc.

p.s. I'm fairly familiar with C# and Mathematica, so all I want to know is if this is possible, or not.

share|improve this question
It is possible via JLink (see the JLink docs for details, my quick search resulted in this link, but the updated version of this is now incorporated into the current JLink tutorial). I would guess .NET link should make this possible too. – Leonid Shifrin Aug 29 '12 at 8:41


If we send the following four commands to the Mathematica Kernel, via Net/Link, it will create a new notebook, and graph the result of an equation:

n = CreateWindow[]
NotebookWrite[n, "Plot[Sin[x],{x,0,6 Pi}]"]
SelectionMove[n, All, CellContents]

Here is the output in Mathematica. I think this is pretty cool: now I can use Mathematica as a kind of super charged debugging console from a .NET application, one which can plot graphic as well as print text. Any output graphs can then be interacted with, i.e. rotated, animated, etc.

enter image description here


Unfortunately, this didn't end up working at all.

The following command does not work from .NET/Link, as its a function call contained in the user interface, and not the kernel:

n = CreateWindow[]

Currently, I'm still stuck. The only option I can think of is to create a standalone Windows service that sits in the background, accepting arrays from the standalone .NET app, and serving them to a Mathematica Notebook on demand (I havn't implemented this yet).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.