// IDispose public void Dispose() { // we may have recicular COM references to itself // e.g., via _baseIComInterface // make sure to release all references if (_baseIComInterface != null) { Marshal.ReleaseComObject(_baseIComInterface); _baseIComInterface = null; } if (_baseClassComProxy != null) { _baseClassComProxy.Dispose(); _baseClassComProxy = null; } }
// constructor public ImprovedClass() { // aggregate the CCW object with the helper Inner object _baseClassComProxy = new BaseClassComProxy(this); _baseIComInterface = _baseClassComProxy.GetComInterface <IComInterface>(); }