【问题标题】:AssetNotFoundException in SharpDXSharpDX 中的 AssetNotFoundException
【发布时间】:2014-09-29 07:40:50
【问题描述】:

我实际上是在尝试制作在窗口上显示一些图片的程序 这是部分代码

public Texture2D tulTexture;
//...
protected override void LoadContent()
{
    // Instantiate a SpriteBatch
    spriteBatch = ToDisposeContent(new SpriteBatch(GraphicsDevice));

    // Loads the balls texture (32 textures (32x32) stored vertically => 32 x 1024 ).
    // The [Balls.dds] file is defined with the build action [ToolkitTexture] in the project
    tulTexture = this.Content.Load<Texture2D>("T.jpg");

    // Loads a sprite font
    // The [Arial16.xml] file is defined with the build action [ToolkitFont] in the project


    base.LoadContent();
}

当我运行程序时,我得到了 AssetNotFoundException 但这是谎言。我有这个资产!

【问题讨论】:

  • 请发布完整的 StackTrace。
  • 不久前我遇到了同样的问题。进入 SharpDX 代码并观察它构建它试图打开的文件的路径是很有帮助的。我也从没有为图像文件设置正确的构建操作中看到这一点 - 它需要是 ToolkitTexture。

标签: sharpdx


【解决方案1】:

AssetNotFoundException 但这是谎言。我有这个资产!

很可能您没有将纹理配置为构建的一部分。您需要在 VS 中对纹理设置动作“ToolkitTexture”,并在没有“.jpg”的情况下读取纹理Content.Load&lt;Texture2D&gt;("T"),就像在 SharpDX 示例中所做的那样。这在您粘贴的上面代码的注释中进行了解释。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多