2012-02-18 41 views
0

我想在我的XNA遊戲中使用DirectInput,但是在涉及到.dll文件時我遇到了問題。我正在使用Microsoft Visual Studio C#Express Edition。這正是我做的:引用.dll文件時出現錯誤信息

  • 右擊「參考」
  • 選擇「添加引用」
  • 導航到.dll文件,並點擊OK

然後我收到以下錯誤: enter image description here

如上所述,我想引用Microsoft.DirectX.DirectInput命名空間,但我不知道它是哪個.dll文件,所以我只是選擇了「d3dref9.dll」。該目錄下的每個.dll文件都不起作用,儘管如此,我挑選的任何人都會給我提供相同的錯誤。現在我已經能夠用其他.dll文件完成此操作,但由於某些原因,DirectX無法正常工作。我知道這可能是因爲this這個人只是看他的代碼中的第二行。

我已經安裝了DirectX SDK爲什麼我不能引用任何.dll文件,我該如何做到這一點?

謝謝!

+0

這些是本地DLL。你需要找到託管的。它應該被命名爲「Microsoft.DirectX.DirectInput.dll」 – Cameron 2012-02-18 18:31:39

回答

0

我想你是想引用不是.NET程序集和/或不是COM庫的.dll。

This link可能與定位propper的.dll幫助:從鏈接後:)

(複製/粘貼

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)
+0

我有2010年6月版本從這裏:http://www.microsoft.com/download/en/details.aspx?id=6812我認爲這是最新的一個。我發現的唯一十月份發行版是2008年。爲什麼在2010年6月是最新的時候安裝?我問,因爲使用我的版本「DirectX for Managed Code」目錄不存在,我無法找到它。 – MrSplosion 2012-02-18 18:45:01

+0

自那以後他們可能已經改變了目錄佈局。你有沒有嘗試搜索你的驅動器「Microsoft.DirectX.DirectInput.dll」? – CodingWithSpike 2012-02-18 22:39:44

1

這裏的問題是,要添加到本地DLL的引用而託管項目僅支持受管理的DLLS。我相信你正在尋找的DLL是Microsoft.DirectX.dll。這有DirectX的託管封裝器

+0

「Microsoft.DirectX.dll」的位置在哪裏?我有2010年6月發佈的最新DirectX SDK版本http://www.microsoft.com/download/en/details.aspx?id=6812 – MrSplosion 2012-02-18 19:02:14

+0

@MrSplosion我不完全確定。找到它的最快方法是從根SDK目錄中搜索「Microsoft.DirectX.dll」。如果它不存在,那麼我會嘗試.Net SDK文件夾,因爲它可能會在那裏安裝DLL – JaredPar 2012-02-18 19:03:46

+0

@MrSplosion看起來像這個線程http://social.msdn.microsoft.com/Forums/eu/vssetup/thread/563fcf70- ba0d-4a84-9ebb-10801075a06d,它們將位於根SDK文件夾下的「。\ Developer Runtime \ x86 \ DirectX for Managed Code」文件夾中。 – 2012-02-19 03:41:09

相關問題