/* taken from Tutorial01.csproj
All objects in NetOffice which are based on CoClasses or Interfaces are wrapping COM Proxies. It's necessary to release a created COM Proxy by the client caller.
This tells the COM Server (meaning your office application) that you do not need the instance any longer.

In the MS Interop Assemblies you do that with Marshal.ReleaseComObject(object proxy);
In NetOffice any object has the Method Dispose() to do that.
An implemented Proxy Table in NetOffice makes it possible that you do not have to call Dispose() for any (implicitly) created object.
This tutorial shows you how to use the Dispose() method to release an object and its created child objects.

See chapter1 and chapter5 in technical documentation for further info.


public void Tutorial01Main()

   /* NetOffice manages COM Proxies for you to avoid any kind of memory leaks           
   *  and make sure your application instance removes from process list if you want. */	 
   // Initialize Api COMObject Support 

   // start application
   Excel.Application application = new Excel.Application();
   application.DisplayAlerts = false;

   Excel.Workbook book = application.Workbooks.Add();
    * now we have 2 new COM Proxies created.
    * the first proxy was created while accessing the Workbooks collection from 
* application the second proxy was created by the Add() method from Workbooks
* and stored now in book with the application object we have 3 created proxies
* now. the workbooks proxy was created about application and the book proxy was
* created about the workbooks. * NetOffice holds the proxies now in a list as follows: * * Application * + Workbooks * + Workbook * * any object in NetOffice implements the IDisposible Interface. * use the Dispose() Method to release an object. the method release all created
* child proxies too. */
application.Quit(); application.Dispose(); /* * the application object is ouer root object * dispose them release himself and any childs of application, in this case workbooks
* and workbook the excel instance are now removed from process list */
MessageBox.Show(this, "Done!", this.Text, MessageBoxButtons.OK,
MessageBoxIcon.Information); }

Last edited Jan 5, 2012 at 9:34 AM by SebastianDotNet, version 28