NAudio 演示不再工作

发布于 2024-08-31 21:01:52 字数 1217 浏览 2 评论 0原文

我刚刚尝试运行 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# 中的音频

I just tried to run the NAudio demos and I'm getting a weird error:

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].

Since the last time I used NAudio demos I have changed from 32bit Windows XP to 64bit Windows 7. Would this cause this issue? Its very annoying as I was about to try my hand at audio in C# again

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

樱娆 2024-09-07 21:01:53

我没有使用 NAudio 的经验,但您提到的异常最常发生在存在位数问题时。这意味着 NAudio 可能仅针对 32 位进行编译,而您则运行 64 位。

要尝试解决此问题,请在项目的编译属性中将输出设置为 32 位 (x86)。

I have no experience with NAudio, but the exception you mention most often occurs when there is a bitness issue. Meaning that NAudio perhaps is compiled for 32 bit only, and you run 64 bit.

To try to fix this, in compilation properties for your project, set the output to be 32 bit (x86).

小矜持 2024-09-07 21:01:53

您的程序正在尝试将 32 位 DLL 加载到 64 位进程中(反之亦然)。在Windows上,32位程序只能加载32位DLL,64位程序只能加载64位DLL。

您的程序可能以 AnyCPU 作为平台,因此编译器会发出 IL,在运行时,它会根据您的平台变成 32 位或 64 位进程。您正在使用的 DLL (NAudio) 可能仅为 x86 平台构建。

在您的项目属性中,尝试强制平台为 x86。

Your program is trying to load a 32-bit DLL into a 64-bit process (or vice versa). On Windows, a 32-bit program can only load a 32-bit DLL and a 64-bit program can only load a 64-bit DLL.

Your program is probably targeting AnyCPU as the platform, so the compiler emits IL which, at runtime, becomes either a 32- or 64-bit process based on your platform. The DLL you're using (NAudio) is probably built for the x86 platform only.

In your project properties, try forcing the platform to be x86.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文