Barcode Xpress for .NET Core v13.9 - Updated
Create Your First Project (Visual Studio)
Getting Started > Create Your First Project (Visual Studio)

Introduction

This step-by-step tutorial will guide you through how to build a complete C# application that analyzes 1D barcodes using Visual Studio.

Steps

  1. Create a new Console App (.NET Core) project:

  2. Place the Project and Solution in the same folder to simplify the directory structure:

  3. Add the Barcode Xpress SDK to your project:

    To let Visual Studio manage your Barcode Xpress dll, add the NuGet package to your project by browsing:

     


    ![](images/net-core-nuget.png)

    If you already have the Barcode Xpress SDK installed on your computer, you can instead add a reference to your project to use the local version:

         

  4. Add the required Microsoft dll’s to the project:

    • Barcode Xpress for .NET Core relies on a Microsoft .NET assembly that is not provided as part of the .NET Core SDK: System.Drawing.Common.

    • You can add them through NuGet or locally using the same method above for Accusoft.BarcodeXpress13.NetCore.dll.

  5. Add using statements to your generated Program.cs:

    using System;
    using System.Drawing;
    using Accusoft.BarcodeXpressSdk;
    namespace MyProject
    {
    
  6. Create instances of Accusoft.BarcodeXpressSdk.BarcodeXpress and System.Drawing.Bitmap:

    using System;
    using System.Drawing;
    using Accusoft.BarcodeXpressSdk;
    namespace MyProject
    {
        class Program
        {
            static void Main(string[] args)
            {
                BarcodeXpress barcodeXpress = new BarcodeXpress();
                System.Drawing.Bitmap bitmap = new Bitmap("barcode.bmp");
            }
        }
    }
    

    The constructor for System.Drawing.Bitmap takes a string which contains a path. Pass in a path to whatever image you would like to find barcodes in.

  7. Pass the bitmap to BarcodeXpress and access returned results:

    namespace MyProject
    {
        class Program
        {
            static void Main(string[] args)
            {
                BarcodeXpress barcodeXpress = new BarcodeXpress();
    
                System.Drawing.Bitmap bitmap = new Bitmap("barcode.bmp");
    
                                Accusoft.BarcodeXpressSdk.Result[] results = barcodeXpress.reader.Analyze(bitmap);
    
                                if (results.Length > 0)
                {
                    foreach (Accusoft.BarcodeXpressSdk.Result result in results)
                    {
                        Console.WriteLine("{0} : {1}", result.BarcodeType.ToString(), result.BarcodeValue);
                    }
                }
                else
                {
                    Console.WriteLine("No Barcodes Found.");
                }
            }
        }
    }
    

    BarcodeXpress.reader.Analyze returns an array of Result objects which contain information about all barcodes detected on the page. You can iterate over that array to access all known properties of each barcode.

  8. Finally, clean up the Barcode Xpress object by releasing unmanaged resources using the Dispose() method:

    namespace MyProject
    {
        class Program
        {
            static void Main(string[] args)
            {
                BarcodeXpress barcodeXpress = new BarcodeXpress();
    
                System.Drawing.Bitmap bitmap = new Bitmap("barcode.bmp");
    
                                Accusoft.BarcodeXpressSdk.Result[] results = barcodeXpress.reader.Analyze(bitmap);
    
                                if (results.Length > 0)
                {
                    foreach (Accusoft.BarcodeXpressSdk.Result result in results)
                    {
                        Console.WriteLine("{0} : {1}", result.BarcodeType.ToString(), result.BarcodeValue);
                    }
                }
                else
                {
                    Console.WriteLine("No Barcodes Found.");
                }
                barcodeXpress.Dispose();
            }
        }
    }
    
Is this page helpful?
Yes No
Thanks for your feedback.