ASP.NET WebForms application. There is a custom web control (IE inherits from System.Web.UI.WebControls.WebControl). I can put breakpoints anywhere in CreateChildControls() or any other overloaded method and these breakpoints work fine. However, if I try to add a breakpoint to a method that is bound to a Button on the page, I get an error on the breakpoint:

The breakpoint will not currently be hit.  No executable code of the debugger's target code is associated with this line.  Possible causes include: conditional compilation, compiler optimizations, or the target architecture of this line is not supported by the current debugger code type.

I've tried cleaning the solution, deleting all bin/obj folders, restarting local IIS, recycling the app pool, all to no avail.

Code is in VB.NET (sorry). Here is the function definition (in the WebControl code):

 Private Sub AddToCartClick(ByVal sender As Object, ByVal e As System.EventArgs)
      // breakpoint on line 1

Here is the code that ties the function to the Button:

 Dim button = new Button
 AddHandler button.Click, AddressOf AddToCartClick

The code executes and has worked for a long time, but I cannot debug it with breakpoints.

Related posts

Recent Viewed