MonoGame icon indicating copy to clipboard operation
MonoGame copied to clipboard

System.TypeInitializationException: 'The type initializer for 'Sdl' threw an exception.'

Open Lancelotbronner opened this issue 2 months ago • 6 comments

Prerequisites

  • [x] I have verified this issue is present in the develop branch
  • [x] I have searched open and closed issues to ensure it has not already been reported.

MonoGame Version

MonoGame 3.8.4

Which MonoGame platform are you using?

MonoGame Cross-Platform Desktop Application (mgdesktopgl)

Operating System

Windows

Description

Starting from a fresh Monogame template, haven't modified anything and it crashes. The SDL2 dll is present next to the executable.

I'm using VS 2026 and Windows 11 on arm if that makes any difference.

Steps to Reproduce

  1. Create new project from latest templates
  2. Run
  3. Crash.

Minimal Example Repo

No response

Expected Behavior

The official templates should at least compile without modifications.

Resulting Behavior

Crash.

Files

No response

Lancelotbronner avatar Oct 14 '25 22:10 Lancelotbronner

VS 2026 and Windows 11 on arm if that makes any difference

It makes a big one.

I believe this is fixed for 3.8.5. You can test a preview by using the 3.8.5-develop.12 nugets.

ThomasFOG avatar Oct 15 '25 08:10 ThomasFOG

Using 3.8.5-develop.12 I get a different crash, I believe it might be the same but VS doesn't catch it?

Here's the whole output, the debugger does attach but doesn't seem to catch the exceptions.

Exception thrown: 'System.DllNotFoundException' in System.Private.CoreLib.dll
Exception thrown: 'System.TypeInitializationException' in MonoGame.Framework.dll

Lancelotbronner avatar Oct 22 '25 02:10 Lancelotbronner

Do you happen to have manually replaced the dll yourself? (if so, you shouldn't)

Maybe try to delete the bin and obj folders before attempting to rebuild, just to make sure that the correct dll gets in the output folder.

Are you running VS for ARM and .NET for ARM?

ThomasFOG avatar Oct 22 '25 07:10 ThomasFOG

I haven't, still happens after deleting the bin and obj folders.

I tried with both .NET8 for ARM via the command-line and VS2026's bundled .NET10 and got the same result.

I'm not sure if VS2026 detected Windows for ARM on download or something but it is running properly on an ARM machine so, I would assume so?

Lancelotbronner avatar Oct 22 '25 12:10 Lancelotbronner

I don't have that issue when running on macOS but it's not a viable workaround (I use Windows-exclusive APIs so it just crashes later with platform exceptions).

Lancelotbronner avatar Oct 22 '25 12:10 Lancelotbronner

Still happens with 3.8.5.develop-13 on the official release of VS2026. @ThomasFOG

Lancelotbronner avatar Nov 20 '25 19:11 Lancelotbronner