Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Breakpoints can not be reached at random times

Posted on 2009-07-14
11
409 Views
Last Modified: 2012-05-07
I'm trying to Debug my ASP.NET Application and I've set a couple of breakpoints. However, when I run the application in Debugger it runs right past the two breakpoints (i.e. there's a empty yellowish circle that shows up quickly over the first breakpoint but then the application runs) and therefore you cannot step-into the code to test it.
I also noticed that there is no "Rebuild" or "Clean" options under the "Build" website menu in VS 2005 like there is when I build Windows Forms applications. I'm relatively new to ASP.NET Development and am not sure why the breakpoints will not work. I would appreciate any experience on this dilemma. Below is a simple program and the Source code and C# Code behind code.
Thanks Experts,
Wally
------- Default.ASP Source Code ----------------
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="WelcomeLabel" runat="server" Text="Enter your name and travel details for this year or last year"
            Width="358px"></asp:Label><br /><br />
        <asp:TextBox ID="NameTextBox" runat="server"></asp:TextBox><br /><br />
        <asp:ListBox ID="CountryListBox" runat="server" SelectionMode="Multiple">
        </asp:ListBox><br /><br />
        <br />
        <asp:Button ID="ThisYearButton" runat="server" Text="Visted This Year" OnClick="TheButton_Click" /> &nbsp;
        <asp:Button ID="LastYearButton" runat="server" Text="Visited Last Year" /> <br /><br />
        <asp:Label ID="ResultLabel" runat="server"></asp:Label>
        <hr />
    </div>
        <asp:Label ID="TimestampLabel" runat="server"></asp:Label>
    </form>
</body>
</html>
-------------- Code Behind --------------------------
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
 
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            CountryListBox.Items.Add("Austrailia");
            CountryListBox.Items.Add("Canada");
            CountryListBox.Items.Add("France");
            CountryListBox.Items.Add("Germany");
        }
 
        TimestampLabel.Text = DateTime.Now.ToString();
    }
    protected void TheButton_Click(object sender, EventArgs e)
    {
        ResultLabel.Text += String.Format("Countries visted by {0}: <br />", NameTextBox.Text);
 
        foreach (ListItem item in CountryListBox.Items)
        {
            if (item.Selected)
            {
                ResultLabel.Text += "* " + item.Value + "<br />";
            }
        }
        ResultLabel.Text += "<br />";
    }
}

Open in new window

0
Comment
Question by:wally_davis
  • 7
  • 4
11 Comments
 

Author Comment

by:wally_davis
ID: 24850998
FYI, This is a Website Project.
0
 
LVL 8

Expert Comment

by:ppittle
ID: 24851534
Where are you putting your break points?
0
 

Author Comment

by:wally_davis
ID: 24851635
I'm starting out by putting my breakpoints at 1.  if (!IsPostBack) and 2. ResultLabel.Text += String.Format("Countries visted by {0}: <br />", NameTextBox.Text);
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:wally_davis
ID: 24851657
Just so you know, the entire web application runs in the IE 7.0 Browser and and I can fill out the textbox and ListBox and it postsback to the Local ASP.NET Server (Not using IIS) and it renders all the information in the final two ResultLabel.Text Labels.
0
 
LVL 8

Expert Comment

by:ppittle
ID: 24851716
ASP.NET and VS can get a little odd when dealing with Websites.  ASP.NET will compile the site on first request and the version that the web server is using will not neccesarily be the version on the file system.  ASP.NET actually builds everythign out to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\.  This can be a bit of a pain until you get used to it, especially coming from windows development.

Try this:
1) Close IE and kill the Visual Stuio web Server (there's an icon for it in your system tray)
2) From Visual Studio goto Debug -> Start Debugging.  This should launch up a new version of the Visual Studio web server, rebuild your site, and Visual Studio should attach to the web server and you should be able to debug.

Alternatively, you may find it easier to use the Web Application template in Visual Studio as opposed to a web site (File -> New Project -> Web Application).  This template is similiar to a Windows or Console Application and doesn't have quite as many quirks as creating a Web Site.

HTH,

PJ
0
 

Author Comment

by:wally_davis
ID: 24851942
ppittle, I did everything you indicated, step by step, and even created a new "Web Application" , i.e. Choosing to create a Web Application Project vs. a New Web Site Project and still to no avail.
Again, the entire Web app was run during debug and postback occured after entering all the data in the two input controls.
I appreciate your help so far. Any other ideas?
0
 

Author Comment

by:wally_davis
ID: 24851965
Something else of interest. I noticed that no \Bin folder was created nor any *.pdb files, etc. are under the Project path at all.
0
 
LVL 8

Expert Comment

by:ppittle
ID: 24853511
That's an interesting observation.  In your web.config, make sure you have this line:
<system.web>
      <compilation debug="True">
0
 

Author Comment

by:wally_davis
ID: 24853816
Yes, the compilation debug is set to true:

<?xml version="1.0"?>
 
<configuration>
  
    <appSettings/>
    <connectionStrings/>
  
    <system.web>
        <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
        -->
        <compilation debug="true" />
        <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
        <authentication mode="Windows" />
        <!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.
 
        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
    </system.web>
</configuration>

Open in new window

0
 

Accepted Solution

by:
wally_davis earned 0 total points
ID: 24860788
Decided to try VS 2008 I have loaded on my PC. Moved my Website over from VS2005 and tested the breakpoints. Works perfect. Something must have gotten botched during the VS2005 Install.
0
 
LVL 8

Expert Comment

by:ppittle
ID: 24860804
The tried and true re-install.  Sorry it came down to that, but glad to hear you got everything figured out.  Happy coding!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question