Эта ошибка произошла в следующей строке:
Код: Выделить всё
_guideData = _transportInformationFilter as IGuideData;Код: Выделить всё
_transportInformationFilterЯ предположил, что ошибка каким-то образом произошла из-за _transportInformationFilter был преждевременно выпущен, и я связал это со следующим методом (удалена обработка ошибок):
Код: Выделить всё
private void AttachGuideDataEvent()
{
IConnectionPoint connPoint = null;
IConnectionPointContainer connPointContainer = null;
try
{
connPointContainer = _transportInformationFilter as IConnectionPointContainer;
if (connPointContainer == null) /* error */
var guideDataEventGuid = typeof (IGuideDataEvent).GUID;
connPointContainer.FindConnectionPoint(ref guideDataEventGuid, out connPoint);
if (connPoint == null) /* error */
int cookie;
connPoint.Advise(this, out cookie);
if (cookie == 0) /* error */
_persistIGuideDataEventCookie = cookie;
}
finally
{
if (connPointContainer != null)
Marshal.ReleaseComObject(connPointContainer);
if (connPoint != null)
Marshal.ReleaseComObject(connPoint);
}
}
Учитывая это, в каких ситуациях мне необходимо явно освобождать COM-объекты (используя Marshal.ReleaseComObject) в C#, чтобы избежать утечки ресурсов?
Подробнее здесь: https://stackoverflow.com/questions/508 ... eried-thro