I've been using XNA for a while but recently I've needed to write a content extension library which I haven't done before. I need to import a TextureAtlas class from a file that is exported by a tool I wrote. The output of my editor is a serialized XML file that contains a list of all StaticImages and Animations in the TextureAtlasFile class that its serialized from. In my solution I have the TextureAtlasContentLoader project which holds all of the classes that I will need for the texture atlas both in game and for loading the actual content. The importer deserializes the xml back to a TextureAtlasFile and the processor converts it to a TextureAtlas to return after it is loaded.

The problem is that I have no idea how to share the classes between the content extension project and the game project that will be using the TextureAtlas class. I've tried referencing the content extension project in the game project and that works fine to get me pass compiling but it throws a ContentLoadException exception when I call

textures = Game1.content.Load<TextureAtlas>("MainMenu");


Error loading "MainMenu". Cannot find type Client.Render.TextureAtlas, TextureAtlasContentLoader, Version=, Culture=neutral, PublicKeyToken=null.

The only other clue to whats wrong I have is a warning while compiling that says/

Warning 2 The referenced assembly "Microsoft.Xna.Framework.Content.Pipeline, Version=, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" could not be resolved because it has a dependency on "Microsoft.Build.Framework, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project. Client

which leads me to believe I'm not supposed to reference it in the game project. So to summarize my question, how do I handle my TextureAtlas and TextureHandle class that both the content loader and the game project need without causing errors?


1 Answer 1


You could put your shared type in another project (game library) that is referenced by your content pipeline extension project and by your game project.

You might like to create TextureAtlasContent and TextureHandleContent classes, and have your content pipeline use those, with your game using your TextureAlias and TextureHandle class (that way there's no need for an extra project). It's what's done often for classes that use the graphics device in some way (Texture2D and Texture2DContent for example).

Shawn Hargreves' blog has some excelent posts on the topic of the content pipeline (as well as many other things):

Shawn Hargreaves Blog Index #Content Pipeline

There are also many good posts on the App Hub forums, there's a dedicated section for the content pipeline:

XNA Framework Content Pipeline - App Hub Forums

  • \$\begingroup\$ Thanks, really helpful information and the blog post on content pipeline assemblies addressed my exact problem. \$\endgroup\$
    – MbHimself
    Jan 10, 2012 at 18:33

You must log in to answer this question.

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