Creating a MSI Installer with IronBarCode

An MSI (Microsoft Installer) is a Windows installation package that facilitates the management of software installation, updates, and removal. Using an MSI provides a standardized method for installing applications, which is especially beneficial for enterprise-level deployments.

IronBarCode offers tools to seamlessly integrate with your existing application and convert it into an MSI for easy distribution. It ensures reliable installation across various environments and allows developers to select which components to include or exclude.

This tutorial will briefly demonstrate how to create an MSI file from an example barcode application.

Start using IronBarcode in your project today with a free trial.

First Step:
green arrow pointer

Prerequsites

Before we start on the project, please download the Microsoft Visual Studio Installer Projects extension for the MSI build to work.

Create a MSI Installer

We'll use a Windows Forms App (.NET Framework) project to demonstrate its functionality for this example.

Add a Button

  • Navigate to the ToolBox
  • Search for Button
  • Add the button by drag and down onto the windows form.

Add button

Edit the Button Code

Double click on the button component to access the C# code of the form. Below is the logic for the form component, it takes in a barcode and attempts to scan it. This code only scan image and does not work for PDF. Use the ReadPdf method for PDF document.

using IronBarCode;
using IronSoftware.Drawing;
using System;
using System.Drawing;
using System.Windows.Forms;

namespace MsiInstallerSample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All;
            IronSoftware.Logger.LogFilePath = "Default.log";

            IronBarCode.License.LicenseKey = "IRONBARCODE-MYLICENSE-KEY-1EF01";

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.Filter = "Image files (All files (*.*)|*.*";

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        // Load the selected image
                        using (Bitmap bmp = new Bitmap(openFileDialog.FileName))
                        {
                            // Process the image
                            AnyBitmap anyBitmap = AnyBitmap.FromBitmap(bmp);

                            // Configure barcode reader options (customize as needed)
                            var option = new BarcodeReaderOptions
                            {
                                Speed = ReadingSpeed.Detailed,
                                ExpectMultipleBarcodes = true,
                                ScanMode = BarcodeScanMode.Auto,
                            };

                            BarcodeResults result = IronBarCode.BarcodeReader.Read(anyBitmap, option);

                            if (result.Count > 0)
                            {
                                string output = string.Empty;
                                foreach(var barcode in result)
                                {
                                    Console.WriteLine($"Barcode Found: {barcode.Text}");
                                    output += barcode.Text + "\n";
                                }

                                MessageBox.Show($"Detected Barcodes: \n{output}");
                            }
                            else
                            {
                                MessageBox.Show("No Barcode found.");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show($"{ex.Message}");
                    }
                }
            }
        }
    }
}
using IronBarCode;
using IronSoftware.Drawing;
using System;
using System.Drawing;
using System.Windows.Forms;

namespace MsiInstallerSample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All;
            IronSoftware.Logger.LogFilePath = "Default.log";

            IronBarCode.License.LicenseKey = "IRONBARCODE-MYLICENSE-KEY-1EF01";

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.Filter = "Image files (All files (*.*)|*.*";

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        // Load the selected image
                        using (Bitmap bmp = new Bitmap(openFileDialog.FileName))
                        {
                            // Process the image
                            AnyBitmap anyBitmap = AnyBitmap.FromBitmap(bmp);

                            // Configure barcode reader options (customize as needed)
                            var option = new BarcodeReaderOptions
                            {
                                Speed = ReadingSpeed.Detailed,
                                ExpectMultipleBarcodes = true,
                                ScanMode = BarcodeScanMode.Auto,
                            };

                            BarcodeResults result = IronBarCode.BarcodeReader.Read(anyBitmap, option);

                            if (result.Count > 0)
                            {
                                string output = string.Empty;
                                foreach(var barcode in result)
                                {
                                    Console.WriteLine($"Barcode Found: {barcode.Text}");
                                    output += barcode.Text + "\n";
                                }

                                MessageBox.Show($"Detected Barcodes: \n{output}");
                            }
                            else
                            {
                                MessageBox.Show("No Barcode found.");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show($"{ex.Message}");
                    }
                }
            }
        }
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Adding a Setup Project

After setting up the form and its controller logic, we need to add a Setup Project to the existing solution to create an MSI installer. The Setup Project allows us to build an installer for the application we just created.

Right-click on the solution, then go to Add > New Project...

Add Setup Project

For the MSI installer, build the MsiInstallerSample project again in Release mode. Right-click on the Setup Project, then go to Add > Project Output...

Add project output

To ensure the MSI installer runs smoothly, you must include the following three files in your setup project: onnxruntime.dll, IronBarcodeInterop.dll, and ReaderInterop.dll. These files are generated when you build the project in Release mode:

  • onnxruntime.dll: Located at MsiInstallerSample\MsiInstallerSample\bin\Release
  • IronBarcodeInterop.dll: Located at MsiInstallerSample\MsiInstallerSample\bin\Release\runtimes\win-x86\native
  • ReaderInterop.dll: Located at MsiInstallerSample\MsiInstallerSample\bin\Release\runtimes\win-x86\native

Add additional DLLs

If any of these files is missing, you may encounter the following exception message, as noted in this troubleshooting article: Missing DLLs in Creating MSI Installer

Finally, build the Setup Project. The installer will be located at: MsiInstallerSample\SetupProject\Release

Run & Test the Installer

We install the application with the MSI file to ensure everything is running smoothly.

Demonstration related to Run & Test the Installer

Download MSI Installer Sample Project

You can download the complete code for this guide. It comes as a zipped file that you can open in Visual Studio as a WinFormApp project.

Download the WinForm MSI App Project

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...Read More