To release the reference to the variable, set the variable equal to Nothing or Null. The .ReleaseComObject decrements the reference count of the RCW, and the loop makes sure that the underlying COM component is released regardless of how many times it has re-entered the CLR. Use .ReleaseComObject in a loop until it returns 0 when you have finished using an object. For example, change the following line of code: To make sure that the Office application exits, determine whether your automation code meets the following criteria:ĭeclare each object as a new variable. Therefore, if all references have not been released on the RCW, the COM object does not quit. The RCW keeps a reference count on the COM object. NET calls a COM object from managed code, it automatically creates a Runtime Callable Wrapper (RCW). NET, the Office application does not exit when you call the Quit method. When you automate a Microsoft Office application from Microsoft Visual Basic. See the other products that this article applies to.
0 Comments
Leave a Reply. |