none
counterpart for System.Runtime.InteropServices.Marshal.GetIUnknownForObject RRS feed

  • Question

  • Hello All!

    I have some .NET object instance. I have got IUnknown for this object by calling GetIUnknownForObject.
    How I can cast IUnknown to .NET object back? What should I do with .Release() and .AddRef() to avoid memory leaks?

    Thanks!

    WBR, Dmitry

    Dmitry Shuklin, http://www.shuklin.com
    Sunday, May 24, 2009 6:47 PM

Answers

  • You can go back by casting the return value of Marshal.GetObjectForIUnknown().  The IUnknown pointer indeed needs to be released, call Marshal.Release().

    Hans Passant.
    Sunday, May 24, 2009 7:03 PM
    Moderator

All replies

  • You can go back by casting the return value of Marshal.GetObjectForIUnknown().  The IUnknown pointer indeed needs to be released, call Marshal.Release().

    Hans Passant.
    Sunday, May 24, 2009 7:03 PM
    Moderator
  • Hans, Thank You Much!!!
    Dmitry Shuklin, http://www.shuklin.com
    Sunday, May 24, 2009 7:07 PM