.NET MAUI Scan Barcode in Windows Apps with a Powerful Barcode Scanner Library
You don't need to wrestle with complex camera drivers or endless permission loops to get a barcode scanner working in .NET MAUI. Most developers think "barcode" and immediately start worrying about live camera stream overhead. There’s a better route. By using the IronBarcode .NET library, you can scan barcodes directly from image files, like JPEGs or PNGs, avoiding the headache of camera management entirely. While we’re focusing on Microsoft Windows for this tutorial, the exact same code runs on your Android app and iOS projects too.
Get started with a free trial to follow along.
How Do You Create a .NET MAUI App for Barcode Scanning?
Setting up a .NET MAUI project in Visual Studio Code or Visual Studio is straightforward, for this tutorial, we'll be using Visual Studio. Launch Visual Studio 2022 or later, select Create a new project, and choose the .NET MAUI App template. Enter your project name and select your target platforms, for this tutorial, we're focusing on Windows deployment.
Unlike solutions such as Scanbot SDK that require complex initialization in MauiProgram.cs with var builder configurations and camera preview setup, IronBarcode requires no special registration. The public static class MauiProgram remains unchanged from the default template, making integration remarkably simple for .NET MAUI apps.
To install the IronBarcode NuGet package, you can use the Command Palette (Ctrl+Shift+P in VS Code) or run the following command in the Package Manager Console in Visual Studio:
Install-Package BarCode
This single NuGet package installation provides everything needed for barcode scanning, multi barcode scanning, and QR codes recognition. The latest version supports all major barcode formats without additional dependencies, unlike camera-based scanners that often require permission handlers and CameraView control configurations.
To use IronBarcode in a production environment, you will need to apply a license key. You can set this in your MauiProgram.cs or within the App.xaml.cs constructor:
IronBarCode.License.LicenseKey = "YOUR_IRONBARCODE_LICENSE_KEY";IronBarCode.License.LicenseKey = "YOUR_IRONBARCODE_LICENSE_KEY";IRON VB CONVERTER ERROR developers@ironsoftware.comHandling Permissions for iOS and Android
One of the primary benefits of using an image-based .NET library is the simplified permission model. Traditional camera-based scanners require the following permissions in your AndroidManifest.xml:
<uses-permission android:name="android.permission.CAMERA" /><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
When building for iOS and Android, these required permissions can often lead to "permission denied" errors if not handled perfectly. However, because IronBarcode scans from a var image or file stream, you only need to ensure the app has access to the file system.
What Interface Design Works Best for a MAUI Barcode Scanner?
A clean, functional interface enables users to select an image file containing barcodes and view the scanning results. The following XAML creates a simple but effective barcode scanner UI for your .NET MAUI application:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BarcodeScanner.MainPage">
<ScrollView>
<VerticalStackLayout Spacing="20" Padding="30">
<Label Text="MAUI Barcode Scanner"
FontSize="24"
HorizontalOptions="Center" />
<Button x:Name="SelectImageBtn"
Text="Select Image File"
Clicked="OnSelectImage" />
<Image x:Name="SelectedImageDisplay"
HeightRequest="250" />
<Label x:Name="ResultsLabel"
Text="Barcode results will display here" />
</VerticalStackLayout>
</ScrollView>
</ContentPage><?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BarcodeScanner.MainPage">
<ScrollView>
<VerticalStackLayout Spacing="20" Padding="30">
<Label Text="MAUI Barcode Scanner"
FontSize="24"
HorizontalOptions="Center" />
<Button x:Name="SelectImageBtn"
Text="Select Image File"
Clicked="OnSelectImage" />
<Image x:Name="SelectedImageDisplay"
HeightRequest="250" />
<Label x:Name="ResultsLabel"
Text="Barcode results will display here" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>IRON VB CONVERTER ERROR developers@ironsoftware.comThis layout provides a button for image file selection, an area to display the selected image, and a label for barcode detection results. The design works across all .NET MAUI target platforms while maintaining native performance on Windows.
How Do You Implement Barcode Detection from Image Files?
In your MainPage.xaml.cs, you can use lifecycle methods like async void OnAppearing to initialize settings or check if the user has provided the necessary file access.
The public partial class MainPage contains the scanning logic. IronBarcode's BarcodeReader.Read method handles all the complexity of barcode detection, supporting scanning barcodes from JPEG, PNG, GIF, TIFF, and BMP formats. Here's the complete implementation:
using IronBarCode;
namespace BarcodeScanner;
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private async void OnSelectImage(object sender, EventArgs e)
{
try
{
// Open file picker for image selection
var result = await FilePicker.PickAsync(new PickOptions
{
FileTypes = FilePickerFileType.Images,
PickerTitle = "Select a barcode image"
});
if (result != null)
{
// Display the selected image
var stream = await result.OpenReadAsync();
SelectedImageDisplay.Source = ImageSource.FromStream(() => stream);
// Read barcodes from the image file
var barcodes = BarcodeReader.Read(result.FullPath);
// Display all detected barcode values
if (barcodes.Count > 0)
{
string output = string.Join("\n",
barcodes.Select(b => $"{b.BarcodeType}: {b.Value}"));
ResultsLabel.Text = output;
}
else
{
ResultsLabel.Text = "No barcodes detected in image";
}
}
}
catch (Exception ex)
{
ResultsLabel.Text = $"Error occurred: {ex.Message}";
}
}
}using IronBarCode;
namespace BarcodeScanner;
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private async void OnSelectImage(object sender, EventArgs e)
{
try
{
// Open file picker for image selection
var result = await FilePicker.PickAsync(new PickOptions
{
FileTypes = FilePickerFileType.Images,
PickerTitle = "Select a barcode image"
});
if (result != null)
{
// Display the selected image
var stream = await result.OpenReadAsync();
SelectedImageDisplay.Source = ImageSource.FromStream(() => stream);
// Read barcodes from the image file
var barcodes = BarcodeReader.Read(result.FullPath);
// Display all detected barcode values
if (barcodes.Count > 0)
{
string output = string.Join("\n",
barcodes.Select(b => $"{b.BarcodeType}: {b.Value}"));
ResultsLabel.Text = output;
}
else
{
ResultsLabel.Text = "No barcodes detected in image";
}
}
}
catch (Exception ex)
{
ResultsLabel.Text = $"Error occurred: {ex.Message}";
}
}
}IRON VB CONVERTER ERROR developers@ironsoftware.comOutput

