我正在开发一个项目,它使用naudio和naudio.lame捕获扬声器音频并将其写入MP3文件。我从nugget enter link description here向我的项目添加了两个DLL并且它工作正常,但问题是当我转到bin>发布或调试文件夹然后单击exe然后它显示错误。我将所有DLL复制到该文件夹,并尝试创建新项目,然后添加引用,但没有任何工作仍然显示单击exe时相同的错误。 任何帮助 感谢
这是错误信息: -
ee the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.IO.FileNotFoundException: Could not load file or assembly 'LameDLLWrap, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'LameDLLWrap, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at NAudio.Lame.LameMP3FileWriter..ctor(Stream outStream, WaveFormat format, Int32 bitRate)
at NAudio.Lame.LameMP3FileWriter..ctor(String outFileName, WaveFormat format, Int32 bitRate)
at WindowsFormsApplication1.Form1.wavtomp3() in c:\Users\aman\Documents\Visual Studio 2010\Projects\WindowsFormsApplication4\WindowsFormsApplication4\Form1.cs:line 37
at WindowsFormsApplication1.Form1.button1_Click(Object sender, EventArgs e) in c:\Users\aman\Documents\Visual Studio 2010\Projects\WindowsFormsApplication4\WindowsFormsApplication4\Form1.cs:line 24
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18052 built by: FX45RTMGDR
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
WindowsFormsApplication4
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Users/aman/Documents/Visual%20Studio%202010/Projects/WindowsFormsApplication4/WindowsFormsApplication4/bin/Release/WindowsFormsApplication4.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18047 built by: FX45RTMGDR
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18021 built by: FX45RTMGDR
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18044 built by: FX45RTMGDR
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
NAudio
Assembly Version: 1.7.0.15
Win32 Version: 1.7.0.15
CodeBase: file:///C:/Users/aman/Documents/Visual%20Studio%202010/Projects/WindowsFormsApplication4/WindowsFormsApplication4/bin/Release/NAudio.DLL
----------------------------------------
NAudio.Lame
Assembly Version: 1.0.1.1318
Win32 Version: 1.0.1.1318
CodeBase: file:///C:/Users/aman/Documents/Visual%20Studio%202010/Projects/WindowsFormsApplication4/WindowsFormsApplication4/bin/Release/NAudio.Lame.DLL
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
答案 0 :(得分:4)
LameDLLWrap
是作为naudio.lame.dll
程序集中的资源存储的内部程序集对。根据您运行的位深度,将解压缩并加载32位或64位版本,然后加载相应的libmp3lame
dll。因此,必须同时将libmp3lame.32.dll
和libmp3lame.64.dll
文件与naudio.lame.dll
程序集一起部署在您的应用程序中,否则将失败
NuGet包应该将项目配置为包含两个文件,并应设置文件的属性以确保它们被复制到输出。
在项目资源管理器中,确保包含两个本机DLL libmp3lame.32.dll
和libmp3lame.64.dll
。单击每个属性并检查属性以确保这两个文件的Copy To Output Directory
属性都设置为Copy always
。
如果没有,请自行设置或使用NuGet删除并重新添加NAudio.Lame
包。
如果这不能解决问题,请告诉我,我会看看能否找出问题所在。
我使用Visual Studio 2012和2013测试了NuGet包,最新的NuGet包管理器(v2.7.41101.371)以及所有三个编译目标(x86
,x64
和{{1 }})。在所有组合中,它按预期运行。如果您使用的是其他配置,请告知我们您的回复。
** 更新
经过一些游戏后,似乎在IDE外部运行时,某些配置中的Loader未正确初始化存在问题。这是因为没有调用其中一个静态初始化器。
问题已修复,现在NuGet上的v1.0.2正在运行。请更新软件包,然后重试。
答案 1 :(得分:0)
确保将所有 dll从库复制到输出文件夹,而不仅仅是您要引用的文件夹。这些只是托管的包装库,需要它们的本地对应物才能工作。与直觉相反,如果找不到依赖库(或者,使用不同的单词,指示的dll不一定是缺少的那个),也会发生此错误。