'When I try to save a QR code from the Zxing library I get an error with the BarcodeWriter class

Currently I want to store my generated qr code as an image in the phone gallery that executes it and then almost at the same time upload it as a backup to Amazon AWS, but when trying to write my qr as image I get errors.

Code:

private void WriteBarcode()
{
    ZXing.BarcodeWriter barcodeWriter = new ZXing.BarcodeWriter
    {
        Format = BarcodeFormat.QR_CODE
    };
    barcodeWriter
        .Write("some string data")
        .Save(@"C:\some path");
}

This code from what I see should have worked but it marks errors in the BarcodeWriter class and I have the following dependencies installed.

Zxing.net
Zxing.Net.Mobile 
Zxing.Net.Mobile.Forms 

Error

Gravedad Código Descripción Proyecto Archivo Línea Estado suprimido Error CS0305 El uso de tipo de tipo genérico 'BarcodeWriter'

Usings:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Xamanimation;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using ZXing.Net.Mobile.Forms;
using ZXing.Mobile;

when I put ZXing.Mobile.BarcodeWriter it gives me an error and says it can't find that namespace



Solution 1:[1]

It works for me if I declare BarcodeWriter with type Image:

var barcodeWriter = new ZXing.BarcodeWriter<Image>();

Solution 2:[2]

You have to add one of the ZXing binding packages to your project. https://www.nuget.org/packages?q=ZXing.Bindings The assemblies in the ZXing.Net package for targets like .Net Standard or .Net Core only contains the basic implementation without a specific image class. That's because the .Net Standard doesn't declare the System.Drawing namespace. There is no Bitmap class or similar available by default for that kind of .Net target. The binding packages provide specific BarcodeWriter and BarcodeReader implementations for different image libraries.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user18783870
Solution 2 Michael