The BarcodeReader.Read method automatically detects and decodes all barcode formats present in the image file. Each result includes the barcode type, value, and location information. This approach eliminates the need for camera permissions, Android- and iOS-specific configurations, or barcode-detection event handling that camera-based solutions like the Scanbot SDK require.
private async void ProcessResults(BarcodeResults barcodes)
{
if (barcodes.Count > 0)
{
string msg = $"Found {barcodes.Count} barcodes.";
// Use await DisplayAlert to show results to the user
await DisplayAlert("Scan Success", msg, "OK");
}
else
{
await DisplayAlert("No Results", "No barcodes were found in the image.", "OK");
}
}private async void ProcessResults(BarcodeResults barcodes)
{
if (barcodes.Count > 0)
{
string msg = $"Found {barcodes.Count} barcodes.";
// Use await DisplayAlert to show results to the user
await DisplayAlert("Scan Success", msg, "OK");
}
else
{
await DisplayAlert("No Results", "No barcodes were found in the image.", "OK");
}
}IRON VB CONVERTER ERROR developers@ironsoftware.comProviding User Feedback with await DisplayAlert
In a mobile or desktop environment, providing immediate feedback is crucial. Instead of updating a label, you can use the await DisplayAlert method to show a modal dialog once the scan is complete. This ensures the user acknowledges the result before continuing.
How Can You Scan Multiple Barcodes and Configure Detection Options?
When your image file contains multiple barcodes, IronBarcode automatically detects them all. For optimized performance when you know the expected barcode types, use BarcodeReaderOptions:
using IronBarCode;
// Configure options for scanning multiple barcodes
var options = new BarcodeReaderOptions
{
ExpectMultipleBarcodes = true,
ExpectBarcodeTypes = BarcodeEncoding.QRCode | BarcodeEncoding.Code128,
Speed = ReadingSpeed.Balanced
};
var barcodes = BarcodeReader.Read(imagePath, options);
// Process each detected barcode
foreach (var barcode in barcodes)
{
Console.WriteLine($"Found: {barcode.Value}");
}using IronBarCode;
// Configure options for scanning multiple barcodes
var options = new BarcodeReaderOptions
{
ExpectMultipleBarcodes = true,
ExpectBarcodeTypes = BarcodeEncoding.QRCode | BarcodeEncoding.Code128,
Speed = ReadingSpeed.Balanced
};
var barcodes = BarcodeReader.Read(imagePath, options);
// Process each detected barcode
foreach (var barcode in barcodes)
{
Console.WriteLine($"Found: {barcode.Value}");
}IRON VB CONVERTER ERROR developers@ironsoftware.comMulti Barcode Scanning Output

