none
Audio COM Exception RRS feed

  • Question

  • I've basically copied the RecordAudio sample line for line into a new project that is a Windows Form Project.  I continually get a COM expection of the form

    Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Research.Kinect.Audio.IMediaObject'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{D8AD0F58-5494-4102-97C5-EC798E59BCF4}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

    from this line

                  while ((count = audioStream.Read(buffer, 0, buffer.Length)) > 0 && totalCount < recordingLength)
    

    All I've done is placed the code from the Program class into a Button click event as I would like to integrate positional audio capture with some other form features.  Any ideas?  Thanks, great SDK!

     

    Friday, June 17, 2011 1:44 PM

Answers

  • Hi

    As mentioned in the FAQ:

    1. Problem: COM exception when using KinectAudioSource
    Characteristics: Most commonly seen in Visual Basic as a COM casting error, but can also be seen in multithreaded C# applications.
    Solution: Make sure thread is marked with [MTAThread] attribute and not [STAThread] attribute, since underlying COM object only supports multi-threaded apartments. Note that Visual Basic threads are STA by default and C# threads are MTA by default.

    check out the "Sample Shape Game" and the Recognizer class there. Worked perfectly for me ! :)

    Franz

    Friday, June 17, 2011 2:40 PM

All replies

  • Hi

    As mentioned in the FAQ:

    1. Problem: COM exception when using KinectAudioSource
    Characteristics: Most commonly seen in Visual Basic as a COM casting error, but can also be seen in multithreaded C# applications.
    Solution: Make sure thread is marked with [MTAThread] attribute and not [STAThread] attribute, since underlying COM object only supports multi-threaded apartments. Note that Visual Basic threads are STA by default and C# threads are MTA by default.

    check out the "Sample Shape Game" and the Recognizer class there. Worked perfectly for me ! :)

    Franz

    Friday, June 17, 2011 2:40 PM
  • Ah yes, there is a STAThread attribute in Program.cs.  That would explain it.  So, is there currently a way to have the functionality of components from Windows Forms and the Kinect?  Seeing as how the Form components need a STAThread attribute?
    Friday, June 17, 2011 2:41 PM
  • Must have been typing at the same time.  I'll see if the relevant code works.  Thanks.

    Friday, June 17, 2011 2:55 PM