Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QRCode class not found after updating from 1.4.2 to 1.6.0 #577

Open
badrshs opened this issue Sep 17, 2024 · 1 comment
Open

QRCode class not found after updating from 1.4.2 to 1.6.0 #577

badrshs opened this issue Sep 17, 2024 · 1 comment

Comments

@badrshs
Copy link

badrshs commented Sep 17, 2024

Type of issue

[x] Bug
[ ] Question (e.g. about handling/usage)
[ ] Request for new feature/improvement

Expected Behavior

The QRCode class should be found and usable after updating to the latest version of QRCoder 1.4.2 -> 1.6.0. The following code should compile and work as it did with previous versions:

using var qrCode = new QRCode(qrCodeData);

Current Behavior

After updating to the latest version of QRCoder, the QRCode class can no longer be found. The compiler throws an error:

Error (active) CS0246 The type or namespace name 'QRCode' could not be found (are you missing a using directive or an assembly reference?)

This is breaking existing code that was working fine with previous versions 1.4.2.

Steps to Reproduce (for bugs)

  1. Update QRCoder to the latest version
  2. Use the following code:
using System.Drawing;
using X.Core.Services;
using QRCoder;

namespace X.Services;

public class QrCodeGenerator : IQrCodeGenerator
{
    public Bitmap GenerateQrCode(string text) => GenerateQrCode(text, 10);

    private Bitmap GenerateQrCode(string text, int size)
    {
        using var qrGenerator = new QRCodeGenerator();
        QRCodeData qrCodeData = qrGenerator.CreateQrCode(text, QRCodeGenerator.ECCLevel.Q);
        using var qrCode = new QRCode(qrCodeData); // Error occurs here
        return qrCode.GetGraphic(size);
    }
}

Your Environment

  • Version used: 1.6.0
  • Compiled from source or NuGet package?: NuGet package
  • Used payload generator: QRCodeGenerator
  • Environment net8.0

Additional context:

  • Operating System: Windows
  • This code was working fine until the update from 1.4.2 -to 1.6.0.
@badrshs badrshs changed the title QRCode class not found after updating from to latest version QRCode class not found after updating from 1.4.2 to 1.6.0 Sep 17, 2024
@badrshs
Copy link
Author

badrshs commented Sep 17, 2024

after some search I was able to fix this by doing

[SuppressMessage("Interoperability", "CA1416:Validate platform compatibility")]
private Bitmap GenerateQrCode(string text, int size)
{
    using var qrGenerator = new QRCodeGenerator();
    using QRCodeData qrCodeData = qrGenerator.CreateQrCode(text, QRCodeGenerator.ECCLevel.Q);
    using var qrCode = new PngByteQRCode(qrCodeData);
    byte[] qrCodeAsPngByteArr = qrCode.GetGraphic(size);

    using var ms = new MemoryStream(qrCodeAsPngByteArr);
    return new Bitmap(ms);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant