简体   繁体   English

Monogame内容加载异常

[英]Monogame Content Load Exception

Made a game in Monogame, but when I run it I get a ton of output saying there are a bunch of DLLs missing. 在Monogame中制作了一个游戏,但是当我运行它时,我得到了大量的输出,说缺少一堆DLL。 The game runs fine in the sense that it doesn't crash, but I'll freeze for a second when I get one of these errors. 从某种意义上说,它不会崩溃,但游戏运行正常,但是当我遇到这些错误之一时,我会冻结一秒钟。 It usually happens when I load an asset, but won't happen again when that asset is already loaded. 通常在我加载资产时会发生,但在该资产已加载后不会再发生。

Here's the output from a single run. 这是一次运行的输出。

'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).

This is the code I use to load assets: 这是我用来加载资产的代码:

GurmLibX.Framework.GameGLX.cs : Game GurmLibX.Framework.GameGLX.cs:游戏

Core.Content.Manager = Content;

GurmLibX.Framework.Content.cs 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);
}

Which is used like: 用法如下:

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

Any guesses as to why this is happening? 为什么会这样呢?

First let's take a look at the errors. 首先,让我们看一下错误。

'Rougelike.exe' (CLR v4.0.30319: Rougelike.exe): Loaded 'D:\\Dropbox\\Projects\\GurmLibX\\Rougelike\\bin\\Windows\\Release\\SharpDX.DXGI.dll'. 'Rougelike.exe'(CLR v4.0.30319:Rougelike.exe):已加载'D:\\ Dropbox \\ Projects \\ GurmLibX \\ Rougelike \\ bin \\ Windows \\ Release \\ SharpDX.DXGI.dll'。 Cannot find or open the PDB file. 找不到或打开PDB文件。

I believe these "Cannot find or open the PDB file" errors are nothing to worry about. 我相信这些“无法找到或打开PDB文件”错误无需担心。 PDB files are used when debugging in Visual Studio so it could be slightly annoying that you can't step into code contained within these DLLs but other than that it shouldn't affect your game. 在Visual Studio中进行调试时会使用PDB文件,因此您可能无法进入这些DLL中包含的代码可能会有些烦恼,但它不会影响您的游戏。

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll 引发异常:mscorlib.dll中的“ System.IO.FileNotFoundException”

Exception thrown: 'Microsoft.Xna.Framework.Content.ContentLoadException' in MonoGame.Framework.dll 引发异常:MonoGame.Framework.dll中的'Microsoft.Xna.Framework.Content.ContentLoadException'

I think these two are closely related. 我认为这两个是密切相关的。 I believe the first exception is triggering the second exception deep within the bowels of MonoGame. 我相信第一个例外会触发MonoGame内部深处的第二个例外。

Essentially when the Content.Load method is trying to load your content files they can't be found. 本质上,当Content.Load方法尝试加载您的内容文件时,找不到它们。

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

What usually happens is that the content is processed by MonoGame's Content Pipeline tool at build time and the content files are output to a Content folder next to your executable. 通常发生的情况是,内容在构建时由MonoGame的内容管道工具处理,并且内容文件输出到可执行文件旁边的内容文件夹。

The exact path to your folder varies depending on the setup but in your case (based on the error messages) it should be something like: 文件夹的确切路径取决于设置,但是在您的情况下(基于错误消息),它应该类似于:

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

Have a look in that folder and see if you can find the XNB files generated by the Pipeline. 查看该文件夹,看看是否可以找到管道生成的XNB文件。

Are you using VS 2017? 您正在使用VS 2017吗? You may experience some issues, in my case, I launched the MonoGame's Content Pipeline tool stand alone and built all the Content folder Add Existing Item > (Your Sprite) > Build . 您可能会遇到一些问题,就我而言,我独立启动了MonoGame的内容管道工具,并构建了所有内容文件夹添加现有项>(您的Sprite)>构建 May not be the best solution but it can let you work ;) 可能不是最好的解决方案,但是它可以让您工作;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM