0

In WPF I can use the following:

var texture = (INuiFrameTexture) Marshal.GetObjectForIUnknown(frame.pFrameTexture);

My INuiFrameTexture looks like this:

[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("00000000-0000-0000-C000-000000000046")]
internal interface INuiFrameTexture {

    [PreserveSig]
    int BufferLen();

    [PreserveSig]
    int Pitch();

    [PreserveSig]
    HRESULT LockRect(uint Level,ref NuiLockedRect pLockedRect,ref IntPtr pRect,uint Flags);

    [PreserveSig]
    HRESULT GetLevelDesc(uint Level, NuiSurfaceDesc pDesc);

    [PreserveSig]
    HRESULT UnlockRect([In] uint Level);
}

Now I'm trying to achieve the same in Silverlight but the framework has no GetObjectForIUnknown method. Does anybody know if there is a way to do this in Silverlight?

  • I'd try Marshal.ReadIntPtr() to get the address of QueryInterface and Marshal.GetDelegateForFunctionPointer() using a fake delegate type for QI. No idea if that can work on Silverlight. – Hans Passant May 07 '12 at 13:54
  • I've been trying this now but I can't get it to work. Could you maybe explain it a bit more in detail? I just started to work with all this marshalling so I don't understand too much of your explanation. – StevenVL May 10 '12 at 07:18

0 Answers0