Using XNA Content Pipeline in a C# Form

1.3k Views Asked by At

I'm trying to create a game editor using a C# form, and I've run into a problem when it comes to deserializing; I can't use the content pipeline in a forms application as I don't even have the option to add any content reference to the project. How can I use the content pipeline with my form app? Is there another way to load and deserialize my XML content?

2

There are 2 best solutions below

1
On BEST ANSWER

Manually edit the .csproj file and add the following in the first PropertyGroup section which contains the assembly name, project guid etc.

<ProjectTypeGuids>{6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

You'll probably need to also add

<XnaFrameworkVersion>v4.0</XnaFrameworkVersion>
<XnaPlatform>Windows</XnaPlatform>

Reload the project in VS, and you should be able to add content references to it.

The two GUIDs specified there are for Windows and XNA (Windows). Here is a list of some common project type guids (although slightly dated) if you need to retarget the project at all.

2
On

Take a look at the Winforms Series 2: Content Loading AppHub sample.

Basically you load and call appropriate microsoft.xna.framework.content classes to read your compiled xnb files.

You'd use classes in the namespaces within microsoft.xna.framework.content.pipeline to create the xnb files (which is what the content project would do for you).

See here for an overview of the content pipeline: What is the Content Pipeline?


Is there another way to load and deserialize my XML content?

Yes, use any .net method of serialising you want, maybe XDocument.