I am working through the book XNA 4.0 Game Development by Example. As XNA is not longer supported I am working through the examples using MonoGame under VS 2013. So far everything has been working fine. In my current project I am adding sound effects using the SoundEffects class. I created the files per the information in the book and received no compile errors. However when I run the build (F5) I get no sounds.
I have VS 2010 installed with XNA and ran the tutorial project under it. The sounds worked fine. I compared my code to the authors’ and could not find any discrepancies.
Below is the code for the SoundManager class I created to handle the sound effects.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
namespace Asteroid_Belt
{
public static class SoundManager
{
private static List explosions = new
List();
private static int explosionCount = 4;
daveleaver,
Thanks for the feedback. I did insert a breakpoint for when I press the spacebar activating the shot. I am a newbie to this but if I read the Call Stack correctly there is a call to the .Play(). If I’m not understanding things correctly let me know.
This is the first line in the Call Stack:
Asteroid Belt.exe!Asteroid_Belt.SoundManager.PlayPlayerShot() Line 60 C#
Below is the text from the debug output. Is this what you are referring to? As I said I am a newbie at some of this so I am learning as I am going. If I read the output text correctly, there seems to be a problem with the ?SharpDX dll and finding the PDB files. As background, I installed MonoGame following the documentation and using all the default settings. Do I need to re-install MonoGame or use NuGet to update SharpDX (which I have learned is a component library of MonoGame. Thanks again for helping this newbie out.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘E:\Projects\Games In Progress\Asteroid Belt\Asteroid Belt\Asteroid Belt\bin\Windows\Debug\Asteroid Belt.vshost.exe’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
The thread 0x16f4 has exited with code 259 (0x103).
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘E:\Projects\Games In Progress\Asteroid Belt\Asteroid Belt\Asteroid Belt\bin\Windows\Debug\Asteroid Belt.exe’. Symbols loaded.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Accessibility\v4.0_4.0.0.0__b03f5f7f11d50a3a\Accessibility.dll’. Cannot find or open the PDB file.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘E:\Projects\Games In Progress\Asteroid Belt\Asteroid Belt\Asteroid Belt\bin\Windows\Debug\MonoGame.Framework.dll’. Cannot find or open the PDB file.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘E:\Projects\Games In Progress\Asteroid Belt\Asteroid Belt\Asteroid Belt\bin\Windows\Debug\SharpDX.RawInput.dll’. Cannot find or open the PDB file.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘E:\Projects\Games In Progress\Asteroid Belt\Asteroid Belt\Asteroid Belt\bin\Windows\Debug\SharpDX.dll’. Cannot find or open the PDB file.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘E:\Projects\Games In Progress\Asteroid Belt\Asteroid Belt\Asteroid Belt\bin\Windows\Debug\SharpDX.Direct3D11.dll’. Cannot find or open the PDB file.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘E:\Projects\Games In Progress\Asteroid Belt\Asteroid Belt\Asteroid Belt\bin\Windows\Debug\SharpDX.DXGI.dll’. Cannot find or open the PDB file.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘E:\Projects\Games In Progress\Asteroid Belt\Asteroid Belt\Asteroid Belt\bin\Windows\Debug\SharpDX.Direct2D1.dll’. Cannot find or open the PDB file.
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
A first chance exception of type ‘Microsoft.Xna.Framework.Content.ContentLoadException’ occurred in MonoGame.Framework.dll
‘Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
SoundManager Initialization Failed’Asteroid Belt.vshost.exe’ (CLR v4.0.30319: Asteroid Belt.vshost.exe): Loaded ‘E:\Projects\Games In Progress\Asteroid Belt\Asteroid Belt\Asteroid Belt\bin\Windows\Debug\SharpDX.XInput.dll’. Cannot find or open the PDB file.
I removed the try/catch as suggested with the same results. I opened the solution provided by the book authors and it works fine though I get a warning about a mismatch in my hardware configuration. So that seems to suggest to me that the problem is with MonoGame. I uninstalled it and re-installed with no changes. I really appreciate your help as it is helping me learn about developing. But I am at a loss on why my project isn’t running under MonoGame but it will under XNA. I’m running MonoGame 3.2 with XNA 4.0 Refresh installed and using VS 2013 Pro.
daveleaver has been very helpful and hope maybe someone else has experienced a similar problem. I put my try/catch statements back in and ran the solution. I noticed in the debug output that my SoundManager wasn’t being initialized. The code is at the top of the thread. When I run the same solution using the code from the book source files, it works fine. I’ve compared the code and can’t see where mine is any different. The only difference between them is that I wrote mine using MonoGame versus XNA as the framework. The sprites/graphics work fine, it is just the sound effects I want to use that aren’t working. I’m a newbie to using MonoGame/XNA for game development so please understand I don’t have a strong programming background yet (but I’m learning). Thank you in advance.
The code for my SoundManager class is listed under my first posting. What other files do you need to see? As I mentioned, I did run the source solution from the book’s source files (written using XNA 4.0 framework) under VS 2013 and it worked fine. So that is why I am wondering why it isn’t working when I wrote the same code under the MonoGame 3.2 framework I installed. Up until I wrote the SoundManager class, all the code works fine. Thanks for the response.
Man, compresses the entire XNA 4 project (.zip/.rar). Send me the file and I will open it (with VS-2013), then I’ll create a new project in monogame to find the error…