ExecutionEngineException on Discord.RunCallbacks in C# (WPF)
Describe the bug Sometimes my app crashes because of an ExecutionEngineException thrown in the discord_game_sdk.dll
Steps to reproduce Steps to reproduce the behavior:
- Create a C# WPF project in VS
- Implement a loop calling Discord.RunCallbacks()
- Implement some basic lobby/activity creation
- Debug it and the error should appear
Expected behavior No ExecutionEngineExceptions
Implementation specifics
- Language: C#
- Game Engine: None (.net 5.0)
That's a vague error type, and those are unspecific steps to reproduce. That's not a blame, it's the error being very generic. According to Microsoft Docs, an ExecutionEngineException is "The exception that is thrown when there is an internal error in the execution engine of the common language runtime."
I want you to confirm some things:
- You are doing this on a classic Win32 application, and you have Discord open when trying to connect?
- When the exception doesn't happen, is everything working? Can you get your current username for example?
- I initially had fatal crashes in my C# app too. This was because there is a bug in the bindings the SDK provides. Check out https://github.com/discord/gamesdk-and-dispatch/issues/36, and my suggestion to fix this "easily": https://github.com/discord/gamesdk-and-dispatch/issues/36#issuecomment-774548288
- Does it still happen? Could you please provide any error message and stack trace of the exception when it is thrown?
Note: I'm not a Discord developer, only just like you a developer who has once worked with the Game SDK. Also, the Game SDK is barely or not maintained at the moment, so if I can't help you, you might need to change your plans.
Next, there is a server where developers using the Game SDK help each other: go to discord.gg/discord-developers, and after having joined, it's the #game-sdk channel. Make sure to have read the #rules first though.
I had a similar issue and I believe it's caused by garbage-collected delegates. It's a bug in Core.cs that is yet to be fixed.
There's details here on how to fix it: https://github.com/discord/gamesdk-and-dispatch/issues/102
Since I fixed the bug #36 it worked for me. But I currently dont work that much on my project, so I cant say that it is really gone.