System.TypeInitializationException: The type initializer for ‘Sdl’ threw an exception. —> System.Exception: Failed to load SDL library.
at Sdl.GetNativeLibrary () [0x00117] in :0
at Sdl…cctor () [0x00000] in :0
— End of inner exception stack trace —
at Microsoft.Xna.Framework.GamePlatform.PlatformCreate (Microsoft.Xna.Framework.Game game) [0x00000] in :0
at Microsoft.Xna.Framework.Game…ctor () [0x00213] in :0
at DigitalJigsawPuzzleSteam.Game1…ctor () [0x0000b] in /Users/Findling/Projects/DigitalJigsawPuzzle/DigitalJigsawPuzzle/Game1.cs:21
at DigitalJigsawPuzzleSteam.Program.Main (System.String[] args) [0x00001] in /Users/Findling/Projects/DigitalJigsawPuzzle/DigitalJigsawPuzzle/Main.cs:24
Can anyone give me advice on how to fix this? Trying to port game to macOS and encountered this error. It is failing on my public Game1: Game { } class in Game1.cs.
Is there something about the use of “Game” on macOS I’m not aware of?
I just tried to create a project and was getting this error too. The only way I could get it to work was to use a project that was created on a Windows computer. Maybe it puts the SDL libraries in the correct place.
I have exactly the same problem, but I found it compiles on macOS 10.13.6 (High Sierra), but produces the error on macOS 10.15.3 (Catalina). I triple-checked all the installed path, and actual paths in source code, and they are all same on two machines. Why is it so and how can I fix it (if possible)? Any help would be appreciated.
I am using:
VS 2019 for Mac 8.4.8
.NET Core SDK 3.1.101 for template creation
MonoGame.Content.Builder 3.7.0.9
MonoGame.Framework.DesktopGL.Core 3.8.0.2
What I do to compile:
I created a project in CLI using dotnet core (dotnet new mgdesktopgl -o mygame), opened it on VS 2019 for Mac, and pressed big shinny “Run” button.
Adding my error msg here for more clarity:
Unhandled exception. System.TypeInitializationException: The type initializer for 'Sdl' threw an exception. ---> System.Exception: Failed to load SDL library. at Sdl.GetNativeLibrary() at Sdl..cctor() --- End of inner exception stack trace --- at Microsoft.Xna.Framework.SdlGamePlatform..ctor(Game game) at Microsoft.Xna.Framework.Game..ctor() at mg_launch_test.Game1..ctor() in /Users/myusername/dev/mg-launch-test/Game1.cs:line 12 at mg_launch_test.Program.Main() in /Users/myusername/dev/mg-launch-test/Program.cs:line 10