问题
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:
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!
回答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
回答2:
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:
- Right-click on References folder, and select "Add Reference..."
- On the .NET tab, select the "Browse" button.
- Navigate to where you installed the SDK. (On my machine it is C:\Program Files\Microsoft DirectX 9.0 SDK)
- The files you are looking for should be in ".\Developer Runtime\x86\DirectX for Managed Code"
- Select the DLLs that you want (in this case Microsoft.DirectX.dll, Microsoft.DirectX.DirectInput.dll)
来源:https://stackoverflow.com/questions/9343905/error-message-when-referencing-dll-files