当我使用QRCode.dll版本1.3.5或检查了版本1.3.3但出现相同问题时,我无法访问QRCode类或QRCodeGenerator.QRCode。
public void GenerateQRCode(string code)
{
var imgUrl="";
//string code = txtCode.Text;
QRCodeGenerator qrGenerator = new QRCodeGenerator();
QRCodeData qrCodeData = qrGenerator.CreateQrCode(code, QRCodeGenerator.ECCLevel.Q);
QRCode qrCode = new QRCode(qrCodeData);
// I am getting error in above line, or I am using below line of code but getting error. Unable to access QRCode withQRCodeGenerator.
QRCodeGenerator.QRCode qrCode = qrGenerator.CreateQrCode(code, QRCodeGenerator.ECCLevel.Q);
using (Bitmap bitMap = qrCode.GetGraphic(20))
{
using (MemoryStream ms = new MemoryStream())
{
bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte[] byteImage = ms.ToArray();
imgUrl= "data:image/png;base64," + Convert.ToBase64String(byteImage);
}
}
}
上面是我在Web API 2中使用的代码