This project has moved. For the latest updates, please go here.
/* taken from Tutorial02.csproj
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.
*/
public void Tutorial02Main() { // Initialize Api COMObject Support LateBindingApi.Core.Factory.Initialize(); // start application Excel.Application application = new Excel.Application(); application.DisplayAlerts = false; Excel.Workbook book = application.Workbooks.Add(); Excel.Worksheet sheet = (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(this, "Done!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); }


  See next: Tutorial03 - Using Dispose with event exporting Objects

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

Comments

No comments yet.