17 May 2010

Start External Program to Debug a Class in Visual C# 2008 Express

While playing with an automation server for MS-Excel, I wanted to debug my class method by starting Excel in Visual C# Express and using the formula in a worksheet. After the usual couple of minutes of hunting through the project property sheets, it dawned on me that you can't define the start program in the Visual C# Express IDE.

So I reopened my project in SharpDevelop (another .Net IDE), defined Start External Program in my project and continued playing with my automation server.

Checking the project files, I found that SharpDevelop added or modified the StartAction and StartProgram properties to the project's .csproj file:

  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
    <StartProgram>D:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE</StartProgram>

Then I reopened the solution in Visual C# Express and found that I could start Excel to debug the class, too! It seems that Visual C# Express debugger and MSBuild.exe tool does support the feature but the IDE doesn't allow you to edit the Start Action parameter.