C# – can’t debug office word add-in

add-incdebuggingms-word

Here's what I did:

From VS2010 > new C# Project (from Other Project Types > Extensibility > Shared Add-in) > some basic configuration in the Connect class

After that I set in the project properties > debug > start external program, the path for winword (C:\Program Files (x86)\Microsoft Office\Office12\WINWORD.EXE)

When creating a shared add in, the setup files are in a separate project, in the same solution. so i did a build for the add-in, and installed it.

when i start word (separately or from Start with debug from visual studio) the add-in runs fine, but it can't seem to hit any breakpoints?

If I modify something and do just Build, when i start word again, the changes are there, so it must be the correct dll that word is loading

Question is of course, how do i get breakpoints to work?

Best Answer

First, breaks won't work at all if you run through an installed instance of the addin. You HAVE to start the addin from inside VS to be able to do any debuggins (ok technically not completely true, I +THINK+ you can "attach" to a running instance but I've never debugged that way.

You'll want to make sure you're in DEBUG build configuration. Release mode won't necessarily set things up to allow debugging.

You should be able to REBUILD the entire solution before starting it. Rebuilding the solution will register things with the registry so that word +SHOULD+ find you're add in properly.

Finally, make sure that, during all your testing runs etc, Word hasn't disabled your add in. Check Options/Addins/Com Addins and make sure your in the list and enabled.

If you're addin fails for some reason, word has a habit of disabling it and from then on not loading it unless you reenable.