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

Type or namespace "QRCode" could not be found in new Blazor Server .Net 6 App #377

Open
brentminder opened this issue Jan 15, 2022 · 10 comments

Comments

@brentminder
Copy link

brentminder commented Jan 15, 2022

Type of issue

[X] Bug

Expected Behavior

I'm trying your sample code for QRCoder, and the "QRCode" reference in the code should be found from the using statement:
@using QRCoder
...
QRCode qrCode = new QRCode(qrCodeData);

Current Behavior

I'm getting type or namespace" QRCode "could not be found in a brand new Blazor Server .Net 6 app using your sample code:
@using QRCoder
...
QRCode qrCode = new QRCode(qrCodeData);

Steps to Reproduce (for bugs)

Create a blazor server app and paste this code into the index.razor page:

@page "/"
@using QRCoder
@using System.Drawing
<h1>Hello, world!</h1>
@code {
    protected async override Task OnInitializedAsync()
    {
	QRCodeGenerator qrGenerator = new QRCodeGenerator();
	QRCodeData qrCodeData = qrGenerator.CreateQrCode("The text which should be encoded.", QRCodeGenerator.ECCLevel.Q);
	QRCode qrCode = new QRCode(qrCodeData);
	Bitmap qrCodeImage = qrCode.GetGraphic(20);
	await base.OnInitializedAsync();
    }
}

Your Environment

VS 2022 latest
Nuget QRCoder latest:
.NET 6 Blazor Server

@brentminder brentminder changed the title type or namespace" QRCode "could not be found in Blazor Server .net 6 app Type or namespace "QRCode" could not be found in new Blazor Server .Net 6 App Jan 15, 2022
@2014fighting
Copy link

I have the same problem in version 1.4.3 and use .NET 6

@wengtad
Copy link

wengtad commented Jan 17, 2022

I having the same problem in version 1.4.3 and .NET 6. So I downgraded to 1.4.2.
Reference: #361

@alstan
Copy link

alstan commented Jan 18, 2022

Same here, I had to downgrade.

@heidgert
Copy link

heidgert commented Jan 20, 2022

I experienced the same when upgrading my class lib to .NET 6. Was able to make it work by setting Target OS to Windows on project settings but I would prefer not having to do this, if possible.

@cyberdarius
Copy link

cyberdarius commented Jan 20, 2022

Here explanations and possible solutions.

#361 (comment)

@Anduin2017
Copy link

Same here.

@Strudus
Copy link

Strudus commented Apr 18, 2022

I having the same problem in version 1.4.3 and .NET 6. So I downgraded to 1.4.2. Reference: #361

Work for me by downgrading the version to the 1.4.2

@1973-clinton
Copy link

You can try:

PngByteQrCode OR
BitmapByteQrCode

@philipp-koch
Copy link

For those wondering how to display a QR code in Blazor WASM using .NET 6+, you might want to try this:

@using QRCoder

<img src=@("data:image/png;base64," + System.Convert.ToBase64String(
 PngByteQRCodeHelper.GetQRCode("text you want displayed as QR code", QRCodeGenerator.ECCLevel.Q, 10))) />

@AmeerIT
Copy link

AmeerIT commented Dec 23, 2023

For those wondering how to display a QR code in Blazor WASM using .NET 6+, you might want to try this:

@using QRCoder

<img src=@("data:image/png;base64," + System.Convert.ToBase64String(
 PngByteQRCodeHelper.GetQRCode("text you want displayed as QR code", QRCodeGenerator.ECCLevel.Q, 10))) />

after downgrading to 1.4.2, this inline code worked, thanks for the suggestion

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