Getting System.DllNotFoundException when deploying asp.net core (using NAudio) to Kubernetes

7/17/2019

I deploy asp.net core application docker image to Kubernetes cluster. My application is using NAudio to get microphone stream from the user and send to Google Speech-To-Text.

But after I deployed, getting the error below in Kubernetes logging:

System.DllNotFoundException: Unable to load shared library 'Msacm32.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libMsacm32.dll: cannot open shared object file: No such file or directory at NAudio.Wave.Compression.AcmInterop.acmStreamOpen2(IntPtr& hAcmStream, IntPtr hAcmDriver, IntPtr sourceFormatPointer, IntPtr destFormatPointer, WaveFilter waveFilter, IntPtr callback, IntPtr instance, AcmStreamOpenFlags openFlags) at NAudio.Wave.Compression.AcmStream..ctor(WaveFormat sourceFormat, WaveFormat destFormat) at NAudio.Wave.WaveFormatConversionProvider..ctor(WaveFormat targetFormat, IWaveProvider sourceProvider) at NAudio.Wave.WaveFormatConversionStream..ctor(WaveFormat targetFormat, WaveStream sourceStream) at Web.API.GoogleApi.GoogleSpeechSession.WriteBufferToStreamingContext(Byte[] buffer) in /app/GoogleApi/GoogleSpeechSession.cs:line 385 at Web.API.GoogleApi.GoogleSpeechSession.SubmitToGoogle(Byte[] buffer) in /app/GoogleApi/GoogleSpeechSession.cs:line 406

So, is there any way to deploy NAudio to Kubernetes? or I have to change to another library?

Please help me if you know about it. Thanks

-- Vo Dinh Duy
asp.net-core
c#
docker
kubernetes
naudio

1 Answer

7/17/2019

Considering that Kubernetes only very recently began to support Windows containers, and that support is still so sketchy as to virtually make Windows containers still unsupported, I'd imagine you're running linux containers.

Something like an audio library is very often going to be platform-specific, using APIs provided by a particular operating system, drivers compatible only with a particular operating system, etc. I'd imagine that's the case here: your NAudio library only works in Windows. You need to find a library that is either cross-platform or will work in linux, if you're going to be using linux containers.

.NET Core 2.0 began allowing references to .NET Framework libraries as a convenience. There's tons of .NET Framework libraries and components out there, many of which are no longer updated, but yet are perfectly compatible with .NET Standard and thus .NET Core. However, being able to add the reference is not a guarantee that will will actually work, and in particular, work cross-platform.

For what it's worth, you should attempt to mimic your production environment as closely as possible in development. In particular here, if you're going to be deploying to linux containers in Kubernetes, then you should use linux containers in your dev environment (fully supported by Docker for Windows) and even actually use Kubernetes (built in to Docker for Windows).

-- Chris Pratt
Source: StackOverflow