I have a bug in an Excel VSTO 4.0 C# add-in that I've developed but it is only occurring when double-clicking on an existing file to launch Excel. I'm trying to figure out a way to start the VS2013 debugger so that I can put in some breakpoints but none of the ways I've tried to start the debugger mimic the process of launching Excel by a double-click on a file.
Ways I've tried so far:
- Launching Excel itself and then attaching to the process
- Double-clicking an Excel file and then attaching to the resulting process
- In the VS project Debug properties under Start Action, entering the path to Excel Excel.exe in the Start external program box and the path to an existing Excel file in the command line arguments box
- Adding Excel.exe as a new existing project to my VS solution with the path to an existing file as an argument in the project properties, the setting it as the startup project for the solution.
None of these methods for starting the debugger are reproducing the bug. Is there another way to start debugging when double-clicking a file to launch Excel?
For what it's worth, the bug I'm experiencing is that an empty workbook will be created when double-clicking an existing file when Excel is not already running. I need to find out where / why that empty file is getting created. It doesn't happen if Excel is already running and you double-click a file to open it.
Try to use any logging mechanisms to log any action in the code. Thus, you will be able to find what is going on in the code at runtime. For example, you can write actions to the log file. You may find the log4net library helpful.