我正在写一个我想使用ContentTypeReader的游戏。在加载模型时,如下所示:
terrain = Content.Load<Model>("Text/terrain");
我得到以下错误:
Error loading "Text\terrain". Cannot find ContentTypeReader
AdventureGame.World.HeightMapInfoReader,AdventureGame,Version=1.0.0.0,Culture=neutral.
我读到这类错误可能是由程序集名称中的空格引起的,所以我已经将它们全部删除,但仍然会发生异常。
这是我的内容类:
[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";
}
}
以前有没有人遇到过这样的错误?
发布于 2012-12-24 15:58:00
我已经遇到同样的问题一周了,最终决定对整个“组装”部分进行快速检查。
我找到了一个解决方案!
实际上,当你进入AssemblyInfo.cs时,你会看到所有的属性(如标题、描述等)。
遗憾的是,这个标题是由XNA制作的,并不是您的运行时读者所指的。它实际上获取项目的初始名称,用于跟踪项目中的应用程序(exe)文件。试着从头开始重新制作你的项目,确保你的命名空间和你的项目保持一致,并且永远不要改变它,或者尝试重新命名你的exe文件,在你的项目(我相信)中的/obj文件夹中找到。希望我能帮上忙!
-Will
https://stackoverflow.com/questions/13791010
复制相似问题