SharpDX中的AssetNotFoundException

时间:2014-09-28 19:33:34

标签: sharpdx

我实际上是想让程序在Window上显示一些图片 这是代码的一部分

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,但这是谎言。我已经获得了此资产!

1 个答案:

答案 0 :(得分:1)

  
    

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

  

您很可能没有将纹理配置为构建的一部分。你需要在VS中的纹理上设置动作“ToolkitTexture”,并在没有“.jpg”的情况下读取纹理Content.Load<Texture2D>("T"),就像在SharpDX样本中一样。在您粘贴的上述代码的注释中对此进行了解释。