Axapta Business Connector error

Hi all, I have written a Windows Service in C# that connects through the ABC COM component to retrieve customer data from Axapta. The service runs and works properly on my development machine, but I can’t get it to work in my test environment, or on another developer’s machine. I keep getting the an error (listed at the bottom of this post). I have set up a simple test application that just connects to the ABC and calls WinAPI.getTickCount to test the connection, again it works on my machine, but fails on other machines with the same error (so the problem is definitely not that I am using a service). On both these machines, running Axapta normally using the configuration specified by the test application works fine, it is just connecting through the ABC that fails. The error indicates a file permissions issue, but as I said the same user is able to connect to Axapta normally (and I have made sure that the ABC is running under interactive user), and can access all necessary files. It was suggested on the AxaptaDev yahoo group that I try copying the CURRENT_USER Axapte registry settings into the LOCAL_MACHINE tree, but that did not help. Does anyone have any suggestions on how to fix this, or on how to debug it more effectively? At this point I cant get into the guts of the ABC so I can’t figure out exactly what is causing the failure. Thank in advance, Matt “at AxaptaCOMConnector.Axapta2Class.Logon2(Object user, Object userPassword, Object Company, Object language, Object serverManager, Object objectServer, Object configuration, Object isWebUser, Object reserved1, Object reserved2) at AxaptaCommsTest.Form1.connect() File Error : The application files are not accessible. This can be caused by another Navision Axapta instance using the application files in exclusive mode. Navision Axapta cannot be executed. Please restart the Navision Axapta Business Connector before logging on.”

Hi, How many simultaneus ABCs there is in your license? br,

Hi there, We have three ABC licences, and we’re not using any of them (this will be the first app to use them). We also don’t use the web portal, so that’s definitely not using one. I will try shutting down my machine and testing on another machine to make sure they are not competing for licences, but I doubt that’s the problem… Thanks, Matt

Hi, Have you checked not to have a 2-tier client using the application in exclusive mode while you work with the COM? (In SP1 and SP2 AxConfig utility has a checkbox Open the application files in excusive mode.) Regards, Ciprian

