How to achieve QR code recognition in images with ZXing.Net

Dear Guys,

In my UiPath Studio, ZXing.Net (0.16.11) is installed. I need to use the Invoke Code activity to achieve QR code recognition in images. I have created variables: imagePath (String) – input image path, and resultText (String) – output recognition result.

After entering the following code in Edit Code:

vb
Imports ZXing
Imports System.Drawing
Imports System.IO
Try
Dim bitmap As New Bitmap(imagePath)
Dim reader As New BarcodeReader
reader.Options.PossibleFormats = New List(Of BarcodeFormat) From {BarcodeFormat.QR_CODE}
reader.Options.TryHarder = True
reader.AutoRotate = True
Dim result As Result = reader.Decode(bitmap)
If result IsNot Nothing Then
resultText = result.Text
Else
resultText = “no barcode”
End If
bitmap.Dispose()
Catch ex As Exception
resultText = "failure: " & ex.Message
End Try
The following errors occurred:

No compiled code to run
error BC30024: Statement is not valid inside a method. At line 0
error BC30024: Statement is not valid inside a method. At line 1
error BC30024: Statement is not valid inside a method. At line 2
error BC30002: Type ‘BarcodeReader’ is not defined. At line 5
error BC30002: Type ‘BarcodeFormat’ is not defined. At line 6
error BC30451: ‘BarcodeFormat’ is not declared. It may be inaccessible due to its protection level. At line 6
error BC30002: Type ‘Result’ is not defined. At line 9
Variable ‘BarcodeReader’ is missing. Please use Data Manager to recreate it.

Hi,

In InvokeCode, we cannot use Imports statement. Can you try to define it at Import tab or write full namesapce such as System.Drawing.Bitmap.

Or as another approach, we can use Barcode activities package to decode QRcode using Zxing.

Regards,

Thanks for your reply,Yoichi.
I succeeded to use Barcode activities package to decode QRcode but failed to run the automation in Assistant due to lower dependence for automation Acitivities.

Hi,

Do you have any error? Does it fail on another machine?
If it fails to install necessary libraries, adding the following feed’s URL may solve this issue.

https://api.nuget.org/v3/index.json
https://gallery.uipath.com/api/v3/index.json

Regards,

Could not load file or assembly ‘UiPath.UIAutomationNext, Version=25.10.25.0, Culture=neutral, PublicKeyToken=null’. 系统找不到指定的文件。

It is normal in Studio and fail in assisant even on another machine.

Hi,

How about updating UiPath.UiAutomation.Activites package to the latest stable (25.10.26)?

Regards,

Hi Yoichi,

I found the reason from below.I try to use the Zxing library to achieve my target but meet many problems.

met with any solution ? Please share if possible as i am also into the same problem

Hi,

Can you check the following post?

Regards,