I'm currently having trouble implementing loading content with the content pipeline into my WinForm application. I'm using the "WinForms Series 1: Graphics Device" sample provided by microsoft.

By simply creating a project, copying over the classes, creating a both content projects like in the sample worked all fine. But what I really want is use my XNA Game Project and it's Content Project to be used so I can run simple simulations inside my editor with it's code and graphics.

I thought it would be really simple since it appears to be the same structure except this time the games project has some code in it. But it seems like it doesn't, if I try to load some font or a sprite it gives me the classic red cross and a console entry telling me it can't load my asset. However, it's clearly on the Content directory in the build.

• It's not enough to simply have the asset in the correct directory, you also need to add each asset to the Content project so that it can be compiled into XNA's asset file format. – John McDonald Jan 8 '12 at 22:05
• True, I added a reference to my game from my Game Editor which is a WinForm application. By doing this all my "raw assets" will also be compiled to my GameEditor's bin folder. The problem actually was that my game's asset's were compiled for the HiDef Game profile and not for the Reach profile, which the sample's classes seem to use. Since I'm a newbie on this site I can't answer my own question, so I edited the question to include my answer. – Mike Jan 8 '12 at 22:11

Open GraphicsDeviceService.cs file and edit the line below;

graphicsDevice = new Microsoft.Xna.Framework.Graphics.GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach, parameters);


as

graphicsDevice = new Microsoft.Xna.Framework.Graphics.GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, parameters);


and you'll be able to compile your assets within HiDef profile and still use in winforms-xna control.

• This is the correct answer. – Vaughan Hilts Aug 11 '13 at 23:30

The WinFormGraphicsDevice sample's classes uses the Reach profile, while my game project's sources get compiled for the HiDef profile, which are are obviously incompatible with each other.

The solution is to simply set your game's "Game profile" to "Reach" by right-clicking on the project in your VS and select Properties. Then go to the "XNA Game Studio" tab and click the "Use Reach to access a limited API set supported by Windows Phone, Xbox 360 and Windows".

Remember! as said Reach is a limited API and thus has its differences with the HiDef profile. More information about the differences can be found on Shawn Hargreaves Blog.

Edit

I see you already found your answer, and that it was related to the assets being built in a different profile than your game. I thought you were having problems setting up the build process, so I'm leaving my answer anyway for future reference because it might apply to other people arriving on this question.

I've also had problems with this before but managed to get it working. The easiest way is really to start from the Microsoft sample, rename the project and namespace, and then import your own code into that project.

In order to do it manually, first you need to make sure you have all three necessary projects. I'll call them:

1. Main - The main Windows Forms Application.
2. Content - The Empty Content Project where you'll add all your assets.
3. ContentLibrary - The empty Windows Game Library project used to build your assets.

And you need to make sure of the following:

• ContentLibrary must have a Content Reference to Content.
• Main must have a Reference to ContentLibrary. I also add a Project Dependency to it to guarantee the correct build order.

These are all done through the right-click context menu of the project tree.