ContentsIndexHome
PreviousUpNext
Opening and closing an AIMMS session

In order to connect with AIMMS, you should create an ISession object which represents one connection with an AIMMS process running the specified model.

ISession aimmsSession = AIMMS.openSession(args[0], args[1]);

The first argument passed to the openSession method specifies the location of AIMMS; the second argument specifies the location of the AIMMS model1 file. 

If you specify the correct arguments and run the application, a new AIMMS process will be started and instructed to open up the specified project. 

An exception is thrown if AIMMS could not be started or the project file could not be found. It is therefore good practice to catch those exceptions:

ISession aimmsSession = null;
try{
  aimmsSession = AIMMS.openSession(args[0], args[1]);
}
catch(Exception ex)
{
  Console.WriteLine(ex);
}
finally
{
  if (aimmsSession != null )
  {
     aimmsSession.close();
  }
}

By closing the AIMMS Session in the finally clause we make sure that each session is properly closed. 

WARNING: If an ISession is not closed properly this might lead to an unresponsive process during application termination or the AIMMS process remaining as a 'zombie' process for an amount of time. 

 

1You need an AIMMS project file (depending on your aimms version, a .prj or an .aimms file), if you have an AIMMS pack (*.aimmspack), unpack it first.