Hi,
I just started with vb.net and I am not really familiar with releasing COM object yet.
I am using Visual Studio 2015 and my program is for Office 2007 and above.
So I am trying to do it perfect but I am not sure if this is the correct way to release COM objects.
Example:
[...]
If ActiveWindow IsNot Nothing Then
Marshal.ReleaseComObject(ActiveWindow.SELECTION.ShapeRange)
Marshal.ReleaseComObject(ActiveWindow.SELECTION)
Marshal.ReleaseComObject(ActiveWindow)
ActiveWindow = Nothing
End If
[...]
- Is it necessary to release each level separately?
Seen here: http://www.codeproject.com/Tips/235230/Proper-Way-of-Releasing-COM-Objects-in-NET
- Is it “dangerous” to use more than two dots at a time when working with COM objects (ActiveWindow.SELECTION.ShapeRange) - Or should
I assign each level to a seperate variable?
Seen here: http://www.siddharthrout.com/2012/08/06/vb-net-two-dot-rule-when-working-with-office-applications-2/
- Is there a way to check at the end of each function – at least in debugging mode – if there is any COM object left behind and not released yet?
Many thanks.