I'm new to XNA so hopefully my question isn't too silly. I'm trying to load content data from XML.

My XML file is placed in my Content project (the new XNA 4 thing), called "Event1.xml":

<?xml version="1.0" encoding="utf-8" ?>
  <Asset Type="MyNamespace.Event">  // error on this line

My "Event" class is placed in my main project:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace MyNamespace
    public class Event
        public string name;

The XML file is being called by my main game class inside the LoadContent() method:

Event temp = Content.Load<Event>("Event1");

And this is the error I'm getting:

There was an error while deserializing intermediate XML. Cannot find type "MyNamespace.Event"

I think the problem is because at the time the XML is being evaluated, the Event class has not been established because one file is in my main project while the other is in my Content project (being a XNA 4.0 project and such).

I have also tried changing the build action of the xml file from compile to content; however the program would then not be able to find the file and would give this other warning:

Project item 'Event1.xml' was not built with the XNA Framework Content Pipeline. Set its Build Action property to Compile to build it.

Any suggestions are appreciated. Thanks.


2 Answers 2


This is a typical scenario. You must create a 3rd project and place your event class in it. Set the other 2 projects to depend on it so it builds first. Set a reference to the 3rd project in the other 2 projects.

  • \$\begingroup\$ Thanks Steve. I created a third project in the solution, added it to the references of the two existing projects and moved the Event class over to the new project - everything's working now, thanks! :) \$\endgroup\$
    – Pupper
    Commented Nov 7, 2012 at 17:46

Agree with Steve H. Just make a third project called Resources or DataTypes or something along those lines, and add the reference in your other projects to it, as Steve said. Put your Event object in that new project, and make the XML file Compile for its build action.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .