Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all articles
Browse latest Browse all 1741

Commented Unassigned: When to release event's COMObject? [21067]

$
0
0
When to release the newContentControl, DO I NEED to release it by myself, or NetOffice release it?

In the DocumentEvents2.cs
public void ContentControlOnExit([In, MarshalAs(UnmanagedType.IDispatch)] object contentControl, [In] [Out] ref object cancel)
{
Delegate[] recipients = _eventBinding.GetEventRecipients("ContentControlOnExit");
if( (true == _eventClass.IsCurrentlyDisposing) || (recipients.Length == 0) )
{
Invoker.ReleaseParamsArray(contentControl, cancel);
return;
}

NetOffice.WordApi.ContentControl newContentControl = NetOffice.Factory.CreateObjectFromComProxy(_eventClass, contentControl) as NetOffice.WordApi.ContentControl;
object[] paramsArray = new object[2];
paramsArray[0] = newContentControl;
paramsArray.SetValue(cancel, 1);
_eventBinding.RaiseCustomEvent("ContentControlOnExit", ref paramsArray);

cancel = (bool)paramsArray[1];
}
Comments: ** Comment from web user: cgh_chen **

Open Source Project, Debug find the error code !


Viewing all articles
Browse latest Browse all 1741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>