Pete's Windows, Office, VB & SQL Blog

Problems I have solved (or not) and good ideas I've found

Posts Tagged ‘Debugger

Breakpoints cannot be set in method or class with the ‘DebuggerStepThrough’ attribute when the debugger option ‘Just My Code’ is Enabled

leave a comment »

If you are trying to get to some system generated code in VB 2008 Express then ignore all comments you find about Tools … Options … Debugger.  It doesn’t exist.  Right clicking and un-ticking ‘Step over properties and operators’ will similarly have no effect.

In the file ‘class-name.Designer.vb’ there is a compiler directive:

<System.Diagnostics.DebuggerStepThrough()>

If this is commented out, then breakpoints can be set.

Why do I need to do this?

Simple.  The form setup includes access to my code.  In my case setting the initial value in a combo-box generates:

Me.cmbDisp.Text = “Activity”
  
Which in turn triggers a cmbDisp.SelectedIndexChanged event, and off to my code it goes (just as it should) BUT this is no longer system generated code, so the compiler should allow debug to occur, it is not clever enough to realise that it has switched from a class in a system generated file, to a class in a user generated file.  The debugger simply fails the program, and provides an inner exception with no code references.

Written by fisherpeter

2010 June 2 at 09:19

Posted in VB Express 2008

Tagged with

Follow

Get every new post delivered to your Inbox.