Exception is thrown only when VS 2005 is running in debug mode

Last post 12-21-2007 1:03 PM by JeffRod. 1 replies.

Sort Posts:

  • Exception is thrown only when VS 2005 is running in debug mode

    12-21-2007, 11:14 AM
    • Member
      68 point Member
    • JeffRod
    • Member since 09-27-2006, 11:27 AM
    • Posts 50

    I have a pretty complex page with FormView configured with Item, Edit and Insert Templates. In my code behind, I reference some controls in the various templates and everything runs fine. However, when I hit F5 to run the debugger, the FormView's control collection is empty (I've checked as far as the PreRender event) and therefore my page breaks. Putting a check for nulls would probably be a good idea, but thats avoiding the issue of why the control collection is empty in the first place. So running it in the debugger breaks my page. Interestingly, if I stop debugging and just "View in Browser" everything works according to plan. This is all taking place in VS 2005.


    Then I open up the same web site in VS 2008 and run it in the debugger and everything runs perfectly again. I'm not sure why this is happening but I sure am glad that I have VS 2008 to be working on. Does anyone know anything about this?

     

    Thanks, Jeff 

    Filed under: , ,
  • Re: Exception is thrown only when VS 2005 is running in debug mode

    12-21-2007, 1:03 PM
    • Member
      68 point Member
    • JeffRod
    • Member since 09-27-2006, 11:27 AM
    • Posts 50

    I have a correction. I determined that the error throws in VS 2008 too but the issue is not running the site in the debugger - at least not directly. The error only gets thrown if I make a reference to the FormView.Controls collection in the debugger. This can be either in the watch windows or in the mouse-over menus when I hover over the FormView object in the code-behind. So if I add a watch to, say, FormView1.Controls.Count or FormView1.FindControl("TextBox1") or FormView1.Controls(0), then this exception will be thrown and crash my page.

    If I remove these references from the debugger, the page will run successfully in both 2005 and 2008. 

    It almost seems like a .NET "Don't Ask, Don't Tell" policy. As long as I dont ask my FormView about it's controls, everything is cool. As soon as I ask, everything hits the fan. That would be fine and all, except there's another bug on my page that I need to fix!!!!!
     

Page 1 of 1 (2 items)