NAudio icon indicating copy to clipboard operation
NAudio copied to clipboard

Crash without exception on .net framework 4.8

Open martenf opened this issue 2 years ago • 2 comments

Im running into the exact same problem as #789, but while using .net framework 4.8 and NAudio 2.0.1.

The crashing code:

private static readonly WaveOutEvent SoundPlayer = new WaveOutEvent();
private static readonly SortedList<string, WaveFileReader> SoundsList = new SortedList<string, WaveFileReader>();

...

SoundPlayer.Stop();

var nextSound = SoundsList[soundName];
nextSound.Position = 0;

SoundPlayer.Init(nextSound);
SoundPlayer.Play();

The nuget references:

<package id="Microsoft.Win32.Registry" version="4.7.0" targetFramework="net48" />
<package id="NAudio.Core" version="2.0.0" targetFramework="net48" />
<package id="NAudio.WinMM" version="2.0.1" targetFramework="net48" />
<package id="System.Security.AccessControl" version="4.7.0" targetFramework="net48" />
<package id="System.Security.Principal.Windows" version="4.7.0" targetFramework="net48" />

Windows event:

Faulting application name: MyApp.exe, version: 1.12.2022.223, time stamp: 0x62274627
Faulting module name: msvcrt.dll, version: 7.0.17763.475, time stamp: 0xf362c2f9
Exception code: 0xc0000005
Fault offset: 0x0000000000074b9a
Faulting process id: 0x414
Faulting application start time: 0x01d832e4e5e161b0
Faulting application path: D:\SoundCrashTest\MyApp.exe
Faulting module path: C:\Windows\System32\msvcrt.dll
Report Id: 6f201770-d678-40cd-8faf-29b2f7fcc01f
Faulting package full name: 
Faulting package-relative application ID: 

Environment:

OS: Microsoft Windows 10 Enterprise LTSC
Architecture: 64bit
.Net runtime: 4.8

martenf avatar Mar 08 '22 14:03 martenf

Maybe worth trying with WasapiOut instead in NAudio 2.1.0 Also, WaveOutEvent was never originally designed to be used with multiple calls to Init (although is more resilient to that now). It might be worth trying creating a new instance instead of re-using the old one.

markheath avatar May 14 '22 15:05 markheath

Try to update Visual C++ Runtime

EzeKees avatar Aug 22 '22 19:08 EzeKees