/// <summary> /// This method validates that the given weak reference is alive. /// 1. IWeakReference->Resolve method returns the target's interface for the mapping IID passed to it. /// 2. If the object is not alive it returns null. /// 2. From the returned interface we get or create a new RCW and return it. /// </summary> /// <returns></returns> internal unsafe object Resolve() { IntPtr pInspectable; __com_IWeakReference *pComIWeakReference = (__com_IWeakReference *)m_pComWeakRef; Guid inspectableIID = Interop.COM.IID_IInspectable; int result = CalliIntrinsics.StdCall__int( pComIWeakReference->pVtable->pfnResolve, m_pComWeakRef, &inspectableIID, &pInspectable); if (result >= 0 && pInspectable != IntPtr.Zero) { try { return(McgMarshal.IInspectableToObject(pInspectable)); } finally { // Release the pInspectable. McgMarshal.ComRelease(pInspectable); } } return(null); }