如何在 C# 项目中包含 XNA 库?
我正在尝试制作一个 C# 游戏。我想在其中包含 XNA 库(例如 Microsoft.XNA.Framework.Graphics)。但是,如果我这样做,则会收到错误:
命名空间 Microsoft.XNA 中不存在类型或命名空间 XNA。
有人可以帮忙吗?
I am trying to make a C# game. I want to include XNA libraries there (e.g. Microsoft.XNA.Framework.Graphics). But, if I do so, I get an error :
The type or namespace XNA doesnot exist in the namespace Microsoft.
Can anyone please help ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
首先,检查您使用的大小写是否正确,命名空间和程序集名称是
Xna
而不是XNA
。如果这不起作用:您应该按照此处的说明进行操作 。这些描述了如何安装(以及 Visual Studio 2010 的某些风格)XNA Game Studio 并使用模板创建项目。使用模板项目比手动添加引用要容易得多。
要添加对 XNA 程序集的引用,您需要在 Visual Studio 的解决方案资源管理器中右键单击您的项目,然后选择“添加引用”。
如果您没有看到要查找的 DLL,则可能需要右键单击您的项目,选择属性,然后确保目标框架是 .NET 4.0 框架的风格之一(对于 XNA 4.0)。
First of all, check you are using the correct case, the namespace and assembly names are
Xna
notXNA
. If that doesn't work:You should follow the instructions here. These describe how to install (as well as some flavour of Visual Studio 2010) XNA Game Studio and to create a project using the template. Using the template project is much easier than adding the references manually.
To add a reference to the XNA assemblies, you need to right click your project in Solution Explorer in Visual Studio and select "Add Reference".
If you do not see the DLLs you are looking for, you may need to right click your project, select properties, and then ensure that the target framework is one of the flavours of the .NET 4.0 framework (for XNA 4.0).
首先,您应该右键单击(通常)显示在您正在处理的项目顶部的“References”文件夹。从这里您可以选择添加引用并手动浏览到 XNA .DLL 的位置。
First you should right click on the "References" folder shown (usually) at the top of the project you are working in. From here you can select add references and manually browse to the location of the XNA .DLLs.
首先,您需要添加对 XNA 二进制文件的引用。其次,我建议您从内置 Visual Studio XNA 游戏模板开始,然后从那里开始工作。
要手动添加引用,您可能需要 XNA Game Studio 安装),然后添加对
Microsoft.Xna.Framework.dll
的引用以及您需要的任何其他内容。就我个人而言,我仍然认为您应该从游戏的内置视觉工作室模板开始。一旦您感受到了它,就可以继续学习高级概念,例如将您的游戏嵌入到标准 WinForm 应用程序或其他应用程序中。
First, you need to add a reference to the XNA binary files. Second, I recommend you start off with the Built-In Visual Studio XNA Game Template, and work from there.
To add the references manually, you'll (probably need XNA Game Studio installed) and then add references to
Microsoft.Xna.Framework.dll
and whatever else you need.Personally, I still think you should start with the built-in visual studio template for a Game. Once you get a feel for it, move on to advanced concepts like embeding your game into a standard WinForm app or whatever.
在解决方案资源管理器中。转到引用,添加引用,然后添加 Microsoft.Xna.Framework.Xact 引用 4.0 如果您不对其进行排序,它位于底部附近的某个位置。然后您可以访问音频引擎类。
我遇到了同样的问题,然后在第三次尝试时发现了它。对我来说效果很好。希望这有帮助。
In the solution explorer. Go to reference, add reference and then add th Microsoft.Xna.Framework.Xact reference 4.0 It is somewhere near the bottom if you leave it unsorted. Then you can access the Audio Engine class.
I had the same problem and then found it at the 3rd time of trying. Worked fine for me. Hope this helps.
无需在 Visual Studio 中的引用列表中苦苦寻找,只需从 此处,或直接链接:
https://www.dllme.com/dll/files/microsoft_xna_framework_dll.html
Instead of hassling around in the references list in Visual Studio, just download the DLL from HERE, or the direct link:
https://www.dllme.com/dll/files/microsoft_xna_framework_dll.html