NAudio 抛出没有找到合适的转换来编码或解码生产服务器上的内容

NAudio throws No suitable transform was found to encode or decode the content on production server

我有一个控制台应用程序测试 NAudio 库,下面的代码在我的本地机器和测试服务器上工作正常,但在生产服务器上抛出错误

音频文件是 .m4a 文件

class Program
{
   static void Main(string[] args)
   {
       string audioPath = ConfigurationManager.AppSettings["AudioFile"];
       Console.WriteLine(new AudioFileReader(audioPath).TotalTime.TotalMilliseconds);
       Console.ReadLine();
   }
}

错误信息

System.Runtime.InteropServices.COMException: No suitable tr
ansform was found to encode or decode the content. (Exception from HRESULT: 0xC0
0D5212)
   at NAudio.MediaFoundation.IMFSourceReader.SetCurrentMediaType(Int32 dwStreamI
ndex, IntPtr pdwReserved, IMFMediaType pMediaType)
   at NAudio.Wave.MediaFoundationReader.CreateReader(MediaFoundationReaderSettin
gs settings)
   at NAudio.Wave.MediaFoundationReader.Init(MediaFoundationReaderSettings initi
alSettings)
   at NAudio.Wave.MediaFoundationReader..ctor(String file)
   at NAudio.Wave.AudioFileReader.CreateReaderStream(String fileName)
   at NAudio.Wave.AudioFileReader..ctor(String fileName)
   at NAudioTest.Program.Main(String[] args) in C:\Users\staff\source\repos\NAud
ioTest\NAudioTest\Program.cs:line 15

关于可能导致此错误的原因有什么建议吗?

您 运行 所在的服务器缺少执行此操作所需的媒体基础编解码器。您必须安装该功能(凭记忆,我认为是“Desktop Experience”)