ContentLoadException, MonoGame 3.2, VS2013

Hi guys,

I’m trying to set things up using the minimal installs and running on VS2013 to produce a Windows 8 store app. I’m getting the dreaded ContentLoadException error (“Could not load xxx asset as a non-content file”). I’ve checked multiple solutions that people are proposing but none of them are the same setup as I have and none of the suggestions work. Maybe I’m trying to do something wrong in the setup? Here’s my setup:

OS: Windows 8.1 Update
MonoGame: 3.2
IDE: Visual Studio 2013 Ultimate

VS was already installed and I found an XNA release for Visual Studio here (https://msxna.codeplex.com/). It has a release for VS2012 and VS2013. I downloaded it and installed the pre-reqs (DirectX, XNA updates, etc.) then installed the vsix extension. Once I did this I was able to add a MonoGame content project to the solution.

I created a new Windows 8 MonoGame app and added the content project. Then I added a simple .PNG file to the project and rebuilt. Everything built correctly. The PNG asset was set to “Compile” and it created the .XNB file for me.

The error of course is that the project can’t find the .XNB file but I’ve tried copying it to the obvious places but nothing works.

The solution is a little weird (structurally) but is the out-of-the-box setup. The main project is Test. The Content project was added as TestContent. This created two projects, one called TestContent with a reference to the actual content project called TestContentContent (I guess MonoGame added the extra “Content” as a suffix). So the PNG (added to the root of the TestContentContent project) was compiled and produced the file Grass.xnb in the “bin\Windows8\Content” folder of the TestContentContent project.

There are a lot people that say “set as content” (instead of compile) and copy always and all that but none of these combinations work. I’ve also manually copied the content folder with the xnb file under the “bin” folder of the output of the main project (where the exe is and where the app is run from) but to no avail.

So no matter what combination of files and places to put them I can’t get this basic sample running. It’s easy to reproduce with any project (File > New, add the content project, add a file, add a few lines of code to load and display it). I think it has to do with the Windows 8 platform (as it’s has some weird stuff with the file system, for example you can’t just double click on the compiled exe). Going to try redoing this as a Windows project instead of a Windows Store app and see if it works as designed but I think something is broken here.

P.S. if it does work with Windows app then thank you for basic content support. With the XNA release for Visual Studio 2013 it means I can use current tools to build games and don’t need to install 3 IDEs.

Thanks

Update: I just built the exact same project as Windows (not Windows Store App) and it works. All I had to do was copy the Content folder (and the xnb file) to the debug folder. Works great. This is exactly what I did with the Windows 8 project but failed. Again, I suspect it’s something to do with Windows Store Apps and the file system. Next attempt is to deploy the Windows 8 app to see if a deployed version works. In any case, I think I’ll write up this as a tutorial on my blog as it’s somewhat unique (I can’t find a single tutorial that pulls the content pipeline together in VS2013 without having to install VS2010).

You have to put XNB files into your project (next to the cs files) and set it to copy to output.

Nezz,

Thanks. Finally figured it out after some playing around. You need to set the output of the content project to the same folder as the MonoGame project, then after building the xnb files you have to change the build action for each xnb file to content and have it copy to the output directory. It’s not enough just to copy it.

Thanks again. I think this is pretty streamlined as it only involves a few tools to be installed rather than the full VS2010 setup and I can get xnb files deployed with my game.