Specifying ExpectBarcodeTypes improves scanning speed by focusing detection on relevant formats. The Speed property balances accuracy against performance; use ReadingSpeed.Faster for pristine images or ReadingSpeed.Detailed for challenging scans with rotation or noise.
This flexibility makes the .NET MAUI barcode scanner suitable for diverse scenarios: retail apps reading product codes, warehouse systems processing shipping labels, or document workflows extracting embedded QR codes.
Why Choose Image-Based Barcode Scanning?
Image-based barcode scanning offers distinct advantages for .NET MAUI scan barcode development. While Scanbot SDK and similar tools focus on live camera preview functionality, IronBarcode's approach provides more straightforward integration, consistent behavior across platforms, and the ability to process existing image files from any source, including scanned documents, email attachments, or user uploads.
For Android and iOS deployments, the same code works without modification, no camera permissions or platform-specific configurations required.
Advanced Features: AR Overlay vs. Image Processing
While some SDKs focus on a live AR overlay (Augmented Reality) to highlight barcodes in a camera feed, IronBarcode focuses on high-speed accuracy for static images. This is ideal for cross-platform applications where users might be uploading receipts, shipping labels, or screenshots rather than scanning items "live" in the field.
By eliminating the need for a live camera feed, you reduce battery consumption and avoid the UI flicker often associated with mobile AR components.
Conclusion
Building a .NET MAUI barcode scanner with IronBarcode requires minimal code while delivering robust barcode detection capabilities. The image file-based approach simplifies development by eliminating camera permissions, device-specific configurations, and complex initialization. You focus on your application logic while IronBarcode handles the scanning.
The complete API documentation covers additional features, including PDF barcode reading, batch processing, and advanced image filters. Ready to implement barcode scanning in your cross-platform .NET MAUI project? Purchase a license for production use, or explore the full feature set with a free trial.
Frequently Asked Questions
How can I create a barcode scanner in .NET MAUI?
You can create a barcode scanner in .NET MAUI by using the IronBarcode .NET library, which allows you to scan barcodes directly from image files such as JPEGs or PNGs. This method bypasses the complexity of managing live camera streams.
Can I use IronBarcode for barcode scanning on Android and iOS?
Yes, you can use the same IronBarcode code for barcode scanning on Android and iOS projects. The library is compatible across these platforms, allowing for seamless integration.
What are the benefits of using IronBarcode for .NET MAUI applications?
Using IronBarcode in .NET MAUI applications simplifies barcode scanning by eliminating the need to handle complex camera drivers or permissions. It allows scanning directly from image files, making the process easier and more efficient.
Is it difficult to manage camera streams in .NET MAUI for barcode scanning?
Managing camera streams in .NET MAUI for barcode scanning can be complex due to camera drivers and permission loops. However, with IronBarcode, you can avoid these challenges by scanning barcodes from image files instead.
Does IronBarcode support scanning QR codes as well as barcodes?
Yes, IronBarcode supports scanning both barcodes and QR codes, providing a versatile solution for various types of code scanning needs in your applications.
Is IronBarcode limited to Windows applications only?
No, while this tutorial focuses on Microsoft Windows, IronBarcode is also compatible with Android and iOS, making it a flexible choice for cross-platform development.
What image file formats does IronBarcode support for scanning?
IronBarcode supports scanning from several image file formats, including JPEGs and PNGs, which allows for a wide range of use cases in barcode scanning.









