This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Documentation / Mathematica / Add-ons & Links / .NET/Link / Part 1. Calling .NET from Mathematica: 'Installable .NET' /

.NET/Link provides Mathematica users with the ability to interact with arbitrary .NET types directly from Mathematica. You can create objects and call methods and properties directly in the Mathematica language. You do not need to write any .NET code, or prepare in any way the .NET types you want to use. You also do not need to know anything about MathLink. In effect, all of .NET becomes a transparent extension to Mathematica, almost as if every existing and future .NET type were written in the Mathematica language itself.

We call this facility "installable .NET" because it generalizes the ability that Mathematica has always had to plug in extensions written in other languages through the Install function. Compared to other languages like C or C++, however, .NET/Link makes the intermediate steps go away completely, which is why we say that .NET becomes a transparent extension to Mathematica.

Although .NET is sometimes referred to as an interpreted environment, this is really a misnomer. To use .NET you must write a complete program in a language like C#, compile it, and then execute it. Mathematica users have the luxury of working in a true interpreted, interactive environment that lets them experiment with functions and build and test programs a line at a time. .NET/Link brings this same productive environment to .NET programmers. You could say that Mathematica becomes a scripting language for .NET.

To Mathematica users, then, the "installable .NET" feature of .NET/Link opens up the universe of .NET types as an extension to Mathematica; for .NET users, it allows the extraordinarily powerful and versatile Mathematica environment to be used as a shell for interactively developing, experimenting with, and testing .NET types.

This section of the .NET/Link User Guide discusses calling from Mathematica into the .NET runtime. You will see how to load .NET assemblies and types into Mathematica, create objects of these types, call methods and properties, and so on. You will also learn how to use .NET/Link to call COM objects as well as standard C-style DLL functions.

Note: This portion of the User Guide is very incomplete. Users should check the .NET/Link home page for a pending update to .NET/Link that greatly increases the size of this User Guide. It may already be available by the time you read this. Until that update is available, you will probably find it necessary to learn from the following example files.

Simple Examples:


GUI Examples:





Calling DLLs:



Calling COM Objects: