Sunday, March 6, 2011

Breakpoints are not hit when debugging in Visual Studio 2010


You may not be able to debug Excel Add-In with VS2010. Here are details of this problem and steps to fix the same.

Problem:        
Excel Add-In b breakpoints are not hit when debugging in Visual Studio 2010

Reason:
This problem occurs when you debug an add-in project targeting to .NET Framework 2.0-3.5 in VS 2010. The reason is the debugger, which doesn't know what .NET Framework version your add-in uses.
To find out that info, the debugger checks the .config file of the executable, which is the host application in your case. The examples of configuration file names are outlook.exe.config and excel.exe.config; if such a file exists, it is located in the Office folder; say, for Office 2007, the folder is C:\Program Files\Microsoft Office\OFFICE12. If the .config file is missing or it doesn't point to a specific .NET Framework version, the debugger uses the debugging engine of .NET Framework 4.0.

Solution:
To help the debugger, you can create (or modify) the .config file(s) for the Office application(s) installed on your PC.

Create a Excel.exe.config file with following content. 


<xml version="1.0"?>
<configuration>
  <startup>
    <supportedRuntime version="v2.0.50727"/>
  </startup>
</configuration>

You just need to place this file in Office folder (C:\Program Files\Microsoft Office\OFFICE12).

2 comments:

  1. Very Useful:


    I had been struggling with the debugging my excel addin.

    I was not able to debug my code using any of the following methods.
    1. By setting Excel.exe as 'Start External Project' from Project Properties > Debug Tab
    2. By 'Attach to process' launched 'Excel.exe' from debug menu.

    This solution has worked for me in Office 2013 with x64 bit compilation of Excel Addin.
    Now I am able to debug my code using both the methods.

    Thanks
    Harminder Singh

    ReplyDelete
  2. Thanks Harminder.

    Thanks a lot for your appreciations.

    ReplyDelete