This project has moved and is read-only. For the latest updates, please go here.

System.Runtime.InteropServices.COMException (0xC00D36E3): Exception from HRESULT: 0xC00D36E3

May 19, 2014 at 1:22 PM
Edited May 19, 2014 at 1:53 PM
On Windows Server 2008 32 bit with installed Desktop Experience I get

System.Runtime.InteropServices.COMException (0xC00D36E3): Exception from HRESULT: 0xC00D36E3
at NAudio.MediaFoundation.MediaFoundationInterop.MFStartup(Int32 version, Int32 dwFlags)
at NAudio.MediaFoundation.MediaFoundationApi.Startup()
at NAudio.Wave.MediaFoundationReader..ctor(String file, MediaFoundationReaderSettings settings)
at NAudio.Wave.MediaFoundationReader..ctor(String file)

Dll is complied for All CPU. Can somebody help me to solve it? What should I change, install to make it work. It is mvc 4.0 application. On 64 bit system it works fine.

It looks like mfplat.dll on 32 bit system is in version 11. Probably api is not compatible with current library?
May 19, 2014 at 2:30 PM
I stopped using MediaFoundationReader and switched to Mp3FileReader.
Jun 7, 2014 at 5:53 PM
Same issue here. I tried using MediaFoundationReader to play FLAC files (I have Flac drivers installed - - and the COMException brings the app down.

Here is the code I use in unit tests:
        public void FlacTestWithMediaFoundation()
            string file = @"C:\Users\...\Track.flac";
            byte[] buffer = new byte[65536];
            using (var fileReader = new MediaFoundationReader(file))
                int bytesRead;
                    bytesRead = fileReader.Read(buffer, 0, 65536);
                    Console.WriteLine("Read " + bytesRead);
                } while (bytesRead > 0);
It reads the file to the end, then throws the exception:
   at NAudio.MediaFoundation.IMFSourceReader.ReadSample(Int32 dwStreamIndex, Int32 dwControlFlags, ref Int32 pdwActualStreamIndex, ref MF_SOURCE_READER_FLAG pdwStreamFlags, ref UInt64 pllTimestamp, ref IMFSample ppSample)
   at NAudio.Wave.MediaFoundationReader.Read(Byte[] buffer, Int32 offset, Int32 count) in c:\src\naudio-current\NAudio\Wave\WaveStreams\MediaFoundationReader.cs: line 193
   at MyApp.UnitTests.FlacTestWithMediaFoundation() in UnitTests.cs: line 60
It may be worth re-iterating that while the unit test simply fails, when I try running my app and playing a FLAC file, Windows shuts the app down, implying a non-recoverable error happens there even though I have exception handling code in the important places.