Questions regarding freeing resources reserved by MarshalInterface.FromManaged() #1191
-
Hello team, I'm making the transition from the old Framework-provided CCW marshalling to the new CsWinRt/WASDK-provided alternative and there's something I'm not clear about. The old I can't for the life of me find any documentation on the new I'm assuming the IntPtr returned from The interop docs say the new replacement for Basically, what do I have to do after using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@mqudsi When you call |
Beta Was this translation helpful? Give feedback.
@mqudsi When you call
FromManaged
on a C# implemented object, a CCW is created for it (if none exists) for which the pointer is returned and the reference count on the CCW is incremented. This pointer which is returned is basically the ABI representation of the object and also owns the reference count. If you want to release the reference, you can make use ofDisposeAbi
as you mentioned or if you passed that pointer to the native side, the native side can callRelease
on theIUnknown
interface just like any other COM object.