' taken from Tutorial02.vbproj
'
' In Tutorial01 you have seen how to use Dispose() to release an object and its created
' children.
This Tutorial shows you how to use the method DisposeChildInstances() to
' release all children with one call.
' ' See chapter1 and chapter5 in technical documentation for further info. ' Private Sub Tutorial02Main() ' Initialize Api COMObject Support LateBindingApi.Core.Factory.Initialize() ' start application Dim application As New Excel.Application() application.DisplayAlerts = False Dim book As Excel.Workbook = application.Workbooks.Add() Dim sheet As Excel.Worksheet = book.Worksheets.Add() ' we have 5 created proxies now in proxy table as follows ' ' Application ' + Workbooks ' + Workbook ' + Worksheets ' + Worksheet ' ' we dispose the child instances of book book.DisposeChildInstances() ' we have 3 created proxies now, the childs from book are disposed ' ' Application ' + Workbooks ' + Workbook ' application.Quit() application.Dispose() ' ' the Dispose() call for application release the instance and created
' childs Workbooks and Workbook
' MessageBox.Show(Me, "Done!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information) End Sub


   See next: Tutorial03 - Using Dispose with event exporting Objects

Last edited Jan 5, 2012 at 10:01 AM by SebastianDotNet, version 5

Comments

No comments yet.