/// <summary>
 ///   Default Constructor.
 ///   <para>
 ///     Creates a new instance of COM Axapta object.
 ///   </para>
 /// </summary>
 /// <exception cref = "AxException">Thrown when an exception occurs trying to create an instance of the Axapta object</exception>
 public AxBusinessConnectorCom()
 {
     try
     {
         _axaptaAdapter = new Axapta2Class();
     }
     catch (COMException exception)
     {
         throw new AxException(string.Format("Can't create Axapta BC object: {0}", exception), exception);
     }
 }
 /// <summary>
 ///   Implementation of the Dispose Pattern
 /// </summary>
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         if ((_axaptaAdapter != null))
         {
             try
             {
                 _axaptaAdapter.Logoff();
                 ShutdownComPlus();
             }
             catch
             {
             }
         }
         _axaptaAdapter = null;
     }
 }
 /// <summary>
 ///   Login to Axapta
 /// </summary>
 /// <param name = "user">User name to login</param>
 /// <param name = "password">Password of the user</param>
 /// <param name = "company">Name of the company to logon</param>
 /// <param name = "language">Language of the user</param>
 /// <param name = "configuration">Configuration name to use for the client</param>
 /// <exception cref = "AxException">Thrown when logon attempt fails</exception>
 public void Logon(string user, string password, string company, string language, string configuration)
 {
     try
     {
         if (_connections.Value > 0)
         {
             Logoff();
             _connections.Decrement();
             _axaptaAdapter = new Axapta2Class();
         }
         _axaptaAdapter.Logon2(user, password, company, language, "", "", configuration, false, null, null);
         _connections.Increment();
     }
     catch (COMException exception)
     {
         throw new AxException(string.Format("Logon failed to axapta: {0}", exception), exception.InnerException);
     }
 }