QueryInterface fails with E_NOINTERFACE on C# RRS feed

  • Question

  • Hi MSDN members,

    I'm a newbie to C# programming. I am developing a basic camera streaming and still capture application. Once user takes still, I will be displaying it on overlay using VMR9's bitmap mixing concept.

    What I did?

     - I am making use of C# direct show library from
     - First I get all required filters interfaces. Find the attached capture device. Called Render stream with source filter and vmr9 for PREVIEW pin. Source filter, sample grabber and null renderer for STILL PIN.
     - I am having three menu buttons -> take still, show overlay and hide overlay.
     - I am making use of bitmap mixer sample provided in that library.
     - Each time user presses Take Still menu, image will be saved in desktop and will be re-sized to small resolution and displayed on video overlay.
     - Show Overlay and hide overlay calls ShowHideBitmap() which perform operation of querying VMR9BitmapMixer interface from vmr9 filter, fills VMR9AlphaBitmap structure and then calls IVMRMixerBitmap9.SetAlphaBitmap function.

    What issue I face?

     - After taking still, if I call ShowHideBitmap() through menu option, the still image taken is being updated perfectly on overlay.
     - This is another option that performs automatic update of overlay as soon as still image is saved. I create event based thread and made it to wait for update event created using EventWaitHandle. Before returning from samplegrabber BufferCB function, I set this update event. Which in turn proceeds with waiting thread. Inside thread I call ShowHideBitmap function. In this scenario, I receive error message as follows.

    `Unable to case COM object of type 'DirectShowLib.VideoMixingRenderer9' to interface type 'DirectShowLib.IVMRMixerBitmap9'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{ced175e5-1935-4820-81bd-ff6ad00c9108}' failed due to the following error: No such interface supported (Exception from HRESULT: 0X80040002 (E_NOINTERFACE)`

    Here is the code block of ShowHideBitmap function

        private static IBaseFilter vmr9 = null;
        private static IVMRMixerBitmap9 vmr9mixerBitmap = null;
        private IVMRWindowlessControl9 vmr9windowlessCtrl = null;
        private static void ShowHideBitmap(Boolean bEnable)
        int hr = 0;
        VMR9AlphaBitmap alphaBmp;
        if (!bEnable)
            if (vmr9mixerBitmap != null)
                // Get current Alpha Bitmap Parameters
                hr = vmr9mixerBitmap.GetAlphaBitmapParameters(out alphaBmp);
                // Disable them
                alphaBmp.dwFlags = VMR9AlphaBitmapFlags.Disable;
                // Update the Alpha Bitmap Parameters
                hr = vmr9mixerBitmap.UpdateAlphaBitmapParameters(ref alphaBmp);
                // Create a surface from our alpha bitmap
                vmr9mixerBitmap = null;
                //Release this alpha bitmap source.
                if (alphaBitmap != null)
                alphaBitmap = BitmapGenerator.GenerateAlphaBitmap();
                // Create a surface from our alpha bitmap
                if(surface == null)
                    surface = new Surface(device, alphaBitmap, Pool.SystemMemory);
                // Get the unmanaged pointer
                unmanagedSurface = surface.GetObjectByValue(DxMagicNumber);
                if (vmr9mixerBitmap == null)
                    vmr9mixerBitmap = (IVMRMixerBitmap9)vmr9;
                // Set Alpha Bitmap Parameters for using a Direct3D surface
                alphaBmp = new VMR9AlphaBitmap();
                alphaBmp.dwFlags = VMR9AlphaBitmapFlags.EntireDDS;
                alphaBmp.pDDS = unmanagedSurface;
                alphaBmp.rDest = GetDestRectangle();
                alphaBmp.fAlpha = 1.0f;
                // Set Alpha Bitmap Parameters
                hr = vmr9mixerBitmap.SetAlphaBitmap(ref alphaBmp);
            catch (Exception ex)

    And here is the thread the waits for update event.

            Thread overlayupdatethreadhandle = new Thread(new ThreadStart(overlayupdatethread));
            private void overlayupdatethread()
                } while (true);
    I have tried updating this overlay using timer which was running at background with interval of 100ms. Using timer was working good, but for this operation, using timer is of bad choice. So i moved with threading concept.

    Why is that getting interface failed while calling from thread and works good when calling from menu options? Should I have to take care of any special thing?  I have even tried parametrized thread, but no luck.  

    Thanks in advance for your help.

    Please mark Vote as helpful when it is so.

    • Moved by Jason Dot Wang Friday, March 29, 2013 7:08 AM This thread is about XNA
    Wednesday, March 27, 2013 8:38 AM

All replies

  • What does dxdiag say for your environment.   Do you have a card that has Direct3D support?

    Wednesday, March 27, 2013 9:33 AM
  • Hi Ron,

    My platform supports Direct3D. Because, I am able to make it work while controlling through menu or timer. The reason for not able to control through thread is due to violation of cross-threaded access. I am digging up for ideas to implement cross threaded COM object access. Can you provide some idea for cross threaded COM access?

    Please mark Vote as helpful when it is so.

    Wednesday, March 27, 2013 10:41 AM
  • Hi SathyaKumar,

      Welcome to MSDN Forum Support.



      You'll need to post it in the dedicated App Hub Forum  for
    more efficient responses, where you can contact
    App Hub  experts.

    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us

    Friday, March 29, 2013 7:08 AM