I am getting below mentioned exception randomly when trying to get DeviceCount property of NAudio Lib in C#.
2015/05/11 Sound - GetDevices failed due to unexpected error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at NAudio.Wave.WaveInterop.waveOutGetNumDevs() at Sound.GetDevices()
Code Snip in c# is given below:
private void GetDevices()
{
var deviceCount = NAudio.Wave.WaveOut.DeviceCount;
}
Could somebody help us to identify the root cause of this issue and how can we solve it?