public COM_IOleInPlaceObject IOleInPlaceObject; // cached interface obtained from UserConrol public ExposedUserControl() { _logger.Log(LogLevel.Trace, "ExposedUserControl constructor called"); // Gain access to the IOleObject and IOleInPlaceObject interfaces implemented by the UserControl IOleObject = (COM_IOleObject)AggregationHelper.ObtainInternalInterface(this, GetType().GetInterface("IOleObject")); IOleInPlaceObject = (COM_IOleInPlaceObject)AggregationHelper.ObtainInternalInterface(this, GetType().GetInterface("IOleInPlaceObject")); }
protected override void Dispose(bool disposing) { if (IOleObject != null) { Marshal.ReleaseComObject(IOleObject); IOleObject = null; } if (IOleInPlaceObject != null) { Marshal.ReleaseComObject(IOleInPlaceObject); IOleInPlaceObject = null; } base.Dispose(disposing); }