我刚试着运行NAudio演示,但得到了一个奇怪的错误:
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].自从我上次使用NAudio演示后,我已经从32位Windows XP更改为64位Windows 7。这会导致这个问题吗?这非常烦人,因为我正要再次尝试在C#中尝试音频
发布于 2010-05-10 04:36:37
我没有使用NAudio的经验,但您提到的最常见的异常发生在存在位问题时。这意味着NAudio可能只为32位编译,而您运行的是64位。
要尝试修复此问题,请在项目的编译属性中,将输出设置为32位(x86)。
发布于 2010-05-10 04:37:30
您的程序正在尝试将32位DLL加载到64位进程中(反之亦然)。在Windows上,32位程序只能加载32位DLL,而64位程序只能加载64位DLL。
您的程序可能将AnyCPU作为平台,因此编译器会发出IL,它在运行时会根据您的平台成为32位或64位进程。您正在使用的DLL (NAudio)可能仅为x86平台构建。
在您的项目属性中,尝试强制平台为x86。
https://stackoverflow.com/questions/2799071
复制相似问题