Using IMu's .Net Library

The IMu .Net API source code bundle for version 2.0 (or higher) is required to develop an IMu-based application. This bundle contains all the classes that make up the IMu .Net API. Contact Axiell Support for access to the IMu API bundles.

As with all .Net assemblies, the IMu .Net assembly must be available so that the .Net compiler and runtime environment can find and use the IMu classes. Tools for .Net development, such as Microsoft's Visual Studio, make it possible to add a reference to the IMu assembly to a project. All classes in the IMu .Net API are included in the one namespace, IMu. As is usual in .Net development, it is possible to refer to an IMu class in your code by either:

  1. Using the fully qualified name:

    C#

    IMu.Session session = new IMu.Session();

    VB

    Dim session = New IMu.Session()

  2. Importing the namespace:

    C#

    usingIMu;
    // ⋯
    Session session = new Session();

    VB

    Imports IMu
    ' ⋯
    Dim session = New Session()

Test Program

Compiling and running this very simple console-based IMu program is a good test of whether the development environment has been set up properly for using IMu:

C#

using System;
using IMu;
class Hello
{
    static void Main(string[] args)
    {
        Console.WriteLine("IMu Version {0}", IMu.IMu.VERSION);
        Environment.Exit(0);
    }
}

VB

Imports IMu
Module Hello
   Sub Main()
         Console.WriteLine("IMu Version {0}", IMu.IMu.VERSION)
         Environment.Exit(0)
     End Sub
End Module

The IMu library includes a class called IMu. This class includes the static string member VERSION which contains the version of this IMu release.

Exceptions

Many of the methods in the IMu library objects throw an exception when an error occurs. For this reason, code that uses IMu library objects should be surrounded with a try / catch block.

The following code is a basic template for writing .Net programs that use the IMu library:

C#

using IMu;
// ⋯
try
{
    // Create and use IMu objects
    // ⋯
}
catch (Exception e)
{
    // Handle or report error
   // ⋯
}

VB

Imports IMu
' ⋯
Try' Create and use IMu objects
    ' ⋯
Catch ex As Exception
    ' Handle or report error
    ' ⋯
End Try

Most IMu exceptions throw an IMuException object. The IMuException class is a subclass of the standard .Net Exception. In many cases your code can simply catch the standard Exception (as in this template). If more information is required about the exact IMuException thrown, see Exceptions.

Note: Many of the examples that follow assume that code fragments have been surrounded with code structured in this way.