0

I would like the use DirectInput in my XNA game however I'm having an issue when it comes to referencing the .dll file. I'm using Microsoft Visual Studio C# Express Edition. This is exactly what I do:

  • right click "References"
  • chose "add reference"
  • navigate to the .dll file and hit OK

I then receive the following error: enter image description here

As stated above I would like to reference the Microsoft.DirectX.DirectInput namespace but I don't know which .dll file that it's in so I just picked the "d3dref9.dll". Every .dll file under that directory doesn't work though so any one I pick gives me the same error. Now I've been able to accomplish this with other .dll files but for some reason the DirectX ones wont work. I know it's possible beacuse this guy did it just look at the second line in his code.

I have the DirectX SDK installed why can't I reference any of the .dll files and how can I make it so I can?

Thanks!

Community
  • 1
  • 1
MrSplosion
  • 183
  • 1
  • 3
  • 10
  • Those are native DLLs. You need to find the managed ones. It should be named something like "Microsoft.DirectX.DirectInput.dll" – Cameron Feb 18 '12 at 18:31

2 Answers2

1

The problem here is that you are adding a reference to a native DLL while managed projects only support managed DLLS. I believe the DLL you are looking for is Microsoft.DirectX.dll. That has the managed wrappers for DirectX

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
  • Where would the location of "Microsoft.DirectX.dll" be? I have the latest DirectX SDK release for June 2010 http://www.microsoft.com/download/en/details.aspx?id=6812 – MrSplosion Feb 18 '12 at 19:02
  • @MrSplosion I'm not exactly sure. The fastest way to find it though would be to search for `Microsoft.DirectX.dll` from the root SDK directory. If it's not there then I would try the .Net SDK folder as it may install the DLL there – JaredPar Feb 18 '12 at 19:03
  • @MrSplosion looks like from this thread http://social.msdn.microsoft.com/Forums/eu/vssetup/thread/563fcf70-ba0d-4a84-9ebb-10801075a06d they'll be in the ".\Developer Runtime\x86\DirectX for Managed Code" folder under the root SDK folder. – George Clingerman Feb 19 '12 at 03:41
0

I think you are trying to reference .dlls that are not .NET assemblies, and/or not COM libraries.

This link might help with locating the propper .dlls:

(copy/paste from linked post:)

What you need to do is add the correct DLLs as references to your project. Since they are not in the list, you'll have to add them manually. I am assuming you are using the October SDK?

What you'll need to do is:

  1. Right-click on References folder, and select "Add Reference..."
  2. On the .NET tab, select the "Browse" button.
  3. Navigate to where you installed the SDK. (On my machine it is C:\Program Files\Microsoft DirectX 9.0 SDK)
  4. The files you are looking for should be in ".\Developer Runtime\x86\DirectX for Managed Code"
  5. Select the DLLs that you want (in this case Microsoft.DirectX.dll, Microsoft.DirectX.DirectInput.dll)
CodingWithSpike
  • 42,906
  • 18
  • 101
  • 138
  • I have the June 2010 version from here: http://www.microsoft.com/download/en/details.aspx?id=6812 I think that is the most up to date one. The only October release I found was from 2008. Why would I install that when June 2010 is the most up to date? I ask because using my version the "DirectX for Managed Code" directory isn't there and I can't find it. – MrSplosion Feb 18 '12 at 18:45
  • Maybe they have changed the directory layout since then. Have you tried searching your drive for "Microsoft.DirectX.DirectInput.dll"? – CodingWithSpike Feb 18 '12 at 22:39