Creating a C# MSI Installer with IronBarCode

To create an MSI installer with IronBarCode, add a Setup Project to your solution, include the required DLLs (onnxruntime.dll, IronBarcodeInterop.dll, and ReaderInterop.dll), and build the project to generate a distributable MSI package.

An MSI (Microsoft Installer) is a Windows installation package that facilitates software installation, updates, and removal. Using an MSI provides a standardized method for installing applications, which is especially beneficial for enterprise deployments. The MSI format supports advanced features like rollback capabilities, administrative installation points, and Windows Installer service integration.

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. The library supports multiple barcode formats, making it versatile for various business applications.

This tutorial demonstrates how to create an MSI file from an example barcode application that leverages IronBarCode's powerful scanning capabilities.

Quickstart: Generate and Read an MSI Barcode in a Click

Use IronBarcode's simple API to both create and read MSI barcodes with minimal setup. The snippet below shows how easy it is to write an MSI barcode image, then read it back—all in just a couple of lines.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronBarcode with NuGet Package Manager

    PM > Install-Package BarCode

  2. Copy and run this code snippet.

    var msiImg = IronBarCode.BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.MSI).SaveAsImage("msi.png");
    var results = IronBarCode.BarcodeReader.Read("msi.png", new BarcodeReaderOptions { ExpectBarcodeTypes = BarcodeEncoding.MSI });
  3. Deploy to test on your live environment

    Start using IronBarcode in your project today with a free trial
    arrow pointer

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

First Step:
green arrow pointer

What Prerequisites Do I Need Before Starting?

Before starting the project, please download the Microsoft Visual Studio Installer Projects extension for the MSI build to work. Additionally, ensure you have installed IronBarCode via NuGet in your project.

Why Is the Visual Studio Installer Projects Extension Required?

The extension provides the Setup Project template necessary for creating MSI installers in Visual Studio 2022. This extension adds deployment project templates that were removed from Visual Studio after version 2010, allowing developers to create traditional Windows Installer packages.

What Version of .NET Framework Should I Target?

Use Windows Forms App (.NET Framework) for maximum compatibility with MSI deployment scenarios. While IronBarCode supports various .NET platforms, the .NET Framework version ensures the broadest compatibility with Windows systems where MSI installers are typically deployed.

How Do I Create the Initial MSI Installer Project?

For this example, use a Windows Forms App (.NET Framework) project to demonstrate its functionality. This approach provides a familiar UI paradigm for desktop barcode scanning applications.

Which Project Type Works Best for MSI Installers?

Windows Forms applications provide the most straightforward path for creating MSI-deployed barcode scanning applications. They offer native Windows integration and don't require additional runtime dependencies beyond the .NET Framework.

What Are the Key Components of the Demo Application?

The application consists of a form with a button that opens a file dialog to scan barcodes from images. This simple interface demonstrates the core functionality while keeping deployment complexity minimal. For more advanced scenarios, consider exploring reading barcodes from PDFs or implementing async barcode reading.

How Do I Add a Button to the Windows Form?

  • Navigate to the ToolBox
  • Search for Button
  • Add the button by dragging and dropping onto the Windows form

Visual Studio Toolbox showing Button control highlighted under All Windows Forms section for adding to form

Where Can I Find the Button Control?

The Button control is located in the Common Controls section of the Visual Studio Toolbox. If the Toolbox isn't visible, open it from View > Toolbox or press Ctrl+Alt+X.

How Should I Position the Button on the Form?

Center the button on the form or position it where users naturally expect to find the primary action. Consider following Windows UI guidelines for consistent user experience across applications.

How Do I Edit the Button Code to Handle Barcode Scanning?

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 scans images and does not work for PDFs. Use the ReadPdf method for PDF documents. For comprehensive barcode reading options, refer to the barcode reader settings documentation.

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

What Are the Key Components of the Barcode Reading Logic?

The code uses OpenFileDialog to select images, configures BarcodeReaderOptions for detailed scanning, and displays results via MessageBox. The reading speed options can be adjusted based on your performance requirements. The ExpectMultipleBarcodes setting enables reading multiple barcodes from a single image.

How Should I Handle Errors in Production?

Include proper error logging and user-friendly error messages rather than displaying raw exception details. Consider implementing retry logic for barcode not recognized scenarios and providing guidance to users on image quality requirements.

Can I Scan PDF Documents with This Code?

For PDF documents, replace the BarcodeReader.Read method with BarcodeReader.ReadPdf to properly handle PDF barcode extraction. You can also explore PDF-specific barcode reader settings for optimized performance.

Here's an example of how to modify the code for PDF support:

