Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6188025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:09:32+00:00 2026-05-24T02:09:32+00:00

I am trying to get a content type reader for my class working, but

  • 0

I am trying to get a content type reader for my class working, but it doesn’t seem to be doing anything. Is there anything I need to do to get this to work?

public class Map
{

    ...

    /// <summary>
    /// Read a Map object from the content pipeline.
    /// </summary>
    public class MapReader : ContentTypeReader<Map>
    {
        protected override Map Read(ContentReader input, Map existingInstance)
        {
            Map map = existingInstance;
            if (map == null)
            {
                map = new Map();
            }

            map.TileSetFile = input.ReadString();
            map.Dimensions = input.ReadObject<Point>();
            map.Tiles = input.ReadObject<int[]>();

            map.Load(input.ContentManager);

            return map;
        }
    }
}

The xml is read in properly, but the Read function seems to not be called. Any ideas?

Do I need more than just what I have here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:09:33+00:00Added an answer on May 24, 2026 at 2:09 am

    Disclaimer: I am by no means an expert on the XNA Content Pipeline

    Before giving a short summary on the content pipeline and how to extend it, i’d like to mention that since XNA 3.1, implementing a ContentTypeReader and ContentTypeWriter is no longer necessary.

    In XNA 3.1, Automatic XNB serialization was introduced (by using Reflection), and so if you do not include any writer and reader, XNA will take care of that for you (i believe excluding some cases).

    Read more here: Automatic XNB Serialization

    The XNA Content Pipeline is a process that is made of the following steps:

    enter image description here

    Most of these occur at design time (when you are using Visual Studio to add art assets to your game and when you’re building your game). The last part is executed at runtime, when you run your game and call Content.Load to load your assets.

    The XNA Content Pipeline, being open for extension, allows you to support more than the built in content types that are shipped with the XNA Framework, and so allows you to introduce new content types and new file formats to be processed as input for your game.

    In the following diagram, you can see the chain of events that are executing when extending the content pipeline:

    enter image description here

    In order to create an extension to support a new type (Map in your example), you must do the following (some of which i suppose you already did):

    1. Create a new Content Pipeline extension library project in VS.
    2. Add this project as a reference to your game’s content project.
    3. Add a new ContentImporter, ContentProcessor [optional] ContentTypeWriter and ContentTypeReader
    4. Your ContentTypeWriter class should implement this method:

      public override string GetRuntimeReader(TargetPlatform targetPlatform)
          {
              // TODO: change this to the name of your ContentTypeReader
              // class which will be used to load this data.
              return "ContentPipelineExtension.CharacterReader, ContentPipelineExtension, Version=1.0.0.0, Culture=neutral";
          }
      

    Note that in this example, i’ve used some other CharacterReader class, you will have to register your reader type with it’s full name and containing assembly.

    Read about the GetRuntimeReader method here: ContentTypeWriter.GetRuntimeReader

    I havev created a demo project with a new type called Character, an importer, processor and reader/writer for it.

    You can get it here: Sample project

    *note that you can put this line in your processor/importer in order to debug and see that visual studio is actually triggering the code for your Content Pipeline extension library.

    System.Diagnostics.Debugger.Launch();
    

    *Another thing to note is that your new type (Map, Character, whatever) should be defined in its own shared assembly and planned correctly, since this type should be used both in your actual Game and in your Content Pipeline extension library.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get the height of a html window's content. This is the
I'm trying to get content from an RSS2 feed from one of my sites
I am trying to get some content in html documents. Some of the documents
I am trying to get simple jQuery to execute on my Content page with
I'm trying to get the contents of a XML document element, but the element
I'm trying to get the contents of a HttpServletRequest. Here is how I'm doing
Using the API, trying to get items in a specific feed returns this: {direction:ltr,id:feed/
I am trying to get a Date type field from the entity and I
I'm trying to interface with the Google Reader (undocumented/unofficial) API using information from this
Hey, Im trying to get the signal pre_save to work on my model but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.