Я использую сканер штрих-кода Zxing в пустом проекте следующим образом:
XAML:
С#
с использованием ZXing.Net.Maui; пространство имен CameraTest; общедоступный частичный класс MainPage: ContentPage { число интервалов = 0; публичная главная страница() { ИнициализироватьКомпонент(); cameraBarcodeReaderView.Options = новые параметры BarcodeReaderOptions { Форматы = BarcodeFormats.OneDimensional, Автоповорот = правда, Несколько = правда }; } } MauiProgram.cs
с использованием ZXing.Net.Maui; использование Microsoft.Extensions.Logging; пространство имен CameraTest; общедоступный статический класс MauiProgram { общедоступный статический MauiApp CreateMauiApp() { вар строитель = MauiApp.CreateBuilder(); строитель .UseMauiApp() .UseBarcodeReader() .ConfigureFonts(шрифты => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); }); #if ОТЛАДКА builder.Logging.AddDebug(); #endif вернуть строитель.Build(); } } Информационный.plist:
NSCameraUsageDescription Это приложение использует сканирование штрих-кода, чтобы... Но при запуске приложения на симуляторе iOS 16.4 для iPhone 14 я получаю следующую ошибку. Кстати, я не написал ни строчки собственного кода.
Что не так со штрих-кодом Zxing?

