Closed Georg1337 closed 3 years ago
Not sure if this is allowed, but for anyone having similar issues, it probably helps to try out this QR-Code lib: https://github.com/manuelbl/QrCodeGenerator
Altough most of the search results for C# QR-Code libs direct to this repository, the one I linked worked well for me. Even tough it took some time to pop out in my searches.
Hi @Georg1337 ,
for me it's working totally fine on Ubuntu Linux with .NET 5.0.202.
Two ideas:
dotnet add package QRCoder
using QRCoder;
) at the beginning of your code file? (Without the using statement you will also get MSB3644-errors...)Hi @Georg1337 ,
for me it's working totally fine on Ubuntu Linux with .NET 5.0.202.
Two ideas:
* Have you installed the package via `dotnet add package QRCoder` * Have you added the using-statement (`using QRCoder;`) at the beginning of your code file? (Without the using statement you will also get MSB3644-errors...)
yes, I did it exactly that way. And as stated, my code does actually work on windows. Seems really strange, that it does not work only for me.
Wait a moment...
/root/temp/imr.qrcodegenerator/QRCodeGenerator.cs(21,17): error CS0246: ...
The error points to line 21. But line 21 in QRCodeGenerator class has no such reference: https://github.com/codebude/QRCoder/blob/master/QRCoder/QRCodeGenerator.cs#L21
Could it be that your program has also a class called "QRCodeGenerator"? If so, dotnet struggles to decide if QRCode should be taken from your project/class or from QRCoder.
Either try to rename your class or reference QRCoder via fullpath like:
// CODE
public List<Bitmap> generate(List<string> GUIDs, int pixelSize = 15)
{
List<Bitmap> qrCodes = new List<Bitmap>();
QRCoder.QRCodeGenerator qrGenerator = new QRCoder.QRCodeGenerator();
foreach (var GUID in GUIDs) {
QRCoder.QRCodeData qrCodeData = qrGenerator.CreateQrCode(GUID, QRCoder.QRCodeGenerator.ECCLevel.H);
QRCoder.QRCode qrCode = new QRCoder.QRCode(qrCodeData);
Bitmap qrCodeImage = qrCode.GetGraphic(pixelSize);
qrCodes.Add(qrCodeImage);
}
return qrCodes;
}
// CODE
Hi @Georg1337 ,
can you try out, if the solution above solves your problem? Or have you settled to another library? (If so, I would close this issue.)
Issue closed due to lack of feedback. If the problem still occurs, please re-open the ticket.
Type of issue
[x] Bug
[ ] Question (e.g. about handling/usage)
[ ] Request for new feature/improvement
Expected Behavior
reference project as "QRCoder" (= pull from nuget.org) and be able to use it in my code
Current Behavior
Windows: works Linux:
Could not load type 'QRCoder.QRCode' from assembly 'QRCoder, Version=1.4.2.0, Culture=neutral, PublicKeyToken=null'
Possible Solution (optional)
Test this library on Debian 10 (haven't tried on other distros, maybe they fail too). Make it compilable OOT
Steps to Reproduce (for bugs)
dotnet add package QRCoder 1.4.1
QRCoder.QRCode
somewhere in codedotnet build
Your Environment
OS: Debian 10
error
Could not load type 'QRCoder.QRCode' from assembly 'QRCoder, Version=1.4.2.0, Culture=neutral, PublicKeyToken=null'
package reference
<PackageReference Include="QRCoder" Version="1.4.1" />
code, that generates error
dotnet version
Note
this does work OOT on windows! After numerous attempts I tried to compile the lib myself. It works OOT on windows 10. Just clone this repo, go to the directory and run dotnet build.
On linux on the otherhand I get:
Since I just need QRCoder, I then switched to the QRCoder directory. After changing
<TargetFrameworks>net35;net40;netstandard1.1;netstandard2.0</TargetFrameworks>
to<TargetFramework>net5.0</TargetFramework>
it compiles. I tried to reference this sub-directory project ($repo-root/QRCoder/QRCoder.csproj
) in my project, but get a similar error, but without the mention of an Assembly (probably because I'm referencing another project):I haven't tried any further, since I think this is strange and I wanted to post this as an issue. To me it seems like QRCoder is just not linux compatible out of the box and needs some adjustments. I will try further to make it compatible with my project. Maybe someone knows what my issue could be. I'm relatively new to .NET cross compiling (developing my app on windows, shipping to linux). Maybe I'm just missing something crucial.
Thanks in advance