index > Visual Studio Tools for Office > Word is still running after you stop debugging it in Visual Studi...

Word is still running after you stop debugging it in Visual Studi...

Hi

G.T.
I run into similar issues debugging Excel VSTO addins. I have learned to close Excel and let Studio follow. My guess is due to the nature of VSTO, the resource dispose change does not conviently flow into the COM interops and office applications stay open due to reference counting issues.



OmegaMan
OmegaMan

I have the Visual Studio SDK, there is a custom debugger sample there, but I can?? find how to extend the existing debugger.

If I can simply extend the debug of C# so I can register all the COM instances that my application is using, so when VS.NET stops the application, it will stop the instances.

But no idea how, I believe the VSTO team faced the same problem with word, just want to know who they went around it.

G.T.

GT,

I am one of the developers that worked on this problem for VSTO. Unfortunately, your scenario has a few details that make it unrelated to the one we faced in VSTO.

In your scenario, you are actually debugging your winform application, not office. When you hit Stop in the debugger, your application is terminated forcefully by the IDE (think Win32 TerminateProcess). No finalizers run, no dispose methods are called, the process just ceases to be. This is where your problem lies. You are automating office externally which means your application is actually talking to COM Interop RCWs (runtime callable wrappers). The RCWs are holding references to objects in Office's automation object model across process (via IUnknown.AddRef). The externally automated app does not shutdown unless the ref-count for these objects drops to zero, or the it is terminated. The finalizer for an RCW releases its reference to the com object via a call to IUnknown.Release. However, like I explained above, hitting stop in the debugger does not execute finalizers. Therefore the reference is leaked and office will continue running. If, however, you close your application gracefully (via the exit button or some other means) finalizers will run in most scenarios and office should shut down cleanly.

In VSTO, the addins run inside of the Office process (i.e. word or excel). The debugger is attached directly to that process, not an external application like in your scenario. When the user hits stop, the debugger attempts to make the application shutdown cleanly. Failing that, it forcefully terminates the process. So, in VSTO, the lifetime of the process is not directly linked to the ref-counts of the object when debugging ends.

Hope that helps clear it up a little.

Jackson Davis - [MSFT]

This post is provided AS-IS and confers no rights.

Jackson Davis - MSFT
How is Microsoft addressing this situation in the next version of VSTO and Excel?

Thanks,



OmegaMan
OmegaMan
reply 5

You can use google to search for other answers

 

More Articles

• More problems with the permissions (Word, VSTO 2005)
• I cann't publish the metadata IBF
• Problem in Charts
• Modifying Infopath controls through scripting
• Error on Visual Studio Tools for Office "v3" install
• OWC chart control-Share point Web part
• Is there anyway I could get the position of a control(FormField) ...
• Deploy VSTO word template
• Can VSTO be used create class libraries
• Cypress applicability to Office 2003 (installable without Office ...
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Help with Outlook Object Model Guard...
• Problem with COM objecto
• how to publish vsto word document in to
• Access Denied starting MS Outlook from W
• How to do ignore spelling error using VSTO
• Searching Files
• [Urgent] How to trap Excel Window Scroll
• Caching with app add-ins
• Communicating with Outlook like ActiveSync
• SetSpreadsheetData method with OWC Chart
• display image in listobject
• Errors using Inspectors in Outlook AddIn
• Delete a range in VSO
• Word - Page Extraction
• Extending/Adding Word, Excel and Visio m

Hot Articles

• DLL VB express 2005 in Excel
• word xml layout
• Error: Office Document Customization in
• VSTO - Outlook - Unload addin
• New to VSTO....please help!
• How to remove Outlook add-in
• VSTO Outlook 2007 Architecture Problems
• How to prevent a new toolbar button from
• Safe to obfuscate a VSTO solution?
• Word.interop - Saveas usage
• Mailto mode
• Is it possible to link project # 1 to pr
• How to get the version inforamtion of mi
• How to process items in a PST-File witho
• Msosec policy will have negative impact

Recommend Articles

• Insert Data into a Workbook
• Excel Template And Sharepoint
• Can I clear the undo list w/o saving Pre
• activeCell.Value2 problem
• ActionsPane And The Disappearance Act (W
• Shared Add-In
• How do I notice when the User change the
• VSTO 2005 Beta2 FAQ
• Evet type: clr20r3 P1: outlook.exe P2: 1
• Outlook: no Add-In does load anymore
• VBA/excel programming investing software
• PowerPoint Paste Special using C#
• Prolem with add-in for MSProject 2000 in
• Running Word Merge client side with a do
• Text in a Form Field?