‘QRCode’ does not contain a definition for ‘GetGraphic’ and no
accessible extension method ‘GetGraphic’ accepting a first argument of
type ‘QRCode’ could be found (are you missing a using directive or an
assembly reference?)
I am tying to Generate QR Code in .Net 6 I am found an error, Tell me Where is my code wrong?
QRCodeGenerator qrCodeGenerator = new();
string data = "Name : " + employeeSalaryGetDetails.Name + "n DOB : " + employeeSalaryGetDetails.DayofBirth.ToString() + "n Email Address : " + employeeSalaryGetDetails.EmailId.ToString();
QRCodeData qrCodeData = qrCodeGenerator.CreateQrCode(data, QRCodeGenerator.ECCLevel.Q);
QRCode qrCoder = new();
qrCoder.Equals(qrCodeData);
Image rqCodeImage = qrCoder.GetGraphic(20);
var bytes = ImageToByteArray(rqCodeImage);
return File(bytes, "image/tmp");
2
Answers
It seems the package is incomplete for .NET6.0 and up, in a new project when I implement
QRCoder
straight from nuget and Include the usingQRCoder
. TypeQRCode
doesn’t exist. The github has some open issues involving this issue. Downgrading to nuget version 1.4.2 might fix your problem.I have tried it and it works. It would look like this:
Note: This is just an example
Try rolling back to version 1.4.1 — the error should go away.