I was just asked this question internally and I thought I would share with everyone:
Can I debug the OneNote add-in within Visual Studio? I tried to attach OneNote.exe but it did not stop at any breakpoint.
I wanted to let people know that you can debug one of these powertoys, here's some notes for debugging a C# OneNote toolbar addin:
If anyone has any problems or needs help please let me know. I answered this internally and I wanted to make sure external people knew about this as well. Take care!
Note: a lot of the credit goes to David Tse who gave me these details.
You can also add this code to your object constructor in order to launch the debugger from inside of your addin:
ctor{
#if DEBUG
System.Diagnostics.Debugger.Launch();
#endif
}
This will either launch a new debugger or attach to an already existing one (also the code gets compiled away under Release mode removing all chances of the debugger launching).
blair
This also works, if (!Debugger.IsAttached) Debugger.Break();
Hello,
I am having a problem, the button appears in the tool bar in One note correctly, but as soon as it is clicked on it becomes disabled.
the popup never appears.
Kevin Damen
Kevin - This means that the toolbar addin isn't registered correctly. Have you read my documentation here:
http://blogs.msdn.com/descapa/archive/2006/08/31/734298.aspx
I have also seen problems if you are using Vista and have UAC/LUA disabled. You can always turn on the debugging and see what error OneNote sees when trying to call the COM methods.
I have the same problem as Kevin. I did put a message box in addin class' constructor and it appears so OneNote does find the addin class. However after I do anythign - for example close the message box - my addin button is disabled and no events go through.
I have succesfully used DevPal addin, so I know I have a "home made" problem somewhere but I just am not able to locate it. Any ideas?
I had the same issue trying to use the Search and Replace add-in.
I went back into my Office installtion setup and noticed that .NET Programmability Support was not installed. Just for good measure I also installed Microsoft Forms 2.0 .NET Programmability Support.
Worked like a charm!
I launched OneNote and clicked the button; the form window popped right up. I didn't even have to reboot or go dig out my Office 2007 installation media!