【问题标题】:Error occurs on Debug, but not on Start New Instance, and only with a Content Reference in another project错误发生在 Debug 上,但不是在 Start New Instance 上,并且仅在另一个项目中出现 Content Reference
【发布时间】:2012-04-19 03:51:34
【问题描述】:

我有一个 Visual Studio 2010,XNA 4.0 游戏解决方案。称之为“游戏”。它有一个名为“Game”的项目和一个名为“GameContent”的关联内容项目。我还在名为“LevelEditor”的解决方案中创建了第二个项目,其中包含一个名为“LevelEditorContent”的关联内容项目。

Game 和 LevelEditor 都可以从自己的内容项目中加载内容,没问题。不过,我决定看看是否可以让 LevelEditor 从 GameContent 加载内容,因此我在 LevelEditor 中添加了对 GameContent 的内容引用。

现在,当我单击“调试”或按 F5 时,游戏崩溃,其中一个内容出现 FileNotFound 错误。如果我从 LevelEditor 中删除内容引用,游戏将再次运行。我不知道为什么。游戏是唯一的启动项目。

更奇怪的是,如果我在解决方案资源管理器中右键单击游戏项目,选择调试,然后选择“启动新实例”,游戏运行正常 - 根本没有 FileNotFound 错误 - 无论 LevelEditor 是否具有该内容引用与否。

为什么不同项目中的内容引用会破坏游戏加载其内容的能力? F5/Debug 和 Start New Instance 有什么不同会导致使用前者而不是后者发生错误?

【问题讨论】:

  • 你有没有检查GameContent项目的DLL位于LevelEditor项目的debug文件夹中?
  • Guillaume - 我刚刚检查过 - LevelEditor 和 Game 在他们的 bin\x86\debug 文件夹中都没有用于 GameContent 的 DLL。 GameContent 不包含任何代码,仅包含图像和 xml 文件。

标签: c# visual-studio-2010 xna project-reference


【解决方案1】:

我无法重现您的问题。尝试阅读该异常的所有详细信息,并查看它试图在哪里找到该文件以及为什么找不到它。检查 ContentManager.RootDirectory 和 Environment.CurrentDirectory 是否正确,以及所有内容是否正确构建。如果您进行重建,会有什么变化吗?

【讨论】:

  • ContentManager.RootDirectory 和 Environment.CurrentDirectory 绝对正确。
  • 但是,我发现当 LevelEditor 引用 GameContent 时,重建会将 GameContent 的输出放在 LevelEditor 的 bin\x86\debug 文件夹中,并将其从 Game 的 bin\x86\debug 文件夹中删除。我不明白为什么内容会根据内容参考是否到位而构建到不同的位置。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-11
  • 1970-01-01
  • 2021-07-05
  • 2021-04-13
  • 2012-09-17
  • 2020-11-10
相关资源
最近更新 更多