This project has moved. For the latest updates, please go here.

Application.Dispose

Jun 4, 2014 at 11:27 AM
Hello

I have the following scenario.
  • Word is not running
  • I create a netoffice word Application object from an independent .NET application
  • open a document and make some manipulation from the .NET application
  • the manipulation from the .NET application is completed
  • the document must remain open and the user uses the document for what ever he wants to do
  • does I have to call Application.Dispose() on the Netoffice Wrapper in the independent .NET Application in this case or not?
thanks
Jun 14, 2014 at 9:14 AM
I think should Add a method to the NetOffice.Factory.Remove(COMObject), remove it from the COMObject List who is created and not disposed.
Coordinator
Jul 19, 2014 at 6:12 AM
hey ho,

its your choice. keep the instance alive or dispose them. (the instance is still alive anyway what you do) if you dispose the instance then you have no chance any longer for any programatic access but keep in your mind, word doesnt dies if you release(dispose) the word instance. you have to call close (or quit, not sure) to shutdown the process.

i'm not sure you want, it sounds like for me keep the instance open and leave the user alone, or you still want track what happen?

hmm.. not sure but hope this helps
*Sebastian
Jul 19, 2014 at 8:32 AM
I have notice the code may call Close() to shutdown the process.
public virtual void Dispose(bool disposeEventBinding){
...
// call quit automaticly if wanted
        if (_callQuitInDispose)
            CallQuit(_underlyingObject);

        // release proxy
        ReleaseCOMProxy();

        // clear supportList reference
        _listSupportedEntities = null;

        _isDisposed = true;
        _isCurrentlyDisposing = false;
    }
/// <summary>
    /// calls Quit for a proxy
    /// </summary>
    /// <param name="proxy"></param>
    private static void COMObject.CallQuit(object proxy)
    {
        try
        {
            if (Settings.EnableAutomaticQuit)
                Invoker.Method(proxy, "Quit");
        }
        catch (Exception exception)
        {
            DebugConsole.WriteException(exception);
        }
    }
Settings.cs
/// <summary>
    /// Get or set the Quit method for an application object was automaticly called while Dispose. false by default
    /// </summary>
    public static bool EnableAutomaticQuit
    {
        get
        {
            return _enableAutomaticQuit;
        }
        set
        {
            _enableAutomaticQuit = value;
        }
    }