MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Mathlink and C#

  • To: mathgroup at
  • Subject: [mg46501] Re: [mg46497] Mathlink and C#
  • From: "Werner Schuster" <werner.schuster at>
  • Date: Fri, 20 Feb 2004 22:58:34 -0500 (EST)
  • References: <>
  • Sender: owner-wri-mathgroup at

> C# but I can´t find a simple example neither for the Mathematca
> worksheet (which should be simple?) nor for a C# source code.

There are samples provided with .NETLink, for calling .NET from
Mathematica anf for evaluating Mathematica expressions from C#;

>I would
> expect something like adding two numbers, i. e. calling a procedure
> "mysum[2,3]" and getting 5. The examples in the Mathematica installation
> (changing the process priority of the Mathkernel.exe) isn´t that what I
> would call simple!!

Well, it actually is pretty simple. Have you read the .NETUserguide provided
with Mathematica or .NETLink?

Basically, what you have to do these steps:
With C#
 - Write your code in a class and compile it into an Assembly;

In Mathematica:
 - invoke Needs["NETLink`"] and InstallNET[] to get .NETLink up and running;
 - Load the assembly (either by specifying the full pathname or by
   using its name in the .NET installation (see the Userguide for details));
 - LoadNETType with the name of your C# class;
 - invoke the method;

For invoking methods, you have to distinguish between member and static
methods;  read the Userguide for details on that (there is a section
named "Contexts and Visibility of Static Type Members" for that);

Werner Schuster (murphee)
Student of SoftwareEngineering and KnowledgeManagement
Maintainer of the OGO-JOGI Project @
Blog @

  • Prev by Date: Errors evaluating InputForm[graphic]
  • Next by Date: Re: Chebyshev's Identity
  • Previous by thread: Mathlink and C#
  • Next by thread: Re: Mathlink and C#