XNA ContentLoadException
本文关键字:ContentLoadException XNA | 更新日期: 2023-09-27 17:52:37
我开始学习"一些" XNA,正如我所料,我很早就遇到了障碍。
- 我已经创建了一个WP7 XNA游戏解决方案我已经删除了默认的内容项目
- 我已经添加了自己的内容项目"Sprites" 我已经添加了3x *.png文件到"Sprites"项目(MyImage1.png, MyImage2.png, MyImage3.png)
- 我添加了一个内容引用,将"精灵"引用到主游戏项目
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
logoTexture = Content.Load<Texture2D>("Sprites/MyImage1");
// TODO: use this.Content to load your game content here
}
我得到一个contentloadeexception说"not found"当试图加载一个我的*.png的
- 我检查了输出目录,一个包含*的"Sprites"子文件夹。xnb文件存在
- 我确实检查了图像的属性,所有图像都标记为texture2d,并将内容导入器和处理器设置为默认的XNA值
我很确定我犯了一个常见的愚蠢的错误,但是我没有看到它,所以我希望你能给我一些指导。
问题固定
Content.RootDirectory = "Content"; // The cause of the problem
对
为什么要删除内容项目?
我猜你需要设置RootDirectory
Content.RootDirectory = "Content";
您应该尝试以下路径格式:
".''Sprites''MyImage1"
根据MSDN,路径必须是相对于当前目录的。目录分隔符是'''