Erstellung einer Desktop BarCode Anwendung (Scanner/Generator) mit .NET MAUI

This article was translated from English: Does it need improvement?
Translated
View the article in English

Bei einer umfassenden Softwarelösung geht es nicht nur um mobile Zugänglichkeit. Die Fähigkeit zur nativen Bereitstellung auf Desktop-Betriebssystemen wie Windows und macOS ist ebenso wichtig. Dieser plattformübergreifende Ansatz ermöglicht es Unternehmen, die volle Leistung von Workstations für hochvolumige Aufgaben wie Asset-Tracking und Verwaltung zu nutzen.

Ohne angemessene Desktop-Unterstützung werden Arbeitsabläufe unterbrochen oder, schlimmer noch, auf weniger leistungsfähige Geräte verlagert. Dies ist besonders wichtig in der Bestandsverwaltung, wo Büromitarbeiter schnell Stapel von Codes erstellen oder Scans überprüfen müssen, ohne ihren Schreibtisch zu verlassen.

IronBarcode liefert die notwendigen Tools zur Implementierung dieser Funktionen, damit Ihre .NET MAUI-Anwendung auf jedem Computer zuverlässig funktioniert.

In diesem Artikel wird erklärt, wie IronBarcode integriert werden kann, um sowohl einen Desktop Barcode Scanner als auch einen Desktop Barcode Generator zu erstellen.



.NET MAUI Desktop-Anwendung

Die Integration von IronBarcode in eine .NET MAUI-Anwendung ist einfach, da die Bibliothek von Anfang an mit der Desktop-Plattform zusammenarbeitet. In diesem Beispiel werden wir sowohl einen Barcode-Scanner als auch einen Barcode-Generator mit IronBarcode separat erstellen.

Beginnen wir zuerst mit dem BarCode-Scanner.

Barcode-Scanner-Schnittstelle XAML

Für die .NET MAUI-Schnittstelle wird eine einfache Schnittstelle implementiert, die es den Benutzern ermöglicht, Barcode-Bilder über eine Schaltfläche hochzuladen. Die Datei MainPage.xaml im Projekt sollte durch den unten dargestellten Inhalt ersetzt werden.

<?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="MauiApp1.MainPage"
             BackgroundColor="{DynamicResource PageBackgroundColor}">

    <ScrollView>
        <VerticalStackLayout Spacing="25" Padding="30" VerticalOptions="Center">

            <Label Text="Desktop Barcode Scanner"
                   FontSize="32"
                   HorizontalOptions="Center" />

            <Image x:Name="ScannerImage"
                   HeightRequest="300"
                   WidthRequest="400"
                   BackgroundColor="#F0F0F0"
                   Aspect="AspectFit"
                   HorizontalOptions="Center" />

            <Button Text="Select Image to Scan"
                    Clicked="OnScanButtonClicked"
                    HorizontalOptions="Center" 
                    WidthRequest="200"/>

            <Label x:Name="ResultLabel"
                   Text="Result will appear here..."
                   FontSize="20"
                   HorizontalOptions="Center"
                   HorizontalTextAlignment="Center" />

        </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="MauiApp1.MainPage"
             BackgroundColor="{DynamicResource PageBackgroundColor}">

    <ScrollView>
        <VerticalStackLayout Spacing="25" Padding="30" VerticalOptions="Center">

            <Label Text="Desktop Barcode Scanner"
                   FontSize="32"
                   HorizontalOptions="Center" />

            <Image x:Name="ScannerImage"
                   HeightRequest="300"
                   WidthRequest="400"
                   BackgroundColor="#F0F0F0"
                   Aspect="AspectFit"
                   HorizontalOptions="Center" />

            <Button Text="Select Image to Scan"
                    Clicked="OnScanButtonClicked"
                    HorizontalOptions="Center" 
                    WidthRequest="200"/>

            <Label x:Name="ResultLabel"
                   Text="Result will appear here..."
                   FontSize="20"
                   HorizontalOptions="Center"
                   HorizontalTextAlignment="Center" />

        </VerticalStackLayout>
    </ScrollView>

</ContentPage>
XML

Desktop BarCode Scanner Logic CS

