Home > Net >  Unable to load libgdiplus in Signal R web application with web sockets (Mac OS)
Unable to load libgdiplus in Signal R web application with web sockets (Mac OS)

Time:01-25

I downloaded this repository from GitHub and try to run it on my MacOS laptop. It uses Signal R and web sockets.
It builds, it starts, it works

But when I try to open web socket I get an error:

Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[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 DYLD_PRINT_LIBRARIES environment variable: dlopen(liblibgdiplus, 0x0001): tried: 'liblibgdiplus' (no such file), '/System/Volumes/Preboot/Cryptexes/OSliblibgdiplus' (no such file), '/usr/lib/liblibgdiplus' (no such file, not in dyld cache), 'liblibgdiplus' (no such file), '/usr/local/lib/liblibgdiplus' (no such file), '/usr/lib/liblibgdiplus' (no such file, not in dyld cache)
         at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
         at System.Drawing.SafeNativeMethods.Gdip..cctor()
         --- End of inner exception stack trace ---

I did brew install mono-libgdiplus but it didn't help.

I'm new to C# and Microsoft frameworks so what else can I do? (MacOS Ventura, Apple M1)

Solved: System.Drawing is not supported on my MacOS, so the peaces of code where this library is using should not be executed.

CodePudding user response:

While the project you played with was very well designed for cross platform, it was unfortunately developed before .NET 6 introduced an important breaking change, that System.Drawing related API is only supported on Windows.

Like you found out, commenting out the lines related to System.Drawing works. But if you want similar functionalities, you will have to rewrite that part with another drawing library. There are many such options out there if search engines are used.

  • Related