这段代码已经很好地工作了很长时间,但是现在突然开始做这个疯狂的事情,有时,代码失败并且崩溃程序,即使我的代码在try-catch语句中。这是失败的代码:
try
{
audioFileReader = new AudioFileReader(file); // here's where Im getting the exception
waveOut = new WaveOutEvent();
FadeInOut = new FadeInOutSampleProvider(audioFileReader);
waveOut.Init(new SampleToWaveProvider(FadeInOut));
PlaySource = Filetype.MP3;
}
catch (Exception e)
{
OnError.Invoke(e);
PostError(e);
}
这是我得到的例外:
NAudio.dll
中出现'System.InvalidOperationException'类型的第一次机会异常附加信息:采样率为48000,采样率为44100的MP3格式.Mp3FileReader不支持采样率变化。
为什么代码不会跳到“catch”部分而是崩溃?
答案 0 :(得分:2)
@Tokfrans - 因为这不是你的代码抛出异常。