question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Base64QRCode does not exist in 1.4.3

See original GitHub issue

Type of issue

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

Expected Behavior

No build errors after minor upgrade of 1.4.2 to 1.4.3

Current Behavior

Upgrading my nuget package dependency from 1.4.2 to 1.4.3 caused build errors in my project, because Base64QRCode could not be found

Possible Solution (optional)

Looks to be related to NET6_0_WINDOWS directives that have been added in this release

Steps to Reproduce (for bugs)

  1. .Net 6 Web App.
  2. Add 1.4.2 QRCoder package
  3. Instantiate a Base64QRCode
  4. Compile / Run and observe no build error
  5. Upgrade to 1.4.3 package
  6. Attempt to build solution. Compiler error: The type or namespace name ‘Base64QRCode’ could not be found (are you missing a using directive or an assembly reference?)

Your Environment

TargetOS of Web App: None. By explicitly setting this to Windows, the compiler error is fixed, but this breaking change shouldn’t be introduced in a patch level version change.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

33reactions
codebudecommented, Dec 13, 2021

Hello @ScottyLightnin ,

this is not bug in QRCoder but more the consequence of breaking changes in Microsoft .NET 6.0.

Explanation - Why are some renderers missing

Up to QRCoder 1.4.2 there was no explicit compilation target for .NET6, thus when apps (that target .NET 6.0) used QRCoder, the package manager/Visual Studio picked the .NET 5.0 binaries when choosing the nearest framework binary. The .NET 5.0 binaries support System.Drawing and thus contain rendering classes like the Base64QRCode which makes use of System.Drawing.

Unfortunately not having .NET 6 as target in QRCoder lead to some serious trouble (see #354, #353) because not everything that works in .NET 5.0 also works in .NET 6.0 or in other words not all binaries/libraries to be available in .NET 5.0 can be expected available on .NET 6.0. Thus it was only consequent to add .NET 6.0 as target frameworks. I think you’re right up to this point?

With adding net6.0 and net6.0-windows as targets, I had to remove the System.Drawing-based renderers for the target net6.0, because Microsoft official says, that System.Drawing from .NET 6.0 on only will be available on Windows platforms: https://docs.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only

TL;DR: It was not my decision to remove the System.Drawing-based renderers from net6.0 target, but I was simply following the breaking changes in .NET 6.0/System.Drawing (as described in the link above).

What can you do now?

You have multiple options:

  • Target your application to net6.0-windows as the renderes like Base64QRCode or QRCode are available there.
  • Use PngByteQRCode or BitmapByteQRCode. They return the QR Code image as byte array. Then simply pass the bytes to Convert.ToBase64String(...) to receive the same output as for Base64QRCode.
  • Stick with QRCoder 1.4.2 which hasn’t the targets for net6.0 and thus via fallback to net5.0 allows you to use Base64QRCode. (The only difference between 1.4.2 and 1.4.3 are the new net6.0 targets as can be seen here: https://github.com/codebude/QRCoder/wiki/Release-notes )

Mid-term solution

Mid-term we will move QRCoder from System.Drawing to ImageSharp, because System.Drawing became a pain in the *** over the years. By replacing it with an alternative graphics lib (currently we aim to ImageSharp) we hope to gain wider support for the different platforms. Note: Since this will bring a lot of breaking changes, this will be released as QRCoder 2.X.X

4reactions
FedericoBernardicommented, Feb 9, 2022

Any time frame for version 2.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

When I am trying to generate QR code from web api in c# ...
1 Answer. Just downgrade to version 1.4. 1 I had the same issue when using 1.4. 3 This fixed the issue for me....
Read more >
QRCoder 1.3.3
QRCoder is a simple library, written in C#.NET, which enables you to create QR Codes. It's licensed under the MIT-license.
Read more >
QRCoder 1.4.3 on NuGet
QRCoder is a simple library, written in C#.NET, which enables you to create QR codes. It hasn't any dependencies to other libraries and...
Read more >
How to easily implement QRCoder in ASP.NET Core using ...
Here I am going to implement the QRCoder library to generate QR Codes in my ASP.NET Core application. I will also be using...
Read more >
Generating a QR code using QRCoder
Clicking to generate the QRCode that would run the DLL gives the error: "Call GerenateQRCode failed. Error Text: Error calling external object ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found