Home » excel » excel – Breakpoints not triggering in VSTO Add-in

excel – Breakpoints not triggering in VSTO Add-in

Posted by: admin April 23, 2020 Leave a comment

Questions:

I was made aware of an interesting situation by my client today. I am sure it is something simple but seems like I can’t put my finger on it. Have never faced this issue and Google has not been too helpful.

Problem

On my client’s laptop, the Add-In is created with Add-in Express™ for Microsoft® Office and .net. When running the Add-in from VS, the breakpoints do not trigger. I logged in via teamviewer. We created a new test project (Add-in) and added this simple code.

Private Sub AdxExcelAppEvents1_WorkbookOpen(sender As Object, hostObj As Object) Handles _
AdxExcelAppEvents1.WorkbookOpen
    MessageBox.Show ("Hello World")
End Sub

I put a breakpoint on AdxExcelAppEvents1_WorkbookOpen and ran. I got the message when I opened a new workbook but the breakpoint did not trigger.

I tested the same code on my laptop and it works just fine.

What has he and I tried

  1. Unregister, Clean + Rebuild, Register
  2. Manually cleaning the Debug folder
  3. Repairing Add-In Express
  4. Uninstalling/ReInstalling Add-In Express
  5. Jumping between frameworks 4.5 and 4.6, 4.7.1
  6. Toggling Tools | Options | Debugging | General require source files to exactly match the original version
  7. Toggling Solution platforms (x86|64|AnyCPU)

Applications

  1. Visual Studio Version: 2019 Pro
  2. MS Office: 2016 Professional Plu 2016

Let me know if you need anything else?

FYI: This has been crossposted at Add-in Express forum I usually do not crosspost but seems like my client is under pressure and has to deliver this project on monday morning.

How to&Answers:

You can use the method Debugger.Break from System.Diagnostics and observe if you get more information about a plausible unhandled exception. In this case, we get the exception wkernelbase.pdb not loaded and Siddharth found it can be fixed by selecting : Tools->Options->Debugging->Symbols->Select "Microsoft Symbol Servers".

Answer:

I suppose there’s an {excel}.exe.config file in the Office folder. The .config requires all add-ins to use .NET 2.0 (3.0, 3.5).

That would explain the issue: you use .NET 2.0 (3.0, 3.5) while the debugger expects to use .NET 4.0 (4.X).

And yes, Add-in Express is built around the COM Add-in technology, not VSTO Add-in.