{System.ArgumentNullException: значение не может быть нулевым. (Параметр «устройство») в ObjCRuntime.ThrowHelper.ThrowArgumentNullException (имя аргумента String) в ObjCRuntime.NativeObjectExtensions.GetNonNullHandle (INativeObject self, строковое имя аргумента) в AVFoundation.AVCaptureDeviceInput..ctor (устройство AVCaptureDevice, NSError& ошибка) в ZXing.Net.Maui.CameraManager.UpdateCamera() в ZXing.Net.Maui.CameraManager.UpdateCameraLocation (CameraLocation cameraLocation) в ZXing.Net.Maui.CameraBarcodeReaderViewHandler.c.b__24_1 (обработчик CameraBarcodeReaderViewHandler, ICameraBarcodeReaderView virtualView) в Microsoft.Maui.PropertyMapper`2.c__DisplayClass5_0[[ZXing.Net.Maui.ICameraBarcodeReaderView, ZXing.Net.Maui, Version=1.0.2.0, Culture=neutral, PublicKeyToken=null],[ZXing.Net.Maui. CameraBarcodeReaderViewHandler, ZXing.Net.Maui, Version=1.0.2.0, Culture=neutral, PublicKeyToken=null]].b__0(IElementHandler h, IElement v) в Microsoft.Maui.PropertyMapper.UpdatePropertyCore (строковый ключ, IElementHandler viewHandler, IElement virtualView) в Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) в Microsoft.Maui.Handlers.ElementHandler.SetVirtualView (представление IElement) в Microsoft.Maui.Handlers.ViewHandler`2[[ZXing.Net.Maui.ICameraBarcodeReaderView, ZXing.Net.Maui, Version=1.0.2.0, Culture=neutral, PublicKeyToken=null],[UIKit.UIView, Microsoft.iOS, Версия = 16.4.0.0, Культура = нейтральная, PublicKeyToken = 84e04ff9cfb79065]].SetVirtualView (представление IView) в Microsoft.Maui.Handlers.ViewHandler`2[[ZXing.Net.Maui.ICameraBarcodeReaderView, ZXing.Net.Maui, Version=1.0.2.0, Culture=neutral, PublicKeyToken=null],[UIKit.UIView, Microsoft.iOS, Версия = 16.4.0.0, Культура = нейтральная, PublicKeyToken = 84e04ff9cfb79065]].SetVirtualView (представление IElement) в Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) в Microsoft.Maui.Controls.Element.set_Handler (значение IElementHandler) в Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler (значение IElementHandler) в Microsoft.Maui.Platform.ElementExtensions.ToHandler (представление IElement, контекст IMauiContext) в Microsoft.Maui.Platform.ElementExtensions.ToPlatform (представление IElement, контекст IMauiContext) в Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView (представление IView) в Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Версия = 1.0.0.0, Культура = нейтральная, PublicKeyToken = null]].SetVirtualView (представление IElement) в Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) в Microsoft.Maui.Controls.Element.set_Handler (значение IElementHandler) в Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler (значение IElementHandler) в Microsoft.Maui.Platform.ElementExtensions.ToHandler (представление IElement, контекст IMauiContext) в Microsoft.Maui.Platform.ElementExtensions.ToPlatform (представление IElement, контекст IMauiContext) в Microsoft.Maui.Handlers.ScrollViewHandler.UpdateContentView (IScrollView ScrollView, обработчик IScrollViewHandler) в Microsoft.Maui.Handlers.ScrollViewHandler.MapContent (обработчик IScrollViewHandler, IScrollView ScrollView) в Microsoft.Maui.PropertyMapper`2.c__DisplayClass5_0[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IScrollViewHandler, Microsoft. Мауи, версия = 1.0.0.0, культура = нейтральная, PublicKeyToken = null]].b__0(IElementHandler h, IElement v) в Microsoft.Maui.PropertyMapper.UpdatePropertyCore (строковый ключ, IElementHandler viewHandler, IElement virtualView) в Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) в Microsoft.Maui.Handlers.ElementHandler.SetVirtualView (представление IElement) в Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[UIKit.UIScrollView, Microsoft.iOS, Version=16.4. 0.0, Culture=нейтрально, PublicKeyToken=84e04ff9cfb79065]].SetVirtualView(представление IView) в Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[UIKit.UIScrollView, Microsoft.iOS, Version=16.4. 0.0, Culture=нейтрально, PublicKeyToken=84e04ff9cfb79065]].SetVirtualView(представление IElement) в Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) в Microsoft.Maui.Controls.Element.set_Handler (значение IElementHandler) в Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler (значение IElementHandler) в Microsoft.Maui.Platform.ElementExtensions.ToHandler (представление IElement, контекст IMauiContext) в Microsoft.Maui.Platform.ElementExtensions.ToPlatform (представление IElement, контекст IMauiContext) в Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent (обработчик IContentViewHandler) в Microsoft.Maui.Handlers.ContentViewHandler.MapContent (обработчик IContentViewHandler, страница IContentView) в Microsoft.Maui.PropertyMapper`2.c__DisplayClass5_0[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IContentViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].b__0(IElementHandler h, IElement v) в Microsoft.Maui.PropertyMapper.UpdatePropertyCore (строковый ключ, IElementHandler viewHandler, IElement virtualView) в Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) в Microsoft.Maui.Handlers.ElementHandler.SetVirtualView (представление IElement) в Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Версия = 1.0.0.0, Культура = нейтральная, PublicKeyToken = null]].SetVirtualView (представление IView) в Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView (представление IView) в Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Версия = 1.0.0.0, Культура = нейтральная, PublicKeyToken = null]].SetVirtualView (представление IElement) в Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) в Microsoft.Maui.Controls.Element.set_Handler (значение IElementHandler) в Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler (значение IElementHandler) в Microsoft.Maui.Platform.ElementExtensions.ToHandler (представление IElement, контекст IMauiContext) в Microsoft.Maui.Platform.ViewExtensions.ToHandler (представление IView, контекст IMauiContext) в Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.SetPageRenderer (страница страницы, ShellContent ShellContent) в Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.LoadRenderers() в Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.ViewDidLoad() в UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr имя_принципалкласса, IntPtr имя_делегата) в UIKit.UIApplication.Main(String[] args, Тип PrincipalClass, Тип DelegateClass) в CameraTest.Program.Main(String[] args) в D:\Maui\annex_apps\CameraTest\CameraTest\Platforms\iOS\Program.cs:line 13}