gamesdk-and-dispatch icon indicating copy to clipboard operation
gamesdk-and-dispatch copied to clipboard

ExecutionEngineException on Discord.RunCallbacks in C# (WPF)

Open TheBlue-1 opened this issue 4 years ago • 3 comments

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:

  1. Create a C# WPF project in VS
  2. Implement a loop calling Discord.RunCallbacks()
  3. Implement some basic lobby/activity creation
  4. Debug it and the error should appear

Expected behavior No ExecutionEngineExceptions

Implementation specifics

  • Language: C#
  • Game Engine: None (.net 5.0)

TheBlue-1 avatar May 04 '21 18:05 TheBlue-1

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.

vkuhlmann avatar May 04 '21 19:05 vkuhlmann

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

Vercidium avatar Jun 02 '21 12:06 Vercidium

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.

TheBlue-1 avatar Jun 07 '21 14:06 TheBlue-1