Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Breakpoints can not be reached at random times

Posted on 2009-07-14
11
Medium Priority
?
415 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

963 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