Solved

Breakpoints can not be reached at random times

Posted on 2009-07-14
11
406 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

914 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now