Setting up the COM server

AxisVM supports Microsoft COM technology allowing other programs to interact with it. Any program can launch AxisVM, build models, run calculations and get the analysis results through the COM server. Several Programming languages can be used to control AxisVM through the COM server, such as C#, Python, Delphi or even Excel using Excel VBA. This article will show the required steps to configure the AxisVM COM server and interact with AxisVM software. Visual Studio and C# are used in this article, but similar procedures can be followed in the case of other programming languages and IDEs.

Registration #

The COM server must be registered in the registry of the operating system to allow the IDEs (e.g., Visual Studio, Delphi IDE, Visual Basic Editor in Excel, and others) to see the AxisVM type library. The COM server is registered automatically during the installation of AxisVM. The IDE will show all the registered versions of the COM server.

Starting AxisVM through the COM server #

Here, Visual Studio 2022 and C# programming language are used to create a project and establish a connection to AxisVM through the COM server. The project will be a Windows Form App with a single button to run AxisVM. 

Adding the COM server library to Visual Studio. #

  • Create a new project using Visual Studio, as shown in the screenshots below, where a Windows From App is chosen, and the required details of the project are filled in.

  • Right-click on the project name (here: AxisVMTutorial) in the solution explorer, and from Add menu, choose COM Reference. The reference manager window will appear, and in the search bar, type AxisVM. Check the checkbox next to AxisVM Library and click OK, as shown in the screenshots below. If there is more than one version of AxisVM, more than one AxisVM library will appear. The AxisVM library would appear in the project Dependencies if it were added successfully to the project. 

Defining the logic to start the COM server #

The OpenAxisVM method shown below is used to define the required steps to start AxisVM. The description of each line code is written next to it. In general, the following steps must be followed:

  • Define a global instance of the IAxisVMApplication interface and initialize it with an object of AxisVMApplication. 
  • Keep checking if AxisVM is loaded using the Loaded property of the AxisVMApplication object.
  • Make AxisVM visible using the Visible property of the AxisVMApplication object.

IAxisVMApplication axisVMApplication;           // Define a global variable for AxisVM.

public int OpenAxisVM(int _MaxWaitTime)         // _MaxWaitTime in seconds.

        {   const int cSleepTime = 100;         // In milliseconds

            int axisVMStatus=0;                 // Variable to track the status of AxisVM.

            uint openTrialTimes = 0;            // Number of times the program is trying to launch AxisVM.

            if (this.axisVMApplication == null) // check if axisVMApplication is not defined.


                this.axisVMApplication = new AxisVMApplication();     //Create an object of AxisVMApplication.

                // Check the status of AxisVM (loaded or not) and the openTrialTimes is less than the maximum trial times. 

                while (((IAxisVMApplication)this.axisVMApplication).Loaded == ELongBoolean.lbFalse && (openTrialTimes < _MaxWaitTime * 1000 / cSleepTime))


                    System.Threading.Thread.Sleep(cSleepTime); // Put the thread to sleep.

                    openTrialTimes++;                                       // Increase the number of trial times after each trial.


                // check if the AxisVM is loaded and assign.

                if (((IAxisVMApplication)this.axisVMApplication).Loaded == ELongBoolean.lbTrue)


                    axisVMStatus = 1;                                       // Assign a value of 1 if loaded.




                    axisVMStatus = -1;                                      // Assign -1 if not loaded.


                // Check if the status is larger than 1 (i.e. loaded).

                if (axisVMStatus > 0)


                    this.axisVMApplication.Visible = ELongBoolean.lbTrue;   // Make AxisVM Visible.




                    this.axisVMApplication = null;                          // Assign null for the object.


                return axisVMStatus;                                        // Return the status of AxisVM.


            return -1;                                                      // Return -1 if there is an defined object.


  • Call the OpenAxisVM method in the project in the required place; as an example here, it is called in the button1_Click method that will be executed when the user clicks on the button, as shown in the figure below.

private void button1_Click(object sender, EventArgs e)


    OpenAxisVM(100);   // Execute the OpenAxisVM method. 


  • Run the Project from Debug menu and start debugging or using the F5 key. The Form with the added button will appear. Click on button 1 to start AxisVM. 
  • To Close AxisVM, the method Quit() of AxisVMApplication object must be called.

Common Problems #

  • Several versions of the COM server are available on the operating system causing failure to connect to AxisVM. 

Solution: Close Visual Studio and any running instance of AxisM. Run UnregComServer.exe as administrator, which is available in the AxisVM installation directory. This will remove the previously registered COM servers. Register the COM server for the required version again by running as administrator !REGISTER_AXISVM.bat or !REGISTER_AXISVM_X64.bat for 32bit or 64bit, respectively. If the problem is not solved, reinstall AxisVM. 

For further information, please refer to AxisVM COM Server Interface.

Powered by BetterDocs