Als Nächstes wird die Logik implementiert, die entsteht, wenn der Benutzer auf die Schaltfläche klickt. Ein OnScanButtonClicked-Ereignishandler ist mit der Scan-Schaltfläche in der Benutzeroberfläche verbunden.

PickPhotoAsync wird zuerst verwendet, um den Benutzer den hochzuladenden Barcode auswählen zu lassen, gefolgt von OpenReadAsync, um auf den Dateistrom zuzugreifen. Die Bilddaten werden sofort in einen MemoryStream mit CopyToAsync kopiert. So können die Daten gleichzeitig für die Anzeige des Bildes auf dem Bildschirm und für die Methode Read zum Scannen des Barcodes verwendet werden.

Schließlich wird der Barcodewert in der Benutzeroberfläche angezeigt, wenn ein gültiger Barcode erkannt wird, oder es wird eine rote Meldung angezeigt, die besagt, dass kein Barcode im Bild gefunden wurde.

Hinweis: Ersetzen Sie den Lizenzschlüssel durch Ihren eigenen, bevor Sie die Anwendung testen.

using IronBarCode;

namespace MauiApp1
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
            // Your license key is set here
            IronBarCode.License.LicenseKey = "YOUR_KEY"
        }

        private async void OnScanButtonClicked(object sender, EventArgs e)
        {
            try
            {
                var fileResult = await MediaPicker.Default.PickPhotoAsync();

                if (fileResult != null)
                {
                    // 1. Copy the file content into a byte array or MemoryStream immediately
                    // This ensures we have the data in memory before the file closes
                    byte[] imageBytes;
                    using (var stream = await fileResult.OpenReadAsync())
                    using (var memoryStream = new MemoryStream())
                    {
                        await stream.CopyToAsync(memoryStream);
                        imageBytes = memoryStream.ToArray();
                    }

                    // 2. Set the Image Source for the UI
                    // We give the UI a FRESH stream from the bytes we just saved
                    ScannerImage.Source = ImageSource.FromStream(() => new MemoryStream(imageBytes));

                    // 3. Process the Barcode
                    // We give IronBarcode its OWN fresh stream from the same bytes
                    using (var processingStream = new MemoryStream(imageBytes))
                    {
                        // 4. Read the barcode with Read
                        var results = BarcodeReader.Read(processingStream);

                        // 5. Display barcode results
                        if (results != null && results.Count > 0)
                        {

                            // Successfully found barcode value
                            ResultLabel.Text = $"Success: {results[0].Value}";
                            ResultLabel.TextColor = Colors.Green;
                        }
                        else
                        {
                            // Image uploaded has no barcode or barcode value is not found
                            ResultLabel.Text = "No barcode detected.";
                            ResultLabel.TextColor = Colors.Red;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // Display any exception thrown in runtime
                ResultLabel.Text = $"Error: {ex.Message}";
                ResultLabel.TextColor = Colors.Red;
            }
        }
    }
}
using IronBarCode;

namespace MauiApp1
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
            // Your license key is set here
            IronBarCode.License.LicenseKey = "YOUR_KEY"
        }

        private async void OnScanButtonClicked(object sender, EventArgs e)
        {
            try
            {
                var fileResult = await MediaPicker.Default.PickPhotoAsync();

                if (fileResult != null)
                {
                    // 1. Copy the file content into a byte array or MemoryStream immediately
                    // This ensures we have the data in memory before the file closes
                    byte[] imageBytes;
                    using (var stream = await fileResult.OpenReadAsync())
                    using (var memoryStream = new MemoryStream())
                    {
                        await stream.CopyToAsync(memoryStream);
                        imageBytes = memoryStream.ToArray();
                    }

                    // 2. Set the Image Source for the UI
                    // We give the UI a FRESH stream from the bytes we just saved
                    ScannerImage.Source = ImageSource.FromStream(() => new MemoryStream(imageBytes));

                    // 3. Process the Barcode
                    // We give IronBarcode its OWN fresh stream from the same bytes
                    using (var processingStream = new MemoryStream(imageBytes))
                    {
                        // 4. Read the barcode with Read
                        var results = BarcodeReader.Read(processingStream);

                        // 5. Display barcode results
                        if (results != null && results.Count > 0)
                        {

                            // Successfully found barcode value
                            ResultLabel.Text = $"Success: {results[0].Value}";
                            ResultLabel.TextColor = Colors.Green;
                        }
                        else
                        {
                            // Image uploaded has no barcode or barcode value is not found
                            ResultLabel.Text = "No barcode detected.";
                            ResultLabel.TextColor = Colors.Red;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // Display any exception thrown in runtime
                ResultLabel.Text = $"Error: {ex.Message}";
                ResultLabel.TextColor = Colors.Red;
            }
        }
    }
}
Imports IronBarCode

Namespace MauiApp1
    Partial Public Class MainPage
        Inherits ContentPage

        Public Sub New()
            InitializeComponent()
            ' Your license key is set here
            IronBarCode.License.LicenseKey = "YOUR_KEY"
        End Sub

        Private Async Sub OnScanButtonClicked(ByVal sender As Object, ByVal e As EventArgs)
            Try
                Dim fileResult = Await MediaPicker.Default.PickPhotoAsync()

                If fileResult IsNot Nothing Then
                    ' 1. Copy the file content into a byte array or MemoryStream immediately
                    ' This ensures we have the data in memory before the file closes
                    Dim imageBytes As Byte()
                    Using stream = Await fileResult.OpenReadAsync(), memoryStream = New MemoryStream()
                        Await stream.CopyToAsync(memoryStream)
                        imageBytes = memoryStream.ToArray()
                    End Using

                    ' 2. Set the Image Source for the UI
                    ' We give the UI a FRESH stream from the bytes we just saved
                    ScannerImage.Source = ImageSource.FromStream(Function() New MemoryStream(imageBytes))

                    ' 3. Process the Barcode
                    ' We give IronBarcode its OWN fresh stream from the same bytes
                    Using processingStream = New MemoryStream(imageBytes)
                        ' 4. Read the barcode with Read
                        Dim results = BarcodeReader.Read(processingStream)

                        ' 5. Display barcode results
                        If results IsNot Nothing AndAlso results.Count > 0 Then
                            ' Successfully found barcode value
                            ResultLabel.Text = $"Success: {results(0).Value}"
                            ResultLabel.TextColor = Colors.Green
                        Else
                            ' Image uploaded has no barcode or barcode value is not found
                            ResultLabel.Text = "No barcode detected."
                            ResultLabel.TextColor = Colors.Red
                        End If
                    End Using
                End If
            Catch ex As Exception
                ' Display any exception thrown in runtime
                ResultLabel.Text = $"Error: {ex.Message}"
                ResultLabel.TextColor = Colors.Red
            End Try
        End Sub
    End Class
End Namespace
$vbLabelText   $csharpLabel

Ausgabe mit BarCode-Wert gefunden

Barcodes gefunden Ausgabe

Wie Sie sehen können, zeigt die Anwendung das Barcode-Ergebnis und das hochgeladene Barcode-Bild an.

Ausgabe ohne BarCode-Wert gefunden

Keine BarCodes gefunden Ausgabe

Wenn ein Benutzer ein Bild hochlädt, das keinen Barcode enthält, erscheint die rote Meldung "Keine Barcodes gefunden."

Generator für Desktop BarCodes

Der nächste Teil baut auf demselben Konzept auf, indem IronBarcode in MAUI integriert wird, um einen Barcode-Generator zu erstellen.

BarCode Generator Schnittstelle XAML

Für die Schnittstelle des Generators wurde ein einfaches Formular implementiert, das die Texteingabe und die Auswahl des Barcodetyps über ein Dropdown-Menü ermöglicht. Eine Schaltfläche zum Auslösen des Erstellungs- und Speichervorgangs ist ebenso enthalten wie eine Bildansicht zur Darstellung des Ergebnisses. Die Datei MainPage.xaml sollte durch den unten dargestellten Inhalt ersetzt werden.

Die vollständige Liste der 1D BarCodes finden Sie hier, die der 2D BarCodes hier.

<?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="MauiApp1.MainPage"
             BackgroundColor="{DynamicResource PageBackgroundColor}">

    <ScrollView>
        <VerticalStackLayout Spacing="20" Padding="30" VerticalOptions="Center">

            <Label Text="Barcode Generator"
                   FontSize="32"
                   HorizontalOptions="Center" />

            <Entry x:Name="BarcodeEntry"
                   Placeholder="Enter value (e.g. 12345 or https://ironsoftware.com)"
                   WidthRequest="300" />

            <Picker x:Name="BarcodeTypePicker"
                    Title="Select Barcode Type"
                    WidthRequest="300">
                <Picker.ItemsSource>
                    <x:Array Type="{x:Type x:String}">
                        <x:String>QRCode</x:String>
                        <x:String>Code128</x:String>
                        <x:String>EAN13</x:String>
                        <x:String>Code39</x:String>
                        <x:String>PDF417</x:String>
                    </x:Array>
                </Picker.ItemsSource>
            </Picker>

            <Button Text="Generate &amp; Save"
                    Clicked="OnGenerateButtonClicked"
                    HorizontalOptions="Center"
                    WidthRequest="200" />

            <Image x:Name="GeneratedImage"
                   HeightRequest="200"
                   WidthRequest="300"
                   BackgroundColor="#F0F0F0"
                   Aspect="AspectFit" />

            <Label x:Name="StatusLabel"
                   FontSize="16"
                   HorizontalOptions="Center"
                   HorizontalTextAlignment="Center" />

        </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="MauiApp1.MainPage"
             BackgroundColor="{DynamicResource PageBackgroundColor}">

    <ScrollView>
        <VerticalStackLayout Spacing="20" Padding="30" VerticalOptions="Center">

            <Label Text="Barcode Generator"
                   FontSize="32"
                   HorizontalOptions="Center" />

            <Entry x:Name="BarcodeEntry"
                   Placeholder="Enter value (e.g. 12345 or https://ironsoftware.com)"
                   WidthRequest="300" />

            <Picker x:Name="BarcodeTypePicker"
                    Title="Select Barcode Type"
                    WidthRequest="300">
                <Picker.ItemsSource>
                    <x:Array Type="{x:Type x:String}">
                        <x:String>QRCode</x:String>
                        <x:String>Code128</x:String>
                        <x:String>EAN13</x:String>
                        <x:String>Code39</x:String>
                        <x:String>PDF417</x:String>
                    </x:Array>
                </Picker.ItemsSource>
            </Picker>

            <Button Text="Generate &amp; Save"
                    Clicked="OnGenerateButtonClicked"
                    HorizontalOptions="Center"
                    WidthRequest="200" />

            <Image x:Name="GeneratedImage"
                   HeightRequest="200"
                   WidthRequest="300"
                   BackgroundColor="#F0F0F0"
                   Aspect="AspectFit" />

            <Label x:Name="StatusLabel"
                   FontSize="16"
                   HorizontalOptions="Center"
                   HorizontalTextAlignment="Center" />

        </VerticalStackLayout>
    </ScrollView>

</ContentPage>
XML

Desktop BarCode Generator Logic CS

Als nächstes wird die Logik für das Schaltflächenklick-Ereignis implementiert. Ein OnGenerateButtonClicked-Ereignishandler ist mit der Generierungsschaltfläche in der Benutzeroberfläche verbunden.

Die Benutzereingabe wird validiert, um sicherzustellen, dass der Text vorhanden ist und ein Typ ausgewählt wurde, woraufhin die Auswahl der richtigen BarcodeEncoding zugeordnet wird. BarcodeWriter.CreateBarcode wird verwendet, um das Bild zu erzeugen, seine Größe zu ändern und es in JPEG-Binärdaten zu konvertieren. Das Bild wird dann mit einem MemoryStream auf dem Bildschirm angezeigt.

Abschließend wird die erzeugte Barcode-Datei mit File.WriteAllBytes direkt auf dem Desktop des Benutzers gespeichert, und das Statuslabel wird aktualisiert, um den Speicherort zu bestätigen.

Hinweis: Ersetzen Sie den Lizenzschlüssel durch Ihren eigenen, bevor Sie die Anwendung testen.

using IronBarCode;
using System.IO; // Required for saving files

namespace MauiApp1
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
            IronBarCode.License.LicenseKey = "YOUR-KEY";

            // Set default selection
            BarcodeTypePicker.SelectedIndex = 0;
        }

        private void OnGenerateButtonClicked(object sender, EventArgs e)
        {
            try
            {
                // 1. Get and Validate Input
                string text = BarcodeEntry.Text;

                if (string.IsNullOrWhiteSpace(text))
                {
                    StatusLabel.Text = "Error: Please enter text.";
                    StatusLabel.TextColor = Colors.Red;
                    return;
                }

                if (BarcodeTypePicker.SelectedIndex == -1)
                {
                    StatusLabel.Text = "Error: Please select a type.";
                    StatusLabel.TextColor = Colors.Red;
                    return;
                }

                // 2. Determine Encoding Type
                string selectedType = BarcodeTypePicker.SelectedItem.ToString();
                BarcodeEncoding encoding = BarcodeEncoding.QRCode;

                switch (selectedType)
                {
                    case "QRCode": encoding = BarcodeEncoding.QRCode; break;
                    case "Code128": encoding = BarcodeEncoding.Code128; break;
                    case "EAN13": encoding = BarcodeEncoding.EAN13; break;
                    case "Code39": encoding = BarcodeEncoding.Code39; break;
                    case "PDF417": encoding = BarcodeEncoding.PDF417; break;
                }

                // 3. Generate Barcode
                var barcode = BarcodeWriter.CreateBarcode(text, encoding);
                barcode.ResizeTo(400, 200); // Optional resizing

                // 4. Convert to Bytes (JPEG)
                var bytes = barcode.ToJpegBinaryData();

                // 5. Update UI
                GeneratedImage.Source = ImageSource.FromStream(() => new MemoryStream(bytes));

                // 6. Save to Desktop automatically
                string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                string fileName = $"barcode_{DateTime.Now:yyyyMMdd_HHmmss}.jpg";
                string fullPath = Path.Combine(desktopPath, fileName);

                File.WriteAllBytes(fullPath, bytes);

                // 7. Show Success Message
                StatusLabel.Text = $"Saved to Desktop:\n{fileName}";
                StatusLabel.TextColor = Colors.Green;
            }
            catch (Exception ex)
            {
                StatusLabel.Text = $"Error: {ex.Message}";
                StatusLabel.TextColor = Colors.Red;
            }
        }
    }
}
using IronBarCode;
using System.IO; // Required for saving files