It would seem I was wrong, the file permissions were the problem after all. Apparently the ABC requires full access to the .aoi files (where the client seems to be happy with just read, list and execute. I used filemon to track what files were failing, and when the ABC tried to connect, it failed while accessing the index file. Thanks anyway for the suggestions :slight_smile:

Oh, and sorry for the double-post, but I thought some of you may find the connection tool I used useful. Here is the full source (sorry for the lack of comments, it is intended as a quick testing tool, nothing more). It requires the configuration you choose to have a user and password for the COM specified in the config tool. Regards, Matt //Form1.cs using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using Microsoft.Win32; using AxaptaCOMConnector; namespace AxaptaCommsTest { ///

/// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private const string AXAPTA_30_REGKEY = “Software\Navision\Axapta\3.0”; private string config = “”; private IAxapta2 axapta; private ArrayList lines; private AxaptaParameterListClass axParamList; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Label label1; private System.Windows.Forms.GroupBox groupBox1; private bool connected = false; private System.Windows.Forms.TextBox txtResult; private System.Windows.Forms.ComboBox lstConfig; private System.Windows.Forms.Timer tmrCallMethod; private System.Windows.Forms.Button btnConnect; private System.ComponentModel.IContainer components; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); //Private init axapta = new Axapta2(); axParamList = new AxaptaParameterListClass(); lines = new ArrayList(); selectConfig(); } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } if(connected) { axapta.Logoff(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.btnConnect = new System.Windows.Forms.Button(); this.txtResult = new System.Windows.Forms.TextBox(); this.panel1 = new System.Windows.Forms.Panel(); this.lstConfig = new System.Windows.Forms.ComboBox(); this.label1 = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.tmrCallMethod = new System.Windows.Forms.Timer(this.components); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); // // btnConnect // this.btnConnect.Location = new System.Drawing.Point(211, 32); this.btnConnect.Name = “btnConnect”; this.btnConnect.TabIndex = 0; this.btnConnect.Text = “Connect”; this.btnConnect.Click += new System.EventHandler(this.button1_Click); // // txtResult // this.txtResult.Dock = System.Windows.Forms.DockStyle.Fill; this.txtResult.Location = new System.Drawing.Point(3, 16); this.txtResult.Multiline = true; this.txtResult.Name = “txtResult”; this.txtResult.ReadOnly = true; this.txtResult.ScrollBars = System.Windows.Forms.ScrollBars.Both; this.txtResult.Size = new System.Drawing.Size(286, 183); this.txtResult.TabIndex = 3; this.txtResult.TabStop = false; this.txtResult.Text = “”; // // panel1 // this.panel1.Controls.Add(this.lstConfig); this.panel1.Controls.Add(this.label1); this.panel1.Controls.Add(this.btnConnect); this.panel1.Dock = System.Windows.Forms.DockStyle.Top; this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = “panel1”; this.panel1.Size = new System.Drawing.Size(292, 64); this.panel1.TabIndex = 4; // // lstConfig // this.lstConfig.Location = new System.Drawing.Point(78, 8); this.lstConfig.Name = “lstConfig”; this.lstConfig.Size = new System.Drawing.Size(208, 21); this.lstConfig.TabIndex = 4; this.lstConfig.Text = “comboBox1”; // // label1 // this.label1.Location = new System.Drawing.Point(6, 8); this.label1.Name = “label1”; this.label1.Size = new System.Drawing.Size(78, 23); this.label1.TabIndex = 3; this.label1.Text = “Configuration”; // // groupBox1 // this.groupBox1.Controls.Add(this.txtResult); this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBox1.Location = new System.Drawing.Point(0, 64); this.groupBox1.Name = “groupBox1”; this.groupBox1.Size = new System.Drawing.Size(292, 202); this.groupBox1.TabIndex = 5; this.groupBox1.TabStop = false; this.groupBox1.Text = “Result”; // // tmrCallMethod // this.tmrCallMethod.Interval = 1000; this.tmrCallMethod.Tick += new System.EventHandler(this.tmrCallMethod_Tick); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(292, 266); this.Controls.Add(this.groupBox1); this.Controls.Add(this.panel1); this.Name = “Form1”; this.Text = “Axapta connection test”; this.panel1.ResumeLayout(false); this.groupBox1.ResumeLayout(false); this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } private void button1_Click(object sender, System.EventArgs e) { if(!connected) { connect(); } else { disconnect(); } } private void connect() { try { lines.Insert(0, “CONNECTING”); selectConfig(); axapta.Logon2("", “”, “”, “”, “”, “”, config, false, “”, “”); connected = true; lines.Insert(0, “CONNECTED”); tmrCallMethod.Enabled = true; } catch(Exception ex) { lines.Insert(0, “FAILED:”); lines.Insert(0, ex.Message); lines.Insert(0, ex.StackTrace); } btnConnect.Text = (connected)?“Disconnect”:“Connect”; txtResult.Lines = (string []) lines.ToArray(typeof(string)); } private void disconnect() { try { lines.Insert(0, “DISCONNECTING”); connected = false; tmrCallMethod.Enabled = false; axapta.Logoff(); lines.Insert(0, “DISCONNECTED”); } catch(Exception ex) { lines.Insert(0, “FAILED:”); lines.Insert(0, ex.Message); lines.Insert(0, ex.StackTrace); } btnConnect.Text = (connected)?“Disconnect”:“Connect”; txtResult.Lines = (string []) lines.ToArray(typeof(string)); } private void selectConfig() { string [] configurationNames; int selectedIndex = -1; int currentIndex = 0; RegistryKey key; //Populate the configuration list from the registry key = Registry.CurrentUser.OpenSubKey(AXAPTA_30_REGKEY); if(null == key) { key = Registry.LocalMachine.OpenSubKey(AXAPTA_30_REGKEY); } if(null != key) { lstConfig.Items.Clear(); configurationNames = key.GetSubKeyNames(); foreach(string configurationName in configurationNames) { if(configurationName.Equals(config)) { selectedIndex = currentIndex; } lstConfig.Items.Add(configurationName); currentIndex++; } //Check for a non matching config, and set the selection if(-1 == selectedIndex) { selectedIndex = 0; config = configurationNames[selectedIndex]; } lstConfig.SelectedIndex = selectedIndex; } else { lines.Insert(0, “Registry key “+AXAPTA_30_REGKEY+” not found.”); } txtResult.Lines = (string []) lines.ToArray(typeof(string)); } private void tmrCallMethod_Tick(object sender, System.EventArgs e) { int outTickCount; int retTickCount; int inTickCount; try { outTickCount = Environment.TickCount; axParamList.Size = 0; retTickCount = (int) axapta.CallStaticClassMethodEx(“WinAPI”, “getTickCount”, axParamList); inTickCount = Environment.TickCount; lines.Insert(0, "round trip: "+(inTickCount-outTickCount)+“ms”); } catch (Exception ex) { lines.Insert(0, ex.Message); lines.Insert(0, ex.StackTrace); disconnect(); } txtResult.Lines = (string []) lines.ToArray(typeof(string)); } } }

Hi all. I though I would mention what the end result of this was. After much permission fiddling and checking, we determined that the Axapta configuration tool seems to impose a local user account on the ABC when you stop/start it using the ‘Business Connector’ tab. This means that if you set a use for the ABC to run under in the component services MMC snap-in (in the identities tab on the properties pane), and then stop the service and restart it using the configuration tool, the service is forced to log on as the currently logged on user instead. Moral of the story? The easiest way to prevent hiccups is to ensure the local user has write access to everything needed by the ABC (yes, this sucks).