2010-05-09 58 views
4

我只是試圖運行n音訊演示和我得到一個奇怪的錯誤:n音訊演示不工作了

System.BadImageFormatException: Could not load file or a 
ssembly 'NAudio, Version=1.3.8.0, Culture=neutral, PublicKeyToken=null' or one o 
f its dependencies. An attempt was made to load a program with an incorrect form 
at. 
File name: 'NAudio, Version=1.3.8.0, Culture=neutral, PublicKeyToken=null' 
    at NAudioWpfDemo.AudioGraph..ctor() 
    at NAudioWpfDemo.ControlPanelViewModel..ctor(IWaveFormRenderer waveFormRender 
er, SpectrumAnalyser analyzer) in C:\Users\Admin\Downloads\NAudio-1.3\NAudio-1-3 
\Source Code\NAudioWpfDemo\ControlPanelViewModel.cs:line 23 
    at NAudioWpfDemo.MainWindow..ctor() in C:\Users\Admin\Downloads\NAudio-1.3\NA 
udio-1-3\Source Code\NAudioWpfDemo\MainWindow.xaml.cs:line 15 

WRN: Assembly binding logging is turned OFF. 
To enable assembly bind failure logging, set the registry value [HKLM\Software\M 
icrosoft\Fusion!EnableLog] (DWORD) to 1. 
Note: There is some performance penalty associated with assembly bind failure lo 
gging. 
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fus 
ion!EnableLog]. 

,因爲我用n音訊演示上次我從32位Windows XP更改爲64位Windows 7.這會導致這個問題嗎?它非常惱人,因爲我正要嘗試用C#語言再次嘗試我的手

回答

7

我沒有NAudio的使用經驗,但是您提到的異常經常在出現位錯問題時發生。這意味着NAudio可能只編譯爲32位,而您運行64位。

要嘗試解決此問題,請在您的項目的編譯屬性中將輸出設置爲32位(x86)。

+0

修復它謝謝:) [正確的答案滴答滴答,因爲顯然他的答案是'老'或第一:) – Kurru 2010-05-09 21:21:09

3

您的程序正試圖將32位DLL加載到64位進程中(反之亦然)。在Windows上,一個32位程序只能加載一個32位DLL,而一個64位程序只能加載一個64位DLL。

你的程序很可能是將AnyCPU作爲平臺的目標,所以編譯器會發出IL,在運行時,IL會變成基於你的平臺的32位或64位進程。您正在使用的DLL(NAudio)可能僅適用於x86平臺。

在您的項目屬性中,嘗試強制平臺爲x86。