Thursday, March 1, 2012

VS 2010 breakpoint not breaking in form load method

I was playing around with a windows forms application, I have removed some references, edited the designer.cs, changed from .NET4 to 3.5 then to 2 then back to 4, and some other things.

After that I was trying to debug, and added a breakpoint to the onload method, the code wasn’t breaking at it.

Started looking at what might have changed, compared the reference, some reference was missing, like the system.core and Microsoft.CSharp. the system.core cann’t be added manually, it is added automatically by the visual studio, so I edited the .csproj file and added it manually

    <Reference Include="System.Core" />   

Compared project config file, and project settings, all looks fine

Then next I set another breakpoint at the constructor function, that was breaking the execution.

So it seems the onload function is not called somehow.

Going back to the designer.cs, the onload method attaching was deleted from the InitializeComponent() method

Adding the line back, every thing went to normal

this.Load += new System.EventHandler(this.Form1_Load);