codebude / QRCoder

A pure C# Open Source QR Code implementation
MIT License
4.46k stars 1.09k forks source link

Unable to load shared library 'libgdiplus' #283

Closed eduardoxvii closed 3 years ago

eduardoxvii commented 3 years ago

Type of issue

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

Expected Behavior

Qrcode is not generated in Centos 7

Current Behavior

fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1] An unhandled exception has occurred while executing the request. System.TypeInitializationException: The type initializer for 'Gdip' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'libgdiplus' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibgdiplus: cannot open shared object file: No such file or directory at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output) at System.Drawing.SafeNativeMethods.Gdip..cctor() --- End of inner exception stack trace --- at System.Drawing.SafeNativeMethods.Gdip.GdipCreateBitmapFromScan0(Int32 width, Int32 height, Int32 stride, Int32 format, IntPtr scan0, IntPtr& bitmap) at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format) at QRCoder.QRCode.GetGraphic(Int32 pixelsPerModule, Color darkColor, Color lightColor, Boolean drawQuietZones) at QRCoder.QRCode.GetGraphic(Int32 pixelsPerModule)

Possible Solution (optional)

Steps to Reproduce (for bugs)

Your Environment

Include as many relevant details about the environment you experienced the bug in.

using (MemoryStream ms = new MemoryStream())
            {
                QRCodeGenerator qrGenerator = new QRCodeGenerator();
                var qrCodeData = qrGenerator.CreateQrCode($"{systemInformacoes.getSignConfirmation()}{id}", QRCodeGenerator.ECCLevel.Q);
                var qrCode = new QRCode(qrCodeData);
                var qrCodeImage = qrCode.GetGraphic(10); <-- The error appears here!!!                
}
dnoonan commented 3 years ago

Installing libgdiplus worked for me. I'm on Pop!_OS 20.04.

sudo apt install libgdiplus

eduardoxvii commented 3 years ago

sudo apt install libgdiplus

@dnoonan , worked!!!!! But i needed run: yum install libgdiplus For Linux CentOs 7

Can close!

resting commented 1 year ago

brew install mono-libgdiplus for mac users works