2
\$\begingroup\$

I'm writing a game where I want to use ContentTypeReader. While loading my model like this:

terrain = Content.Load<Model>("Text/terrain");

I get following error:

Error loading "Text\terrain". Cannot find ContentTypeReader
AdventureGame.World.HeightMapInfoReader,AdventureGame,Version=1.0.0.0,Culture=neutral.

I've read that this kind of error can be caused by space's in assembly name so i've already removed them all but exception still occurs.

This is my content class:

[ContentTypeWriter]
public class HeightMapInfoWriter : ContentTypeWriter<HeightmapInfo>
{
    protected override void Write(ContentWriter output, HeightmapInfo value)
    {
        output.Write(value.getTerrainScale);
        output.Write(value.getHeight.GetLength(0));
        output.Write(value.getHeight.GetLength(1));

        foreach (float height in value.getHeight)
        {
            output.Write(height);
        }       
    }

    public override string GetRuntimeType(TargetPlatform targetPlatform)
    {
        return
            "AdventureGame.World.Heightmap,AdventureGame,Version=1.0.0.0,Culture=neutral";
    }

    public override string GetRuntimeReader(TargetPlatform targetPlatform)
    {
        return
        "AdventureGame.World.HeightMapInfoReader,AdventureGame,Version=1.0.0.0,Culture=neutral";        
    }
}

Does anyone meed that kind of error before?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

I can't be sure from the description but is your content-type-reader class in your content-pipline-extensions project? If so than that is probably the reason why it can't find it. The content-type-reader has to be available at runtime and thus has to be part of the game project or of one of the linked game library projects. Be sure to update your assembly name when you move your class and also, just to be sure, add spaces after the commas in the string that desribes where the class should be.

Edit: to be sure you have to exact QualifiedAssemblyName of a class write this piece of code:

string info = typeof(HeightMapInfoReader).AssemblyQualifiedName;

Of course this only works for a class in the same, or a referenced, assembly so you still have to copy the string in info and put it in the ContentTypeWriter's GetRunTimeReader method harcoded but it makes sure you don't have typo's.

\$\endgroup\$
3
  • \$\begingroup\$ Yes it is in my ContentPipelineExtensionLibrary. Reference is added and so do spaces to string's but still doesn't work. Any other ideas? \$\endgroup\$ Dec 9, 2012 at 22:15
  • \$\begingroup\$ Please read my answer again. The problem is that it is in the ContentPipelineExtensionsLibrary and that it should be in your Game project or a Game Library project :) \$\endgroup\$
    – Roy T.
    Dec 10, 2012 at 7:14
  • \$\begingroup\$ I'm writing this project with my friend and it worked for him. For some reason my project even with those changes can't be run but I assume that its not connected with this issue :) Thank you for your reply. Problem solved! \$\endgroup\$ Dec 11, 2012 at 9:25

You must log in to answer this question.

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