2
votes

When I add Microsoft Excel Object Library (reference Microsoft.Office.Interop.Excel), breakpoints placed in c# code stop working. And I have to debug using MessageBox.Show(). Is it a solution to make breakpoints work?

How to reproduce:

  1. Create a new SSIS package.
  2. Add a Script Task.
  3. Edit the Script task with some simple code, for example:

    // TODO: Add your code here

    string test = "test";
    
    MessageBox.Show("test " + test);
    
    Dts.TaskResult = (int)ScriptResults.Success;
    
  4. Place a breakpoint on MessageBox row, then launch the debug (F5). The breakpoint works!

  5. Edit the script task again, add a reference to Microsoft Excel Object Library 16.0 (COM Objects section).
  6. Try to debug again. The breakpoint doesn't work!
  7. You got it.

I'm using DataTools (Visual Studio 2015) on 32bit Windows 7, target framework is .NET Framework 4.5.

1
It would be awesome if you could provide a minimal reproducible example. If you remove the reference, does the problem stop? - mjwills
Is it a solution? Sure, using MessageBox.Show() is a solution, but not the best one. You could also log to a file. Without some example code to demonstrate what you're doing, there's not much we can do. - Dan Wilson
There are many reasons why your breakpoints are no longer working, but without understanding the specifics of your situation it's nearly impossible to say why. - Dan Wilson
@DanWilson the only reason is adding Interop Excel. Nothing other was changed - Laser42
Please provide some code, including the line(s) where you are trying to break. Provide the version of Excel Interop that you are using. Provide your project framework version. We need details. - Dan Wilson

1 Answers

0
votes

It happens because Excel.Interop is COM extension, and C# code with COM extensions cannot use breakpoints. So, I use MessageBox.Show or static class that logs given string to SQL table to see what happens in my C# code