VS 2013 debugger won't step into methods in an external class library

176 views
Skip to first unread message

Simon

unread,
Jun 24, 2015, 8:30:47 PM6/24/15
to exce...@googlegroups.com, si...@simonandmargaret.com
I wonder if anyone can help me with this.

I have a solution with an EXCEL-DNA project (*IPCalcExcel) and an ordinary C# class library project (IPCalcCore).  I've made sure that the class library IPCalcCore is referenced by IPCalcExcel, and that both projects, when built output .pdb files.  I've edited the .dna file to ensure that both resultant dll files are named and are packed for distribution.  Everything runs fine at runtime.

However:

I find that breakpoints set in the statup project IPCalcExcel will work, but that breakpoints set up in IPCalcCore will simply be skipped over.  Also stepping into an IPCalcCore method from a breakpoint in IPCalcExcel doesn't work.  It just gets stepped over.

I then created a third project being a console application ConsoleTestIPCalc which also references IPCalcCore.  From this application, debugging works properly.  It seems only from my Excel-DNA classes that debugging is restricted.

I've made sure that all projects target the same .NET framework 4.5

I'm sure it must be possible to debug the way I want to.  I must have some option set incorrectly.  Can anyone suggest some settings I may be missing?

Regards and thanks

Simon

Govert van Drimmelen

unread,
Jun 25, 2015, 6:13:27 AM6/25/15
to exce...@googlegroups.com

Hi Simon,

 

I suggest you try these steps:

 

·         Rebuild your whole project.

·         Start Excel on its own (not under the debugger).

·         Attach you Visual Studio to the Excel process using the Debug->Attach to process dialog. Ensure that the right debugger engine is selected (click on the EXCEL.EXE process, then look at the Attach To: part, and set this to Managed (v4.5, v4.0) code).

·         Attach the debugger.

·         Now File->Open your add-in in the bing\Debug directory.

·         Debugging and breakpoints should work.

 

Once you’ve done this, future debugging sessions will remember which engine to use and all should be fine.

 

-Govert

 

 

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at http://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

Simon

unread,
Jun 25, 2015, 8:23:50 PM6/25/15
to exce...@googlegroups.com
Hi Govert

Thanks for your reply.  Unfortunately this procedure did not make any difference.  I still can't get the debugger to step into my class library.  Do you have any other suggestions?

Regards

Simon

Simon

unread,
Jun 25, 2015, 9:02:41 PM6/25/15
to exce...@googlegroups.com
Hi Govert, 

Further to this problem.  I tried a few other things:

I created a new solution with simpler classes and also two projects. This new solution debugs perfectly.  I checked every setting I could find between my two solutions, but I could not find a difference. 

One more strange thing:

When I debug my new solution, it opens excel as expected and the worksheet is named "Book1" as expected.  However when I debug my IPCalcExcel solution, it opens excel, and the worksheet is always named "Book2".  This always happens, even if there is no other Excel running.  I even rebooted my computer to make sure.  Is it possible that somehow my add-in is opening two copies of excel and attaching the debugger to the wrong one?

Regards

Simon

Simon

unread,
Jun 25, 2015, 9:14:35 PM6/25/15
to exce...@googlegroups.com
Hi Govert,

Some more information.  I changed the setting in my External library IPCalcCore to LoadFromBytes="false" and the debugging works again.  I have yet to see what side-effects this will have.

My .dna file now reads:

<DnaLibrary Name="IPCalcExcel Add-In" RuntimeVersion="v4.0">
  <ExternalLibrary Path="IPCalcExcel.dll" LoadFromBytes="true" Pack="true" />
  <ExternalLibrary Path="IPCalcCore.dll" LoadFromBytes="false" Pack="true" />
...

All the best

Simon

Govert van Drimmelen

unread,
Jun 26, 2015, 4:56:25 AM6/26/15
to exce...@googlegroups.com

Hi Simon,

 

Setting LoadFromBytes=”false” means you can’t rebuild the project while Excel has the add-in open.

 

The “Book2” situation is normal – it happens if your add-in attempts to connect to the COM object model before it is properly initialized. To force Excel to initialize it, Excel-DNA opens a workbook, which it immediately closes again – that one was Book1. So the next book opened will be Book2. This should have no other side-effects, and I know of no other way to get Excel to initialize COM in that setting.

 

-Govert

https://groups.google.com/group/exceldna/attach/5a7675ce694d44e1/image001.png?part=0.1&authuser=0

Reply all
Reply to author
Forward
0 new messages