How to update your barcode reading module to work with Dynamic .NET TWAIN 6.x?

Since Dynamic .NET TWAIN 6.0, Dynamsoft Barcode Reader is introduced. It is recommended to use the new library as it provides better performance. This article shows how to upgrade to the latest version of Dynamic .NET TWAIN and use Dynamsoft Barcode Reader.

Option #1[Recommended]: Use the brand new Barcode Reader library with DNT 6.x

Please follow the below steps to update your barcode reading module to work with Dynamic .NET TWAIN 6.x

I. Choose a proper DLL according to your target framework (.Net Framework 2.0/4.0).

Once you install Dynamic .Net TWAIN 6.2, you can find the DLLs in the below paths.
{Install Path}\Redistributable\Assembly\Barcode Reader\For .NETFramework 2.0\ Dynamsoft.BarcodeReader.dll
{Install Path}\Redistributable\Assembly\Barcode Reader\For .NETFramework 4.0\ Dynamsoft.BarcodeReader.dll
For Dynamic .NET TWAIN 6.0 & 6.1,you can find the DLLs in the below paths.
{Install Path}\Redistributable\Barcode Reader\For .NET 2.0\ Dynamsoft.BarcodeReader.dll
{Install Path}\Redistributable\Barcode Reader\For .NET 4.0\ Dynamsoft.BarcodeReader.dll

II. Add the target DLL to the reference of your application.

  • #1. Navigate to the Solution Explorer of VS.
  • #2. Right-click on the item References and click Add Reference.
  • #3. Browse to the target directory that saves the Dynamsoft.BarcodeReader.dll.
  • #4. Choose and add.

III. Add a namespace in your code as below.

using Dynamsoft.Barcode;

IV. Modify your code for barcode detecting.

Please note that the barcode detecting result could be NULL using Dynamsoft.BarcodeReader.dll. Your code may need to be modified for this change.

using Dynamsoft.Barcode;

private void ReadBarcode(){

    //****************** Initialize the barcode reader ******************-//
    BarcodeReader barcodeReader = new BarcodeReader();
    //Activate the component with the key of Dynamsoft Barcode Reader
    barcodeReader.LicenseKeys = "×××";
    //using OR statement to support decoding various formats, PDF417 & QR_Code.
    barcodeReader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.PDF417 | Dynamsoft.Barcode.BarcodeFormat.QR_CODE;
    barcodeReader.ReaderOptions.MaxBarcodesToReadPerPage = xxx;
    System.Drawing.Bitmap bmp = null;
    //**** For Winform application, get barode images in format bitmaps to decode ****-//
    bmp = (Bitmap)this.dynamicDotNetTwain1.GetImage(this.dynamicDotNetTwain1.CurrentImageIndexInBuffer);
    //**** For WPF application, get barode images in format bitmaps to decode ****-//
    bmp = this.dynamicDotNetTwain1.GetBitmap(dynamicDotNetTwain1.CurrentImageIndexInBuffer);
    //****************** Display the result ******************-// 
   	BarcodeResult[] aryResult = barcodeReader.DecodeBitmap(bmp);
    if (aryResult != null)//result could be null
      	for (int i = 0; i < aryResult.Length; i++)
          		BarcodeResult objResult = aryResult[i];
          		Console.Out.WriteLine("Result " + (i + 1));
          		Console.Out.WriteLine("BarcodeFormat: " + objResult.BarcodeFormat.ToString());
          		Console.Out.WriteLine("Text read: " + objResult.BarcodeText);

If you’d like to check with a running sample, please refer to the Read 1D and 2D barcodes sample in the Programming Guide of Dynamic .Net TWAIN SDK. For WPF application, please refer to the Scan document in WPF App.

Option #2[Deprecated]: Keep using the old barcode reader add-on of Dynamic .NET TWAIN 5.x

This option is only available for the customers who upgraded Dynamic .NET TWAIN from v4.x/5.x to v6.x and don't want to modify the code. If so, please make sure the old Barcode libraries are included in your project and referred to correctly. Then you need to register the old barcode license through the property LicenseKeys as below.

// XXX is the 4.x or 5.x barcode reader license
dynamicDotNetTwain1.LicenseKeys = "XXX";

IMPORTANT: Option #2 only works when the barcode license version agrees with the barcode libraries'. I.e. v4 barcode libraries need a v4 license. Dynamsoft will no longer maintain the old barcode library. So we sincerely recommend you the Option#1.

If you need any assistance or have any problem, please feel free to contact us.

Is this page helpful?

Leave a Reply

Your email address will not be published.