Help! Trying to load a song throws SharpDX.SharpDXException

I was following a simple tutorial online to learn the ins and outs of monogame for a Desktop application. I started learning how audio works and am now stuck because of a runtime error. I know how to load audio in with the pipeline tool and was able to successfully load in a SoundEffect object using it. However, when I try and follow the same procedure, this time using an mp3 specified to load in as a Song with the pipeline, and try to use Content.Load(“songName”), a SharpDX.SharpDXException is thrown along with these details: SharpDX.SharpDXException occurred
Message=HRESULT: [0x80070002], Module: [Unknown], ApiCode: [Unknown/Unknown], Message: The system cannot find the file specified.

at SharpDX.Result.CheckError()
at SharpDX.MediaFoundation.SourceResolver.CreateObjectFromURL(String wszURLRef, Int32 dwFlags, ComObject propsRef, ObjectType& objectTypeRef, ComObject& objectOut)
at SharpDX.MediaFoundation.SourceResolver.CreateObjectFromURL(String url, SourceResolverFlags flags, ComObject propertyStore, ObjectType& objectType)
at SharpDX.MediaFoundation.SourceResolver.CreateObjectFromURL(String url, SourceResolverFlags flags)
at Microsoft.Xna.Framework.Media.Song.PlatformInitialize(String fileName)
at Microsoft.Xna.Framework.Media.Song…ctor(String fileName)
at Microsoft.Xna.Framework.Media.Song…ctor(String fileName, Int32 durationMS)
at Microsoft.Xna.Framework.Content.SongReader.Read(ContentReader input, Song existingInstance)
at Microsoft.Xna.Framework.Content.ContentTypeReader1.Read(ContentReader input, Object existingInstance) at Microsoft.Xna.Framework.Content.ContentReader.InnerReadObject[T](T existingInstance) at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T]() at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]() at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action1 recordDisposableObject)
at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)
at _4.Audio.Game1.LoadContent() in A:\Coding Creations\C#\Graphics\4. Audio\4. Audio\Game1.cs:line 31
at Microsoft.Xna.Framework.Game.Initialize()
at _4.Audio.Game1.Initialize() in A:\Coding Creations\C#\Graphics\4. Audio\4. Audio\Game1.cs:line 24
at Microsoft.Xna.Framework.Game.DoInitialize()
at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
at Microsoft.Xna.Framework.Game.Run()
at _4.Audio.Program.Main() in A:\Coding Creations\C#\Graphics\4. Audio\4. Audio\Program.cs:line 18

I’m very stuck and don’t know what I did wrong. Is there something else I need to install to make this work? Please let me know, I appreciate any help.

Did the MP3 go through the content pipeline? It would have been converted to a different format because the content pipeline does not produce MP3 files.

Or did you copy the MP3 directly into the build output? That won’t work with Content.Load<Song>(). Use Song.FromUri() for that.

We will need some more information on how you are trying to use the MP3 in your project.

I used the pipline to convert the mp3 to the xnb and wma files in content folder. I am just looking for a way to potentially use background music in a future project, and figured a Song object would be the best way to do that. As of right now I am just trying to load it in and see if it works in an empty project, so I could go either way (Content.Load() or Song.FromUri()). I am just confused as to how to do this since going the Content route gives me the weird error, and I’m not too familiar as how to correctly use the FromUri() method.

Edit: I did some quick research to correctly set up Song.FromUri() correctly and now I am still getting the same error. I know it’s set up right since there is not file not found error. It is the same message as I was getting before with the Content.Load<>() route.

In the build output folder, does the xnb file and wma file exist? Need to make sure both files are there, copied from the content pipeline build. And just to make sure, this is a DirectX target (Windows) or DesktopGL (OpenGL) build? WMA is only used by the DirectX targets. DesktopGL targets uses Vorbis files (.ogg).

I think it should be. Unless I am looking in the wrong place. I’ll attach a screenshot where you can see what file path I’m looking in. I am using visual studio so I assume this is a DirectX target. But how could I tell if this is not the case? I really do appreciate the help and attentiveness by the way.

There’s the xnb file, and possibly the test.wma beside it (you have known file extensions hidden in Windows Explorer). Are you able to zip up the project and make it available somewhere, or email to me at That will be easier to track down the issue.

Ok I will email you. Thank you for all the help

I didn’t see how you tried to load it through the ContentManager, but I loaded it successfully by using

song = Content.Load<Song>("Sounds/test");

Did you have the correct path in the call to Load?

The FromUri() version also works successfully if you added the test.mp3 to the project and set Copy to Output Directory to Copy if newer.

Sorry for getting back to this thread late, could you possibly send the project that you changed to me? Also I do not have the options you have under ‘Advanced’. Is there something I need to install or add to make that work?

Make sure the file is included in your project. Maybe you need to right-click > Include file in project.

Even after including the file in the project, the error is still thrown. I honestly have no clue why this is happening, so if anyone could post a file that uses songs and works it would be great so I can see if it’s my computer in general or how I’m loading things in.

Ah, ok. If you want the song to be processed through the content pipeline, it does not get added to the Visual Studio project. It gets added to the content project. Double-click on the Content.mgcb file in Visual Studio. This should open the Pipeline Tool. Add the song to the content project (right-click on the root node of the project tree, Add, Existing File or Folder). Now save the content project and exit the Pipeline Tool. Remember to exclude the song from the Visual Studio project (right-click on the Sound folder, Exclude from project). When you build the Visual Studio project, it will now run the content pipeline build, processing the song and creating the XNB file as well. It will also copy the content pipeline build output to the project output folder.

After this, you should be able to use Content.Load<Song>("Sound/test") to load the song.

I did it the way you suggested, and it still doesn’t work. It throws the same error. If you could point me to a premade program that uses audio so I can see if it is my computer and not the way I am writing the code, it would make things much easier. The only things I can think of that are left is when it is building it says it skips the mp3(see screenshot). Otherwise do i have to make a x64 project and not a x86? I’m sorry I just have no idea why this doesn’t work.

I figured it out finally! I feel like such and idiot and I’m sorry for wasting all of your guys time on such a simple solution. I previously had been using the Monogame 3.6 release because I assumed it was the most up to date version. However, I found another thread that had the same problem as me and their solution was using the latest build. I looked at the downloads page and realized that there was “Development Builds”. I uninstalled 3.6 and installed the latest windows development build and it worked like a charm. Thank you all for helping me on such a dumb problem.
Link to original thread: