Friday, May 16, 2008

Troubleshooting VSTO Add-ins

During development By default, if an add-in created with Visual Studio Tools for Office throws an exception, the Office application continues without displaying the exception. Set the debugger to break on all exceptions to see when add-in exceptions are thrown. After deployment VSTO can write all errors that occur during startup to a log file or display each error in a message box. By default, these options are turned off for application-level projects. You can turn the options on by adding and setting environment variables. To display each error in a message box, set the VSTO_SUPPRESSDISPLAYALERTS variable to 0 (zero). You can suppress the messages by setting the variable to 1 (one). To write the errors to a log file, set the VSTO_LOGALERTS variable to 1 (one). Visual Studio Tools for Office creates the log file in the folder that contains the application manifest. The default name is .manifest.log. To stop logging errors, set the variable to 0 (zero).