SoundEffect Causes Error on Application.Current.Exit()

Hello everyone!

I’m encountering a problem in my Windows 8.1 game, specifically with SoundEffects imported from the XNA framework. I call Game.Exit() before Application.Current.Exit() when the player chooses to quit playing the game via a menu option. After that happens, I get the following error and a VS popup asking which debugger I want to use to debug the issue:

‘MyGame.exe’ (CLR v4.0.30319: Immersive Application Domain): Loaded ‘C:\Users\me\Documents\Other Projects\Games\MyGame\MyGame\MyGame\bin\Windows8\Debug\AppX\SharpDX.XAudio2.DLL’. Cannot find or open the PDB file.
‘MyGame.exe’ (CLR v4.0.30319: Immersive Application Domain): Loaded ‘C:\Users\me\Documents\Other Projects\Games\MyGame\MyGame\MyGame\bin\Windows8\Debug\AppX\SharpDX.MediaFoundation.DLL’. Cannot find or open the PDB file.

I know that SoundEffects are causing the issue because I commented out my LoadContent method and everything worked fine. After narrowing it down further by commenting specific assets that I load in, the problem arose only when SoundEffects were loaded. I have encountered this issue previously in plain XNA, but the problem somehow disappeared after I reformatted my computer.

Any help would be greatly appreciated!

EDIT: Has anyone else encountered this problem before? I would greatly appreciate any responses.
EDIT 2: This also happens when it is built under Release.
EDIT 3: I got a new computer and tested this again. For some weird reason, whenever I clicked the “Quit” button in my game it did not happen, but the first time I selected “Quit” with the keyboard it did. Now the error shows up even if I click on “Quit.” This is very strange…

Do you have latest sharpdx/monogame nuget ? Or can you provide basic project to test it ? If you do, I can try to run it.

Thank you for replying. I downloaded MonoGame 3.2 from the official site, so I’d hope that it has the latest libraries.

Simply create a blank Windows 8 XAML project, and convert a .wav file into an xnb using this content compiler (https://xnacontentcompiler.codeplex.com/). Afterwards, add the xnb to your project and load it as a SoundEffect in LoadContent. Add some way of calling Application.Current.Exit() while the game is running (Ex. press Space Bar) and the problem should occur.

Try to get libraries as nugets, my experince is they are often more fresh than official install and also try sharpdx nuget.
In your first post you told that you have wp8.1 project, now you suggest me to create w8 only, it’s mistake or you are dealing with non phone project ? Because I have experince only with wp8 project. So create that project with wave and exit code and share it :).

Sorry for the misunderstanding. I did not mention Windows Phone but rather Windows 8.1. My next reference to the development platform is Windows 8, which you can easily convert to 8.1 in Visual Studio by right-clicking the solution and clicking Retarget.

I have uploaded the sample project here: http://www.mediafire.com/download/3eqzathty9l4z31/SampleProject.zip

Simply run the program and click Quit Game. The error should occur, but if it doesn’t try a few times. After it errors, comment out loading the SoundEffect via the ContentManager and it should no longer error up.

Please let me know your results! Thanks again; I really appreciate it!

Hello, just tried your project (converted to 8.1) and you are right - this way with sfx loading, app exit often took long time and with non zero result code like -1073610751 or 255, without sfx loading it worked ok, exits instantly a always with zero code. I tried to update mono/sharpdx, played with releasing game/releasing resources, tried different targets/release but still same issue, sorry I did not help you.

Thanks; you actually helped a lot! Now I’m sure that this issue doesn’t happen only on my machine and is a bug that needs fixing.

I reported this issue on MonoGame’s GitHub repository so hopefully it’ll get fixed soon.

Ah, maybe I should report my SoundEffect memory leak bug also somewhere there (not sure how, maybe you can help me), because it is also 100% bug very that can be very easily reproduced and here no response for weeks :).