PIAs are .NET interop wrappers. This means that in the object's destructor (or Dispose - I donβt remember) it will automatically process the reference count. The trick is that some links will not be released until the garbage collector is executed. It depends on what the COM object creates. For example, a COM object that opens database cursors will store these cursors in memory until a reference counter to these cursors is released. Using .NET / COM interaction, links are not displayed until the garbage collector executes or you explicitly publish the link using Marshal.ReleaseComObject (or FinalReleaseComObject).
I personally have not worked with PIA Microsoft Office, but in most cases you do not need to explicitly release links. It is only when your application starts blocking other resources or a failure that you should start to suspect broken links.
EDIT: If you are faced with a situation where you need to clear COM / Interop objects, use Marshal.FinalReleaseComObject, which translates the reference count to zero, and not just decreases by one - and set the reference to the object to null. You can explicitly force the garbage collection (GC.Collect) if you really want to be safe, but be careful with the GC too often, as this causes a noticeable performance hit.
source share