namespace MauiApp1
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
            IronBarCode.License.LicenseKey = "YOUR-KEY";

            // Set default selection
            BarcodeTypePicker.SelectedIndex = 0;
        }

        private void OnGenerateButtonClicked(object sender, EventArgs e)
        {
            try
            {
                // 1. Get and Validate Input
                string text = BarcodeEntry.Text;

                if (string.IsNullOrWhiteSpace(text))
                {
                    StatusLabel.Text = "Error: Please enter text.";
                    StatusLabel.TextColor = Colors.Red;
                    return;
                }

                if (BarcodeTypePicker.SelectedIndex == -1)
                {
                    StatusLabel.Text = "Error: Please select a type.";
                    StatusLabel.TextColor = Colors.Red;
                    return;
                }

                // 2. Determine Encoding Type
                string selectedType = BarcodeTypePicker.SelectedItem.ToString();
                BarcodeEncoding encoding = BarcodeEncoding.QRCode;

                switch (selectedType)
                {
                    case "QRCode": encoding = BarcodeEncoding.QRCode; break;
                    case "Code128": encoding = BarcodeEncoding.Code128; break;
                    case "EAN13": encoding = BarcodeEncoding.EAN13; break;
                    case "Code39": encoding = BarcodeEncoding.Code39; break;
                    case "PDF417": encoding = BarcodeEncoding.PDF417; break;
                }

                // 3. Generate Barcode
                var barcode = BarcodeWriter.CreateBarcode(text, encoding);
                barcode.ResizeTo(400, 200); // Optional resizing

                // 4. Convert to Bytes (JPEG)
                var bytes = barcode.ToJpegBinaryData();

                // 5. Update UI
                GeneratedImage.Source = ImageSource.FromStream(() => new MemoryStream(bytes));

                // 6. Save to Desktop automatically
                string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                string fileName = $"barcode_{DateTime.Now:yyyyMMdd_HHmmss}.jpg";
                string fullPath = Path.Combine(desktopPath, fileName);

                File.WriteAllBytes(fullPath, bytes);

                // 7. Show Success Message
                StatusLabel.Text = $"Saved to Desktop:\n{fileName}";
                StatusLabel.TextColor = Colors.Green;
            }
            catch (Exception ex)
            {
                StatusLabel.Text = $"Error: {ex.Message}";
                StatusLabel.TextColor = Colors.Red;
            }
        }
    }
}
Imports IronBarCode
Imports System.IO ' Required for saving files

