3

I am working on a project which capture speaker audio and write it to a MP3 File using naudio and naudio.lame . I add both DLL to my project from nugget enter link description here and its working fine but problem is when I go to bin >release or debug folder and then click on exe then it show error. I copy all DLL to that folder and also try to create new project and then add ref but nothing works still showing same error when click on exe. Any Help Thanks

Here is error msg:-

    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.
Aman Sharma
  • 311
  • 1
  • 8
  • 22
  • I also check assembly for the file version. – Aman Sharma Nov 19 '13 at 05:19
  • I am getting the same exception in an MVC 4 App with .Net Framework 4.5. It works fine in my Windows Form App. I double checked that libmp3lame.32.dll and libmp3lame.64.dll were copied into my output folders. When I try to add references manually, I get a message that implies they are not a valid assemblies. – ThisGuy Nov 19 '13 at 08:23

2 Answers2

4

LameDLLWrap is an internal pair of assemblies stored as resources in the naudio.lame.dll assembly. Depending on which bit depth you are running in, either the 32-bit or 64-bit version will be unpacked and loaded, and will then load the appropriate libmp3lame dll. As a result you must have both libmp3lame.32.dll and libmp3lame.64.dll files deployed with your application alongside the naudio.lame.dll assembly, or it will fail.

The NuGet package should configure the project to include both of the files, and should set the properties on the files to ensure that they are copied to the output.

In your project explorer ensure that you have the two native DLLs libmp3lame.32.dll and libmp3lame.64.dll included. Click on each one and check the properties to ensure that the Copy To Output Directory property is set to Copy always for both of these files.

If not, either set them yourself or use NuGet to remove and re-add the NAudio.Lame package.

If this doesn't solve the problem, let me know and I'll see if I can find out what is going wrong.

I tested the NuGet package with Visual Studio 2012 and 2013, the latest NuGet Package Manager (v2.7.41101.371), and with all three compilation targets (x86, x64 and Any CPU). In all combinations it functioned as expected. If you are using a different configuration let me know as part of your response.


**Update

After a bit of playing around, it seems that there was a problem with the Loader not being properly initialized in some configurations when run outside the IDE. This was due to one of the static initializers not being called.

Problem is fixed and v1.0.2 is now up on NuGet. Please update the package and try again.

Corey
  • 15,524
  • 2
  • 35
  • 68
  • Hi Corey I already done as you said , I copy NAudio.dll,NAudio.Lame.dll, libmp3lame.32.dll,libmp3lame.64.dll to output folder and when I click on EXE it show same error. pls look into this .But if run program by VS studio (run) its working fine . I m using 2012 VS with any CPU config. – Aman Sharma Nov 19 '13 at 08:36
  • Hi Corey, first off, thank you for this library! It works well in a Windows Form app for me. But I still can't get it to load in an MVC4 App with .Net Framework 4.5. Have you tried that? – ThisGuy Nov 19 '13 at 09:14
  • Hi Corey , Thanks its working now great work , and one more question can I change the sample rate of MP3 File I want standard sample rate 44100 of my MP3 File but currently its 16000 – Aman Sharma Nov 19 '13 at 10:02
  • Hi Corey When I try this on a 64 bit machine its showing frame rate 96000 not supported . How to make it working on 64 bit machine. – Aman Sharma Nov 19 '13 at 10:53
  • @AmanSharma The MPEG standards do not support a sample rate of 96000Hz. Supported sample rates are: MPEG2.5 = [8000, 11025, 12000], MPEG2 = [16000, 22050, 24000], MPEG1 = [32000, 44100, 48000]. The LAME libraries confirm to these, and will not handle 96000Hz samples. – Corey Nov 19 '13 at 22:50
  • @ThisGuy This is a complicated issue to do with the current directory not being what you might think when running from a web server. Could you post this as a question please so I can give a full answer - comments are not suitable. – Corey Nov 19 '13 at 23:10
  • @ThisGuy I've added a wiki page on the project site at GitHub that shows how to resolve your problem with MVC. [Click here](https://github.com/Corey-M/NAudio.Lame/wiki/Using-NAudio.Lame-with-MVC) to go to the page. – Corey Nov 20 '13 at 01:34
  • Thanks Corey for your help. – Aman Sharma Nov 20 '13 at 05:18
  • @Corey That worked. Thanks! I created a question here http://stackoverflow.com/q/20088743/910348 since it is a separate issue that others surely will face (though I suppose using the library within a web application is a bit unique). – ThisGuy Nov 20 '13 at 06:16
0

Make sure you copy all the dlls from the library to the output folder, not only the ones you're referencing. These are just managed wrapper libraries and need their native counterparts to work. Contrary to intuition, this error also happens if a dependent library cannot be found (or, with different words, the indicated dll is not neccesarily the one that's missing).

PMF
  • 14,535
  • 3
  • 23
  • 49