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 Answers
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.

- 13,797
- 4
- 31
- 45
-
Thank-you very much, this seems to have worked; however, when deserializing I get the following error: "Cannot find ContentTypeReader for System.Int32[]." I assume I've missed a reference or a namespace include somewhere, but I don't know what. Any ideas? – Jamie Dec 21 '11 at 21:21
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
.

- 31,770
- 9
- 95
- 162
-
1If all content is to be processed at build time, the winforms1 sample is probably the better choice. If any content needs to be processed during run time, then the winforms2 sample is the way to go. – Steve H Dec 21 '11 at 13:39
-
Since the OP was asking about adding a content project to his winforms one (which would build the assets) i went for the 2nd sample. – George Duckett Dec 21 '11 at 14:35