Namespace MauiApp1
    Public Partial Class MainPage
        Inherits ContentPage

        Public Sub New()
            InitializeComponent()
            IronBarCode.License.LicenseKey = "YOUR-KEY"

            ' Set default selection
            BarcodeTypePicker.SelectedIndex = 0
        End Sub

        Private Sub OnGenerateButtonClicked(sender As Object, e As EventArgs)
            Try
                ' 1. Get and Validate Input
                Dim text As String = BarcodeEntry.Text

                If String.IsNullOrWhiteSpace(text) Then
                    StatusLabel.Text = "Error: Please enter text."
                    StatusLabel.TextColor = Colors.Red
                    Return
                End If

                If BarcodeTypePicker.SelectedIndex = -1 Then
                    StatusLabel.Text = "Error: Please select a type."
                    StatusLabel.TextColor = Colors.Red
                    Return
                End If

                ' 2. Determine Encoding Type
                Dim selectedType As String = BarcodeTypePicker.SelectedItem.ToString()
                Dim encoding As BarcodeEncoding = BarcodeEncoding.QRCode

                Select Case selectedType
                    Case "QRCode"
                        encoding = BarcodeEncoding.QRCode
                    Case "Code128"
                        encoding = BarcodeEncoding.Code128
                    Case "EAN13"
                        encoding = BarcodeEncoding.EAN13
                    Case "Code39"
                        encoding = BarcodeEncoding.Code39
                    Case "PDF417"
                        encoding = BarcodeEncoding.PDF417
                End Select

                ' 3. Generate Barcode
                Dim barcode = BarcodeWriter.CreateBarcode(text, encoding)
                barcode.ResizeTo(400, 200) ' Optional resizing

                ' 4. Convert to Bytes (JPEG)
                Dim bytes = barcode.ToJpegBinaryData()

                ' 5. Update UI
                GeneratedImage.Source = ImageSource.FromStream(Function() New MemoryStream(bytes))

                ' 6. Save to Desktop automatically
                Dim desktopPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
                Dim fileName As String = $"barcode_{DateTime.Now:yyyyMMdd_HHmmss}.jpg"
                Dim fullPath As String = Path.Combine(desktopPath, fileName)

                File.WriteAllBytes(fullPath, bytes)

                ' 7. Show Success Message
                StatusLabel.Text = $"Saved to Desktop:{Environment.NewLine}{fileName}"
                StatusLabel.TextColor = Colors.Green
            Catch ex As Exception
                StatusLabel.Text = $"Error: {ex.Message}"
                StatusLabel.TextColor = Colors.Red
            End Try
        End Sub
    End Class
