2010-05-09 57 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。