4. API installation and compiling examples


This chapter describes how to compile and run the .NET examples distributed with MOSEK.

To use the MOSEK .NET interface, a working MOSEK installation must be present — see the MOSEK Installation manual for instructions. In the following we assume that assume that MOSEK is installed in the default directory

C:\Program Files\mosek

The MOSEK .NET interface is defined in

C:\Program Files\mosek\5\tools\platform\win\bin\mosekdotnet.dll

or

C:\Program Files\mosek\5\tools\platform\win64\bin\mosekdotnet64.dll

depending on the platform.

The distributed .NET examples are found in

C:\Program Files\mosek\5\tools\examples\dotnet

Please note that the Windows “Program Files” may be different for non-US installations.

4.1. Compiling and running the examples

To compile an example, say lo1, with the Microsoft .NET compiler, open a DOS box with paths for Visual Studio set up (usually in the Start menu, the sub-menu for Visual Studio contains an entry that starts a DOS box with everything set up). Change directory to where the examples are found:

  c:
  cd "\Program Files\mosek\5\tools\examples\dotnet"

Then the following line compiles lo1.cs into an executable lo1.exe:

  csc /r:"c:Program Files\mosek\mosek\5\tools\platform\win\bin\mosekdotnet.dll" lo1.cs

As for the Visual Basic example, the equivalent command looks as follows

  vbc /r:"c:\Program Files\mosek\mosek\5\tools\platform\win\bin\mosekdotnet.dll" lo1.vb

To run the example, the system must be able to locate mosekdotnet.dll. To ensure this, either copy mosekdotnet.dll into the directory where lo1.exe was created, or ensure that mosekdotnet.dll resides in the Global Assembly Cache.

The program can now be executed by entering on the command line:

  lo1

4.2. Visual Studio projects

The example lo1.cs also exists as a Microsoft Visual Studio project. This cannot immediately compile as it requires to know the location of mosekdotnet.dll. To set this path correctly open the project in Visual Studio and look in the Solution Explorer window. Open the references branch in the tree-structure and delete the original mosekdotnet.dll reference (right-click on it, select remove), then right-click on references, select Add reference and click on browse to enter the full path of mosekdotnet.dll.

Assuming that mosekdotnet.dll is in the Global Assembly Cache, the project should now compile and run without problems, otherwise the dll should be copied to the directory where the binary application is located.

4.3. Using the interface DLL

The library mosekdotnet.dll may be used from any .NET compatible language such as Visual Basic, Microsoft C# or Microsoft Managed C++. Both the examples and the library should also work with Mono on most 32-bit platforms.

The library accesses methods in the native MOSEK library (mosek.dll), which from a .NET view is considered unsafe. This means that use of the library is restricted; for example, it may be a problem to use web-based applications with the library. Programs running from a local drive should not cause any problems with a standard Windows setup.

4.4. Interactive use of MOSEK

It is possible to use the MOSEK .NET API interavtively from .NET languages which implements a command-line interpreter, for example IronPython

http://www.codeplex.com/IronPython

or the third-party language Boo

http://boo.codehaus.org/

These can efficiently be used to create and examine the problems and solutions from MOSEK.

4.5. Linux and Mono

It is possible to use the .NET API from Mono v.1.2 and later. Mono is a free implementation if the .NET platform available here

http://mono-project.com/.

The .NET dll is not included in the Linux distributions of MOSEK, but the dll included in the Windows distribution can be used from Mono.

To do this you must have a complete MOSEK installed as described in “the MOSEK Installation Manual”. Set the environment variable

MONO_PATH

to point to mosekdotnet.dll (or mosekdotnet64.dll for the 64-bit Mono).

You should now be able to compile and run the distributed .NET examples using Mono.

Mon Sep 14 15:45:58 2009