My local computer OS is Win 7SP1 64bit.
The Server is Windows Server 2012R2 64bit.
I use NAudio to Convert AAC file into WAV file:
MediaFoundationReader mfReader =
new MediaFoundationReader(path);
string tempfilename = Guid.NewGuid() + ".wav";
MemoryStream otStream = new MemoryStream();
WaveFileWriter.WriteWavFileToStream(otStream, mfReader);
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition",
"attachment; filename=" + HttpUtility.UrlEncode(tempfilename, Encoding.UTF8));
Response.BinaryWrite(otStream.ToArray());
Response.Flush();
Response.End();
It works fine on my own computer,but throw exception on server.
System.Runtime.InteropServices.COMException (0x80004005): 对 COM 组件的调用返回了错误 HRESULT E_FAIL。 在 NAudio.MediaFoundation.MediaFoundationInterop.MFCreateSourceReaderFromURL(String pwszURL, IMFAttributes pAttributes, IMFSourceReader& ppSourceReader)
I have already installed the "Meida Foundation" And "Desktop Experience" features on server ,but it still dont work.
Have I missed small configuration? or just NAudio doesn't support working on servers?
I forgot mention a detail that "path" parameter is a URL Link,not a local file's name.
So,the error actually caused by a network 404 since the Server's network environment is much more restricted.
Then I changed the URL which server can reach,and it threw a different error:
System.Runtime.InteropServices.COMException (0xC00D36C4): 不支持给定的 URL 的字节流类型。 (异常来自 HRESULT:0xC00D36C4)
So I tried to use "WebClient" to download the AAC file first,and read it from local disk.
It finaly worked!
In Conclusion:NAudio sure can work on server 2012,but some of its feature may be restricted.