Corey-M/NAudio.Lame

Sample code throws 'System.DllNotFoundException' in LameDLLWrap

Closed this issue · 3 comments

Attempting to run sample code

// Convert WAV to MP3 using libmp3lame library
    public static void WaveToMP3(string waveFileName, string mp3FileName, int bitRate = 128)
    {
        using (var reader = new AudioFileReader(waveFileName))
        using (var writer = new LameMP3FileWriter(mp3FileName, reader.WaveFormat, bitRate))
            reader.CopyTo(writer);
    }

throws DllNotFoundException.

I don't have any DLL's anywhere on my machine that start with libmp3lame... should those be included with NuGet package?

The LAME DLLs are included in the package and should be copied to your build folder when you build your project. If you look in bin\Debug (or bin\Debug\netcoreapp3.0 or wherever the build output goes) you should find NAudio.dll, NAudio.Lame.dll, libmp3lame.32.dll and libmp3lame.64.dll alongside your project's executable. If not then something has gone wrong with your build.

I've just tested from scratch on a machine that hasn't had NAudio.Lame on it before. Created a new project, added the nuget and the sample code. This compiles and runs without error and correctly performs conversion, so it seems odd that you are having this issue.

Can you tell me more about your environment? OS version, VS version and so on.

I was seeing NAudio.dll and NAudio.Lame.dll in the [project]\bin\Debug directory, but I wasn't seeing the libmp3lame.32.dll or libmp3lame.64.dll.

I cleaned the solution, uninstalled / reinstalled the packages via NuGet package manager, and now I see the formerly missing DLLs. I ran a test and all appears to be working.

I'm running Windows 10 Pro 64-bit (10.0, Build 18362) (18362.19h1_release.190318-1202)
VS: Microsoft Visual Studio Community 2019 Version 16.3.9
VisualStudio.16.Release/16.3.9+29509.3
Microsoft .NET Framework Version 4.8.03752

NAudio: v1.9.0
NAudio.Lame: v1.1.0

OK, sounds like you had a bad package install through NuGet. Glad its' working for you now.