Resources for IT Professionals > Forums Home > Using Forums Forums > Off-Topic Posts (Do Not Post Here) > Word application quit or Marshal.ReleaseComObject?
Ask a questionAsk a question
 

QuestionWord application quit or Marshal.ReleaseComObject?

  • Wednesday, November 04, 2009 3:59 PMHaripraghash Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    I have seen lot of people using word application.quit and  Marshal.ReleaseComObject to close the winword process. I am using Marshal.ReleaseComObject to close my word document. Which approach should i take? Marshal.ReleaseComObject or word application.quit. I started using Marshal.ReleaseComObject because the quit option started giving me errors like "cannot cast Application to _Application"

    Please mark the response as answers if it solves your question or vote as helpful if you find it helpful. http://thoughtorientedarchitecture.blogspot.com/
    • Moved byCindy MeisterMVPWednesday, November 04, 2009 4:05 PMnot a VSTO project (From:Visual Studio Tools for Office)
    •  

All Replies

  • Wednesday, November 04, 2009 4:05 PMCindy MeisterMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    This question is off-topic in the VSTO forum, as VSTO solutions run in-process with the application as tools for extending the user interface. The application hosting the VSTO solution is never sent the command to quit from the VSTO solution. The forum's Please Read First message lists venues more appropriate for questions about general office "interop".

    FWIW you should always Application.Quit to end the Word application instance. Hard to say why you might be getting errors, since we don't know your code or the architecture of your application. I suggest you post to one of the venues listed in Please Read First. When you do, be sure to

    1. Mention the version of Word involved

    2. Show the code that instantiates the Word application, as well as the code that's failing, plus anything else you consider relevant

    3. Mention the programming language and version of Visual Studio you're using
    Cindy Meister, VSTO/Word MVP