End Namespace
$vbLabelText   $csharpLabel

Ausgabe mit generiertem BarCode

BarCode erfolgreich generieren

Wie Sie sehen können, zeigt die Anwendung den generierten Barcode an und speichert ihn auf dem Desktop des Benutzers.

Ausgabefehler

BarCode-Fehler generieren

Bestimmte Barcodetypen haben Einschränkungen und Formatanforderungen für den Eingabewert. Wenn der Barcode nicht generiert werden kann, zeigt die Anwendung die IronBarcode-Ausnahme an, wie oben dargestellt. Für die Formatierung der einzelnen Barcodetypen beachten Sie bitte die entsprechenden detaillierten1D und 2D.

Um die obigen Beispiele (Desktop Barcode Scanner und den Desktop Barcode Generator) zu testen, laden Sie bitte das Beispielprojekt herunter.

Häufig gestellte Fragen

Was ist .NET MAUI?

.NET MAUI ist ein plattformübergreifendes Framework für die Erstellung nativer Mobil- und Desktopanwendungen mit C# und XAML. Es ermöglicht Entwicklern, Anwendungen für Android, iOS, macOS und Windows mit einer einzigen Codebasis zu erstellen.

Wie kann IronBarcode in einer .NET MAUI-Anwendung verwendet werden?

