问题
I have been trying to include DirectX in C sharp project (Visual Studio 2010). I installed DirectX SDK and included the components as:
using Microsoft.DirectX;
using Microsoft.DirextX.Direct3D;
When I try to compile, I get the error: the type or namespace name 'directx' does not exist in the namespace 'microsoft'
Some blogs mentioned that I need to add 'reference' - Microsoft.DirectX under '.NET' tab. But I couldn't find it over there. Neither was any facility to add it to the tab.
Any suggestion will be highly appreciated.
回答1:
This was deprecated a long time ago. The last Direct SDK that still has the managed wrappers is February 2010. The download is available here. You'll get to pick the references you are looking for after you install that one.
Better not to use it, no future, look at something like the open source SlimDX or SharpDX projects.
回答2:
There are various reasons why a dll would not appear on the .Net tab.There is specific registry configuration that makes certain dlls to appear on the .Net tab.
Alternatively use the browse option to add the dll reference manually to your project.
Project >> Add Reference
回答3:
Here is one way i have find. First you need to install DXSDK (i have June2010 and SDK for Windows 7). Go to "Add refference" dialog press "Browse" , go to something like this "C:\Windows\Microsoft.NET\DirectX for Managed Code\1.0.2902.0" or "C:\Windows\Microsoft.NET\Managed DirectX\v9.02.2904" then choose proper dll for example - Microsoft.DirectX.dll. So you can add "using Microsoft.DirectX" directive to your project.
回答4:
This is the way to add reference for Directx
in C#
Program :
- Go to the solution explorer
- Click references
- Click add reference
- Click Browse
Go to : "
C:\WINDOWS\Microsoft.NET\DirectX for Managed Code\1.0.2902.0\
" *usually this is the place ofDirectx
Files located. This can be change with the installation of.net
. - Select your
DirectX
package.
example :
(C:\Windows\Microsoft.NET\DirectX for Managed Code\1.0.2902.0\Microsoft.DirectX.dll)
来源:https://stackoverflow.com/questions/13157290/the-type-or-namespace-name-directx-does-not-exist-in-the-namespace-microsoft