Cannot Debug

Feb 13, 2013 at 4:37 PM
Hi, I am using Window 7 64 bit and Excel2007 32-bit, I have .Net framework 4.5 and uses VS2012 Premium. I open the example solution in Distribution\Sample\VisualStudio\CSharpAddIn\ and follow the steps in the word file to set up debugging.

When I launch debug in VS2012, the Excel launched as expected and my add-in is loaded and the AddThemCS functions is visible, but when I execute a it, the process does not hit the breakpoint but my function runs just fine in Excel.

I have tried many things but nothing seems to work. Would you know what the main issue is? Thank you very much!
Feb 13, 2013 at 6:49 PM
Hi Steve,

I think Visual Studio might be attaching the wrong debugger. VS can only load one version of the managed debugger. So one example that I suspect goes wrong is if your Excel instance already has an add-in that loaded the .NET 2.0 runtime, and your add-in targets .NET 4. Then VS will attach the .NET 2.0 managed debugger, and then not be able to debug your code.

One way to deal with it is to start Excel first, then Attach to Process from your Visual Studio, being careful to select the right managed debugger in the dialog before attaching. If this works once, you might find that it continues to work - it seems Visual Studio remembers some debugger settings for a project.

Anyway, that's about everything I know about getting the debugging going.

Feb 13, 2013 at 7:07 PM
Hi Govert,

Thank you. Attach the debugger to the Excel process would allow me to debug my code. VS does not remember the debugger settings though so I still cannot debug straight from VS. If I found a solution I will post it here in the future, but thank you and this solved my problem for now.

Aug 9, 2013 at 8:04 PM
This problem happened to me once, but I found out what was going on wrong.
VS was not allowing me to debug at the breakpoint either.

In my case, I had my Excel addin XLL already installed as an addin in Excel, and while debugging my code, the loaded addin was interfering with the debug session.
Once I uninstalled the addin in Excel, I was able to debug my code again.
I hope this might help some others experiencing the same problem.