IronBarcode for .NET kann in eine .NET MAUI-Anwendung integriert werden, um die Erzeugung und das Scannen von Barcodes zu ermöglichen. Es bietet eine unkomplizierte Möglichkeit zum Erstellen und Lesen von Barcodes auf mehreren Desktop-Plattformen.

Welche Barcodetypen kann IronBarcode generieren?

IronBarcode unterstützt die Generierung einer Vielzahl von Barcodeformaten, darunter QR-Codes, Code 128, Code 39, UPC, EAN und viele mehr, und ist damit vielseitig für alle Desktop-Anwendungen einsetzbar.

Ist es möglich, Barcodes mit einer mit IronBarcode erstellten Desktop-Anwendung zu scannen?

Ja, IronBarcode kann zum Scannen von Barcodes in Desktop-Anwendungen verwendet werden, so dass Benutzer Barcode-Informationen schnell und effizient über die Benutzeroberfläche der Anwendung dekodieren können.

Welche Vorteile hat die Verwendung von IronBarcode für Barcode-Anwendungen?

IronBarcode bietet hohe Genauigkeit, Geschwindigkeit und Benutzerfreundlichkeit. Es lässt sich nahtlos in .NET MAUI integrieren und bietet umfassende Unterstützung für die Erzeugung und das Scannen von Barcodes in Desktop-Anwendungen.

