简体   繁体   中英

how to include XNA libraries in C# project?

I am trying to make a C# game. I want to include XNA libraries there (eg 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?

First of all, check you are using the correct case, the namespace and assembly names are Xna not XNA . 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).

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.

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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