ZXing - 使用通用类型 BarcodeWriter<TOutput> 需要 1 个类型参数 ZXing.NET.Mobile

use*_*904 4 c# zxing xamarin.android xamarin

我一直在尝试使用 ZXing.Net.Mobile 和 ZXing.Net.Mobile.Forms 生成 QRCode: https://github.com/Redth/ZXing.Net.Mobile并遇到以下错误:

“严重性代码描述项目文件行抑制状态错误 CS0305 使用通用类型“BarcodeWriter”需要 1 个类型参数 TestApp.Android G:\Tests\TestApp\TestApp\TestApp.Android\SelectedBookingPage.cs 70 Active ”

这是我的代码:

BarcodeWriter writer = new BarcodeWriter()
            {
                Format = BarcodeFormat.QR_CODE,
                Options = new ZXing.Common.EncodingOptions
                {
                    Height = 600,
                    Width = 600
                }
            };
Run Code Online (Sandbox Code Playgroud)

我见过的其他例子像上面一样调用 BarcodeWriter() 就好了,https://csharp.hotexamples.com/examples/ZXing/BarcodeWriter/-/p​​hp- barcodewriter-class-examples.html 列出了一些。

为什么调用 BarcodeWriter 需要类型参数。如何正确实例化 BarcodeWriter 的实例?

Ale*_*dre 8

如果您将 ZXing.Net 与 .Net Standard 一起使用,则必须添加一个附加包,其中包含您要使用的图像处理库的条形码读取器和写入器类的特定实现。

例如,在 Windows 上,您需要使用此包: https: //www.nuget.org/packages/ZXing.Net.Bindings.Windows.Compatibility/

更多信息在这里: https ://github.com/micjahn/ZXing.Net/issues/370