Monogame内容加载异常

时间:2015-12-30 23:05:45

标签: c# xna monogame

用Monogame制作游戏,但是当我运行它时,我得到了大量的输出,说有一堆DLL丢失了。游戏运行正常,它不会崩溃,但当我得到其中一个错误时,我会冻结一秒钟。它通常在我加载资产时发生,但在该资产已经加载时不会再发生。

这是一次运行的输出。

'Rougelike.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Symbols loaded.

'Rougelike.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'D:\Dropbox\Projects\GurmLibX\Rougelike\bin\Windows\Release\Rougelike.exe'. Symbols loaded.

'Rougelike.exe' (CLR v4.0.30319: Rougelike.exe): Loaded 'D:\Dropbox\Projects\GurmLibX\Rougelike\bin\Windows\Release\GurmLibX.dll'. Symbols loaded.

'Rougelike.exe' (CLR v4.0.30319: Rougelike.exe): Loaded 'D:\Dropbox\Projects\GurmLibX\Rougelike\bin\Windows\Release\MonoGame.Framework.dll'. Module was built without symbols.

'Rougelike.exe' (CLR v4.0.30319: Rougelike.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Symbols loaded.

'Rougelike.exe' (CLR v4.0.30319: Rougelike.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Symbols loaded.

'Rougelike.exe' (CLR v4.0.30319: Rougelike.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Symbols loaded.

'Rougelike.exe' (CLR v4.0.30319: Rougelike.exe): Loaded 'D:\Dropbox\Projects\GurmLibX\Rougelike\bin\Windows\Release\SharpDX.RawInput.dll'. Cannot find or open the PDB file.

'Rougelike.exe' (CLR v4.0.30319: Rougelike.exe): Loaded 'D:\Dropbox\Projects\GurmLibX\Rougelike\bin\Windows\Release\SharpDX.dll'. Cannot find or open the PDB file.

'Rougelike.exe' (CLR v4.0.30319: Rougelike.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Symbols loaded.

'Rougelike.exe' (CLR v4.0.30319: Rougelike.exe): Loaded 'D:\Dropbox\Projects\GurmLibX\Rougelike\bin\Windows\Release\SharpDX.Direct3D11.dll'. Cannot find or open the PDB file.

'Rougelike.exe' (CLR v4.0.30319: Rougelike.exe): Loaded 'D:\Dropbox\Projects\GurmLibX\Rougelike\bin\Windows\Release\SharpDX.DXGI.dll'. Cannot find or open the PDB file.

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'Microsoft.Xna.Framework.Content.ContentLoadException' in MonoGame.Framework.dll

'Rougelike.exe' (CLR v4.0.30319: Rougelike.exe): Loaded 'D:\Dropbox\Projects\GurmLibX\Rougelike\bin\Windows\Release\SharpDX.Direct2D1.dll'. Cannot find or open the PDB file.

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'Microsoft.Xna.Framework.Content.ContentLoadException' in MonoGame.Framework.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'Microsoft.Xna.Framework.Content.ContentLoadException' in MonoGame.Framework.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'Microsoft.Xna.Framework.Content.ContentLoadException' in MonoGame.Framework.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'Microsoft.Xna.Framework.Content.ContentLoadException' in MonoGame.Framework.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'Microsoft.Xna.Framework.Content.ContentLoadException' in MonoGame.Framework.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'Microsoft.Xna.Framework.Content.ContentLoadException' in MonoGame.Framework.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'Microsoft.Xna.Framework.Content.ContentLoadException' in MonoGame.Framework.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'Microsoft.Xna.Framework.Content.ContentLoadException' in MonoGame.Framework.dll

'Rougelike.exe' (CLR v4.0.30319: Rougelike.exe): Loaded 'D:\Dropbox\Projects\GurmLibX\Rougelike\bin\Windows\Release\SharpDX.XInput.dll'. Cannot find or open the PDB file.

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'Microsoft.Xna.Framework.Content.ContentLoadException' in MonoGame.Framework.dll

'Rougelike.exe' (CLR v4.0.30319: Rougelike.exe): Loaded 'D:\Dropbox\Projects\GurmLibX\Rougelike\bin\Windows\Release\SharpDX.XAudio2.dll'. Cannot find or open the PDB file.

The program '[21932] Rougelike.exe: Program Trace' has exited with code 0 (0x0).
The program '[21932] Rougelike.exe' has exited with code -1 (0xffffffff).

这是我用来加载资产的代码:

GurmLibX.Framework.GameGLX.cs:游戏

Core.Content.Manager = Content;

GurmLibX.Framework.Content.cs

public static ContentManager Manager = null;

public static string RootDirectory
{
    get { return Manager.RootDirectory; }
    set { Manager.RootDirectory = value; }
}

public static T Load<T>(string assetName)
{
    return Manager.Load<T>(assetName);
}

使用方法如下:

SpriteFont font = Content.Load<SpriteFont>("fonts/someFont");

有关为何发生这种情况的任何猜测?

2 个答案:

答案 0 :(得分:0)

首先让我们来看看错误。

  

'Rougelike.exe'(CLR v4.0.30319:Rougelike.exe):已加载'D:\ Dropbox \ Projects \ GurmLibX \ Rougelike \ bin \ Windows \ Release \ SharpDX.DXGI.dll'。无法找到或打开PDB文件。

我相信这些“无法找到或打开PDB文件”的错误无需担心。在Visual Studio中进行调试时会使用PDB文件,因此您可能不会步入这些DLL中包含的代码,但不会影响您的游戏。

  

抛出异常:mscorlib.dll中的'System.IO.FileNotFoundException'

     

抛出异常:MonoGame.Framework.dll中的'Microsoft.Xna.Framework.Content.ContentLoadException'

我认为这两者密切相关。我相信第一个例外是在MonoGame的内部触发第二个例外。

基本上当Content.Load方法尝试加载内容文件时,无法找到它们。

SpriteFont font = Content.Load<SpriteFont>("fonts/someFont");

通常情况下,内容在构建时由MonoGame's Content Pipeline tool处理,内容文件将输出到可执行文件旁边的“内容”文件夹中。

文件夹的确切路径因设置而异,但在您的情况下(根据错误消息),它应该是这样的:

D:\Dropbox\Projects\GurmLibX\Rougelike\bin\Windows\Release\Content

查看该文件夹,看看是否可以找到管道生成的XNB文件。

答案 1 :(得分:0)

你在使用VS 2017吗?您可能会遇到一些问题,在我的情况下,我单独启动了MonoGame的Content Pipeline工具并构建了所有Content文件夹Add Existing Item&gt; (你的精灵)&gt;构建即可。可能不是最好的解决方案,但它可以让你工作;)