MAUI: Most common pitfalls
A curated list of frequently encountered issues when integrating the barKoder MAUI SDK—and their proven solutions.
1. I received this exception on startup what can it be? #
Issue: **Microsoft.Maui.Platform.HandlerNotFoundException:** 'Handler not found for view Plugin.Maui.Barkoder.Controls.BarkoderView.'
Solution: In your MauiProgram.cs you need to configure the MauiHandler using
.ConfigureMauiHandlers(handlers =>
{
handlers.AddHandler(typeof(BarkoderView), typeof(BarkoderViewHandler));
});
2. Is it possible to use the BarkoderView with an MVVM pattern? #
Solution: You can use IBarkoderDelegate in any class you want; it is not limited only to the content page. Although you need to pass BarkoderView as a parameter to start the scanning process. Here is a code snippet you can try
using Plugin.Maui.Barkoder.Handlers;
using Plugin.Maui.Barkoder.Interfaces;
using Plugin.Maui.Barkoder.Controls;
namespace BarkoderSample
{
public class BarkoderExampleViewModel: IBarkoderDelegate
{
BarkoderView BKDView;
public BarkoderExampleViewModel(BarkoderView barkoderView)
{
BKDView = barkoderView;
// TODO: - Barkoder configuration goes here or on the ContentPage
}
public void StartScanning()
{
BKDView.StartScanning(this);
}
public void DidFinishScanning(BarcodeResult[] result)
{
// TODO: - Handle results here and/or pass to ContentPage
}
}
}
3.We want the scanning area to cover the full screen, not just the square region. #
Solution: The missing thing you need is SetRegionOfInterest. In your SetBarkoderSettings in your xaml.cs file you can use
// Your other settings
scanner.SetRegionOfInterest(0, 0, 100, 100);
This means the ROI will start with 0 from the left and top and fill 100% of the screen
4. Can the MAUI sdk control the scanner timeout? #
Solution: Yes, look at the example below.
private void OnStartScanningBtnClicked(object sender, EventArgs e)
{
BKDView.StartScanning(this);
_ = StopScanHandler();
}
private async Task StopScanHandler()
{
await Task.Delay(TimeSpan.FromSeconds(10.5));
BKDView.StopScanning();
}
5.Can Barkoder expand/convert UPC-E to UPC-A? #
Solution: Yes, you can use the method below to achieve that.
_scanner.SetUPCE1expandToUPCA(true);
_scanner.SetUPCEexpandToUPCA(true);
6. It seems that continuous scanning does not respect the thresholdBetweenDuplicateScans
setting.
#
Solution: The functionsetDuplicatesDelayMs
has been removed in the latest SDK version. However, you can achieve the same behavior by using SetThresholdBetweenDuplicateScans(10)
7.In your demo app there are Camera Settings available: #
- Dynamic Exposure
- Camera Focus and Exposure
- Video Stabilization
Issue: Are those settings also available for .net Maui ?
Solution: Yes — these settings are also available in the .net MAUI version. You can configure them through the following methods on the BarkoderView
instance:
- BKDView.SetDynamicExposure(int level);
- BKDView.SetCentricFocusAndExposure(bool enabled);
- BKDView.SetVideoStabilization(bool enabled);
This allows you to adjust camera exposure, focus, and stabilization behavior in your MAUI app, just like in the demo app.
8. Error occurred while restoring NuGet packages: Could not find a part of the path. #
The issue you're encountering is related to a general Windows limitation on maximum path length (commonly referred to as MAX_PATH
which is 260 characters by default).
Starting with version 1.6.2, some internal paths within the NuGet (especially targeting iOS platforms) became longer, which is likely triggering this issue.
Solution:
You can resolve this on your Windows system by enabling support for long paths. This is a common Windows limitation, not specific to our package.
You can follow the instructions provided in the link below to enable long path support:
Enable long paths on Windows 10 – Autodesk Guide
Once enabled, you should be able to extract and use our latest NuGet version without any issues.
You can also try this scenario.
To ensure everything works correctly, please follow the steps below:
- Enable long path support as outlined in our documentation. This is a required step for proper functionality.
- Make sure the correct Barkoder version (1.6.4) is referenced in your project file. Please avoid using Visual Studio 2022 at this stage.
- Open Windows PowerShell at the solution level.
- Run the following command:
dotnet restore --force
This will install the correct Barkoder version (1.6.4) and resolve any issues related to file paths longer than 256 characters.
5. After completing the steps above, return to Visual Studio 2022 and build the project.
Notice that VS2022 does not and apparently cannot install nuget packages where file path > 256 even though the windows registry has been changed and Local Compute Policy>Computer Configuration>Administrative Templates>All Settings>Enable Win32 long paths also changed.