System.IO.FileNotFoundException:无法加载文件或程序集';LameDLLWrap,版本=1.0.0.0

System.IO.FileNotFoundException:无法加载文件或程序集';LameDLLWrap,版本=1.0.0.0,dll,naudio,Dll,Naudio,我正在从事一个项目,该项目捕获扬声器音频并使用naudio和naudio.lame将其写入MP3文件。我将DLL从添加到我的项目中,它工作正常,但问题是当我转到bin>release或debug文件夹,然后单击exe,它就会显示错误。我将所有DLL复制到该文件夹,并尝试创建新项目,然后添加ref,但在单击exe时仍显示相同错误。 有什么帮助吗 谢谢 下面是错误消息:- ee the end of this message for details on invoking just-in-

我正在从事一个项目,该项目捕获扬声器音频并使用naudio和naudio.lame将其写入MP3文件。我将DLL从添加到我的项目中,它工作正常,但问题是当我转到bin>release或debug文件夹,然后单击exe,它就会显示错误。我将所有DLL复制到该文件夹,并尝试创建新项目,然后添加ref,但在单击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.

确保将库中的所有DLL复制到输出文件夹,而不仅仅是引用的DLL。这些只是托管包装器库,需要它们的本地对应项才能工作。与直觉相反,如果找不到依赖库(或者,使用不同的单词,指示的dll不一定是丢失的dll),也会发生此错误。

确保将库中的所有dll复制到输出文件夹,而不仅仅是引用的dll。这些只是托管包装器库,需要它们的本地对应项才能工作。与直觉相反,如果找不到依赖库(或者,使用不同的词,所指示的dll不一定是缺少的dll),也会发生此错误。

LamedLwrap
是作为资源存储在
naudio.lame.dll
程序集中的一对内部程序集。根据运行的位深度,32位或64位版本将被解压缩和加载,然后加载相应的
libmp3lame
dll。因此,必须将
libmp3lame.32.dll
libmp3lame.64.dll
文件与应用程序一起部署在
naudio.lame.dll
程序集旁边,否则将失败

NuGet包应将项目配置为包含这两个文件,并应设置文件的属性,以确保将它们复制到输出

在project explorer中,确保包含两个本机dll
libmp3lame.32.dll
libmp3lame.64.dll
。单击每个文件并检查属性,以确保这两个文件的
Copy to Output Directory
属性都设置为
Copy always

如果没有,可以自己设置,或者使用NuGet删除并重新添加
NAudio.Lame

如果这不能解决问题,请告诉我,我会看看是否能找出问题所在

我使用最新的NuGet软件包管理器Visual Studio 2012和2013(v2.7.41101.371)以及所有三个编译目标(
x86
x64
任何CPU
)测试了NuGet软件包。在所有组合中,它都按预期运行。如果您使用的是不同的配置,请在回答中告诉我


**更新

经过一段时间的尝试后,似乎在某些配置中加载程序在IDE之外运行时没有正确初始化存在问题。这是由于没有调用其中一个静态初始值设定项


问题已经解决,v1.0.2现在在NuGet上运行。请更新包并重试。

LamedLwrap
是一对内部程序集,作为资源存储在
naudio.lame.dll
程序集中。根据运行的位深度,32位或64位版本将被解压缩和加载,然后加载相应的
libmp3lame
dll。因此,必须将
libmp3lame.32.dll
libmp3lame.64.dll
文件与应用程序一起部署在
naudio.lame.dll
程序集旁边,否则将失败

NuGet包应将项目配置为包含这两个文件,并应设置文件的属性,以确保将它们复制到输出

在project explorer中,确保包含两个本机dll
libmp3lame.32.dll
libmp3lame.64.dll
。单击每个文件并检查属性,以确保这两个文件的
Copy to Output Directory
属性都设置为
Copy always

如果没有,可以自己设置,或者使用NuGet删除并重新添加
NAudio.Lame

如果这不能解决问题,请告诉我,我会看看是否能找出问题所在

我使用最新的NuGet软件包管理器Visual Studio 2012和2013(v2.7.41101.371)以及所有三个编译目标(
x86
x64
任何CPU
)测试了NuGet软件包。在所有组合中,它都按预期运行。如果您使用的是不同的配置,请在回答中告诉我


**更新

经过一段时间的尝试后,似乎在某些配置中加载程序在IDE之外运行时没有正确初始化存在问题。这是由于没有调用其中一个静态初始值设定项


问题已经解决,v1.0.2现在在NuGet上运行。请更新软件包并重试。

我还检查了程序集的文件版本。我在使用.Net Framework 4.5的MVC 4应用程序中遇到了相同的异常。它在我的Windows窗体应用程序中运行良好。我仔细检查了libmp3lame.32.dll和libmp3lame.64.dll是否已复制到我的输出文件夹中。当我尝试手动添加引用时,会收到一条消息,表明它们不是有效的程序集。我还会检查程序集的文件版本。在使用.Net Framework 4.5的MVC 4应用程序中,我也会遇到同样的异常。它在我的Windows窗体应用程序中运行良好。我仔细检查了libmp3lame.32.dll和libmp3lame.64.dll是否已复制到我的输出文件夹中。当我尝试手动添加引用时,会收到一条消息,表明它们不是有效的程序集。嗨,Corey,我已经按照您所说的做了,我将NAudio.dll、NAudio.Lame.dll、libmp3lame.32.dll、libmp3lame.64.dll复制到输出