Excel COMAddin in C# - debugging...

Developing COM Addins for Excel is a case of creating a new class library, implementing the IDTExtensibility interface, writing the code and then deploying and debugging.One of the great things about C# is that you can attach the Visual Studio debugger to your code, set breakpoints and then step through the code to find bugs.  A downside of this is approach is that:

Console.WriteLine():

does not work when debugging a Class library, since there is no console in a Class Library.

So, the "right" way to do this is to create a Debug build and then use

System.Diagnostics.Debug.WriteLine();

To debug your code you then

  • Create a debug build
  • In the project properties tab set the "Start Action" to "Start external program"
  • Set the path of the external program to the path to the Excel executable.
  • Set some breakpoints in your C# code.
  • From within the IDE start debugging.
  • An Excel instance will be created and you will then hit any breakpoints and step into the code.

Comments