// For PDF documents, use ReadPdf method
if (Path.GetExtension(openFileDialog.FileName).ToLower() == ".pdf")
{
    var pdfResults = BarcodeReader.ReadPdf(openFileDialog.FileName, option);
    // Process PDF results similar to image results
}
// For PDF documents, use ReadPdf method
if (Path.GetExtension(openFileDialog.FileName).ToLower() == ".pdf")
{
    var pdfResults = BarcodeReader.ReadPdf(openFileDialog.FileName, option);
    // Process PDF results similar to image results
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

How Do I Add a Setup Project to Create the MSI?

After setting up the form and its controller logic, add a Setup Project to the existing solution to create an MSI installer. The Setup Project allows you to build an installer for the application you just created. This process packages all necessary components, including IronBarCode dependencies, into a single deployable unit.

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

 related to How Do I Add a Setup Project to Create the MSI?

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

Visual Studio Add Project Output Group dialog showing deployment options for SetupProject with Solution Explorer visible

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

Visual Studio file dialog selecting ReaderInterop.dll to add to setup project with Solution Explorer showing dependencies

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

Why Are These Specific DLLs Required?

IronBarCode depends on these native libraries for ML-based barcode detection and processing capabilities. The onnxruntime.dll provides the machine learning runtime, while IronBarcodeInterop.dll and ReaderInterop.dll handle the native barcode processing operations. These components enable advanced features like image correction and fault tolerance.

What Happens If I Forget to Include These DLLs?

Missing DLLs will cause runtime exceptions when users attempt to scan barcodes after installation. The application may fail to initialize IronBarCode properly, resulting in FileNotFoundException or DllNotFoundException errors.

How Do I Configure the Project Output Settings?

Select "Primary output" when adding project output to include the main executable and its managed dependencies. This ensures all .NET assemblies are included, but remember to manually add the native DLLs mentioned above.

How Do I Run and Test the MSI Installer?

Install the application with the MSI file to ensure everything runs smoothly. Testing should cover both installation and uninstallation scenarios to verify proper deployment.

Visual Studio showing completed installer build with Release folder containing setup.exe and installer files

What Should I Check During Testing?

Verify that the application launches correctly, can open file dialogs, and successfully scans barcodes from test images. Test with various supported barcode formats to ensure comprehensive functionality. Also verify that the license key application works correctly in the deployed environment.

How Can I Troubleshoot Installation Issues?

Enable Windows Installer logging to capture detailed information about any installation failures or missing components. Check the Windows Event Viewer for additional error details and consult the troubleshooting guides for common deployment issues.

Where Can I Download the Complete 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. The sample includes all necessary configuration and demonstrates best practices for MSI deployment.

Download the WinForm MSI App Project

What's Included in the Sample Project?

The download contains a complete Visual Studio solution with the Windows Forms application and configured Setup Project. It includes sample barcode images for testing and demonstrates proper license key configuration for deployment scenarios.

How Do I Open the Downloaded Project?

Extract the ZIP file and open the .sln file in Visual Studio 2022 with the Installer Projects extension installed. Ensure you have the latest version of IronBarCode installed via NuGet Package Manager. For more detailed setup instructions, refer to the API documentation.

Frequently Asked Questions

What DLL files are required when creating an MSI installer with a barcode application?

When creating an MSI installer with IronBarCode, you need to include three essential DLL files: onnxruntime.dll, IronBarcodeInterop.dll, and ReaderInterop.dll. These files ensure that IronBarCode functions properly when your application is deployed via the MSI package.

What prerequisites do I need before creating an MSI installer for my barcode application?

Before creating an MSI installer with IronBarCode, you need to download and install the Microsoft Visual Studio Installer Projects extension for Visual Studio 2022. Additionally, ensure that IronBarCode is installed in your project via NuGet package manager.

How can I quickly generate and read MSI barcodes in C#?

IronBarCode provides a simple API for generating and reading MSI barcodes. You can create an MSI barcode using BarcodeWriter.CreateBarcode() with the MSI encoding type, save it as an image, and then read it back using BarcodeReader.Read() with BarcodeEncoding.MSI specified in the reader options.

What are the advantages of using MSI installers for distributing barcode applications?

MSI installers provide standardized installation methods ideal for enterprise deployments. When combined with IronBarCode, they offer rollback capabilities, administrative installation points, Windows Installer service integration, and ensure reliable installation across various environments while allowing developers to select which components to include.

Does the barcode library support multiple barcode formats in MSI packages?

Yes, IronBarCode supports multiple barcode formats, making it versatile for various business applications. This flexibility allows developers to integrate different barcode types into their MSI-packaged applications based on specific business requirements.

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
Ready to Get Started?
Nuget Downloads 1,990,480 | Version: 2025.12 just released