Kann IronBarcode große Mengen von Barcodedaten verarbeiten?

Ja, IronBarcode wurde entwickelt, um große Mengen an Barcode-Daten effizient zu verarbeiten und eignet sich daher für Anwendungen, die umfangreiche Barcode-Aufgaben zu bewältigen haben.

Benötige ich eine separate Bibliothek für das Scannen und Generieren von Barcodes?

IronBarcode bietet sowohl Barcode-Scan- als auch Barcode-Generierungsfunktionen in einer einzigen Bibliothek und vereinfacht so den Entwicklungsprozess für Desktop-Anwendungen.

Was sind die Systemvoraussetzungen für die Verwendung von IronBarcode for .NET MAUI?

IronBarcode erfordert eine .NET-Umgebung, die mit .NET MAUI kompatibel ist. Es unterstützt Windows, macOS und andere Plattformen, auf denen .NET MAUI-Anwendungen ausgeführt werden können.

Wie gewährleistet IronBarcode die Genauigkeit der Barcodes?

IronBarcode verwendet fortschrittliche Algorithmen, um eine hohe Präzision sowohl bei der Barcode-Erzeugung als auch beim Scannen zu gewährleisten und die Wahrscheinlichkeit von Fehlern bei der Codierung oder Decodierung von Barcode-Daten zu verringern.

Kann IronBarcode sowohl für kommerzielle als auch für private Projekte verwendet werden?

Ja, IronBarcode kann sowohl für kommerzielle als auch für private Projekte verwendet werden und bietet flexible Lizenzierungsoptionen für unterschiedliche Projektanforderungen.

Curtis Chau
Technischer Autor

Curtis Chau hat einen Bachelor-Abschluss in Informatik von der Carleton University und ist spezialisiert auf Frontend-Entwicklung mit Expertise in Node.js, TypeScript, JavaScript und React. Leidenschaftlich widmet er sich der Erstellung intuitiver und ästhetisch ansprechender Benutzerschnittstellen und arbeitet gerne mit modernen Frameworks sowie der Erstellung gut strukturierter, optisch ansprechender ...

Weiterlesen
Bereit anzufangen?
Nuget Downloads 2,070,733 | Version: 2026.2 gerade veröffentlicht