Error Message when Referencing .dll Files

試著忘記壹切 提交于 2019-12-11 18:56:54

问题


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:

  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)


来源:https://stackoverflow.com/questions/9343905/error-message-when-referencing-dll-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!