Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have this irritating problem in XNA that I have spent my Saturday with:

Cannot find ContentTypeReader BB.HeightMapInfoReader, BB, Version=1.0.0.0, Culture=neutral.

It throws me that when I do (within the game assembly's Renderer.cs class):

this.terrain = this.game.Content.Load<Model>("heightmap");

There is a heightmap.bmp and I don't think there's anything wrong with it, because I used it in a previous version which I switched to this new better system.

So, I have a GeneratedGeometryPipeline assembly that has these classes: HeightMapInfoContent, HeightMapInfoWriter, TerrainProcessor. The GeneratedGeometryPipeline assembly does not reference any other assemblies under the solution.

Then I have the game assembly that neither references any other solution assemblies and has these classes: HeightMapInfo, HeightMapInfoReader.

All game assembly classes are under namespace BB and the GeneratedGeometryPipeline classes are under the namespace GeneratedGeometryPipeline.

I do not understand why it does not find it. Here's some code from the GeneratedGeometryPipeline.HeightMapInfoWriter:

 /// <summary>
    /// A TypeWriter for HeightMapInfo, which tells the content pipeline how to save the
    /// data in HeightMapInfo. This class should match HeightMapInfoReader: whatever the
    /// writer writes, the reader should read.
    /// </summary>
    [ContentTypeWriter]
    public class HeightMapInfoWriter : ContentTypeWriter<HeightMapInfoContent>
    {
        protected override void Write(ContentWriter output, HeightMapInfoContent value)
        {
            output.Write(value.TerrainScale);

            output.Write(value.Height.GetLength(0));
            output.Write(value.Height.GetLength(1));
            foreach (float height in value.Height)
            {
                output.Write(height);
            }
            foreach (Vector3 normal in value.Normals)
            {
                output.Write(normal);
            }
        }

        /// <summary>
        /// Tells the content pipeline what CLR type the
        /// data will be loaded into at runtime.
        /// </summary>
        public override string GetRuntimeType(TargetPlatform targetPlatform)
        {
            return "BB.HeightMapInfo, BB, Version=1.0.0.0, Culture=neutral";
        }


        /// <summary>
        /// Tells the content pipeline what worker type
        /// will be used to load the data.
        /// </summary>
        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            return "BB.HeightMapInfoReader, BB, Version=1.0.0.0, Culture=neutral";
        }
    }

Can someone help me out?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

The problem was that the assembly name contained a space.

share|improve this answer
add comment

Another technique is to have a 'data' project which defines the reader and type which is returned by that reader, and a 'pipeline' project which defines the writer and the content version of that type.

Then you can do the following:

    public override string GetRuntimeType(TargetPlatform targetPlatform)
    {
        return typeof(HeightMapInfo).AssemblyQualifiedName;
    }

    public override string GetRuntimeReader(TargetPlatform targetPlatform)
    {
        return typeof(HeightMapInfoReader).AssemblyQualifiedName;
    }

... since the writer (defined in the pipeline assembly) can reference the data project which defines the runtime type and reader type.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.