Failure to Load Song

I am really struggling with this. I am trying to load a Song.

  1. I have a song.wma and song.xnb (built from the xnb builder tool) located in my content directory
  2. In Visual Studio I have each asset with Build Action as “Content” and Copy to Output Directory “Copy if newer”
  3. In my Debug/Content folder I have song.wma and song.xnb

With the following lines I get the following content load exceptions:

  • song = Content.Load(“song”);

HRESULT: [0x80070002], Module: [Unknown], ApiCode: [Unknown/Unknown], Message: The system cannot find the file specified.

  • song = Content.Load(“song.wma”);

Could not load song.wma asset!

  • song = Content.Load(“song.xnb”);

Could not load song.xnb asset!

All my other assets load fine (Content.Load(“art/stage.png”) for example)

Don’t put the .xnb after “song.” That should fix the problem. The game won’t use the .wma at all, from what I understand. If you still have issues, locate the song.xmb file and manually copy it over into Debug > Contents.

Song loading should look like this:

song = Content.Load < Song >(“song”); //No space between brackets, although technically it doesn’t matter

I appreciate the reply

When I use

song = Content.Load < Song >(“song”);

I get:

An unhandled exception of type ‘SharpDX.SharpDXException’ occurred in SharpDX.dll

Additional information: HRESULT: [0x80070002], Module: [Unknown], ApiCode: [Unknown/Unknown], Message: The system cannot find the file specified.

Check your Contents folder. To do this, from your project folder, go to bin > Windows (if using Windows) > Debug > Content. If it contains an xnb file named “song”, it should be working,
Also, side note, are you using a 32 - bit system? That shouldn’t matter if you already have xnb files compiled, but the content pipeline only builds xnb files on 64 - bit systems.

I am using a 64 bit system

Is the “song” file in the content folder?

In the solution, Yes

You mean in the solution explorer? Make sure to check the actual Debug/Content folder using File Explorer (i.e. outside of Visual Studio), because that’s where the build accesses files and where there’s going to be problems if the file isn’t found. If it is there, I don’t know why it wouldn’t be building right, unless there’s compatibility issues with WMA files. I only use WAV.

Yes I believe the files are in the directory

Volume in drive E is Local Disk
Volume Serial Number is 5E53-6761

Directory of E:.…\bin\Windows\Debug\Content

09/29/2015 10:29 PM .
09/29/2015 10:29 PM …
09/29/2015 10:19 PM art
09/29/2015 10:29 PM 70 out.txt
09/29/2015 10:29 PM 6,975,471 song.wma
09/29/2015 10:29 PM 122 song.xnb
3 File(s) 6,975,663 bytes
3 Dir(s) 104,127,373,312 bytes free

Huh. Weird. Well, this is what I see when I expand the Content folder in the Solution Explorer.

And I have a lot of Texture2Ds and SoundEffects I use. Maybe it doesn’t matter, but it could have something to do with the way you’re importing content files.

Have you tried using MonoGame’s content pipeline? Unless that’s what you mean by XNB builder tool. Also, sorry, I didn’t read your posts clearly enough, I was asking questions you had already answered.

So when I remove the .xnb from the solution and build my Debug/Content directory looks like this

-it has no .xnb

It looks like monogame wont build the .wma

The tool I was using was http://sourceforge.net/projects/xnbbuilder/ to make my .mp3 into a .wma and .xnb

Definitely try using Monogame’s built in content pipeline. To open the content pipeline GUI, go to [Project Name] > Content, then double click “Content”, which should have the Monogame icon next to it. Note that this Content folder is different from the one in the Debug folder; it should be found in the same directory as “bin” and “obj”.

Once you’ve opened the GUI, go to Edit > Add > Existing Folder, then find your art folder and press OK. Next, make sure the Content folder is selected on the left, not the art folder, and then go to Edit > Add > Existing Item, then find song.mp3 (not song.xnb), and press OK. Now go to Build > Build, and say yes when the prompt asks if you want to save the project.

Now when you run the project from Visual Studio, the .xnb files that were generated by Monogame’s content pipeline should automatically be added to the debug folder. If they’re not, you can copy them manually.

Oh, and if you do use the content pipeline, the places where .pngs are loaded should have the .png extension removed, since the project will be using xnb files, not .png files. I’m pretty sure that being able to directly load .png files using Content.Load is a legacy feature from back when Monogame’s content pipeline didn’t exist.

It seems to crash with the mp3 in my project

Well that’s weird. Try clicking debug the program so you can see what type of exception is thrown. Also, you shouldn’t need those “bin” and “obj” folders in there, unless they contain content you’re trying to build.

At this point, I’ve pretty much run out of ideas. Maybe someone more knowledgeable will see this and be able to help you better. Sorry about that.

@KonajuGames @Tom Any ideas why the content pipeline might be throwing that exception? I’ve never seen it before, and the MSDN documentation says its an obsolete API.

So I used the monogame content builder to build the .wma I got out of the xnb builder tool from the .mp3

The monogame content pipeline did not crash but when trying to build/debug my game I got the following error following an MGCB.exe crash

Looks like you’re getting errors from having the bin and obj folders in [Project Name] / Content. Open the pipeline GUI again, right click the bin and obj folders, and remove them. I could be wrong about that, though.

Can you click “Copy exception detail to the clipboard” and paste the details here?