6 Replies - 4058 Views - Last Post: 18 April 2012 - 12:49 AM Rate Topic: -----

#1 IamTw_  Icon User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 238
  • Joined: 25-February 11

Show debug trace in Visual studio

Posted 17 April 2012 - 05:22 PM

Hi.
I am trying to debug my C# code in visual studio, but my debug window doesnt show the traces. I can run the debug by inserting a breakpoint, but the window that should show me what the values are at a specific point/time doesn't show. I have tried to search for it, but I cant find any useful info. Maybe I am searching on the wrong names?
Under the debug options and setting, there are many choices, and I'd rather not check them when I don't know what they really do.

Do you know how to enable it?

Is This A Good Question/Topic? 0
  • +

Replies To: Show debug trace in Visual studio

#2 superkb10  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 298
  • Joined: 27-November 11

Re: Show debug trace in Visual studio

Posted 17 April 2012 - 05:28 PM

Can you show us the code that you're trying to debug? Where you're having your problem? It'll make it a bit easier for us to help you. But as a recommendation, try this, whatever value you're checking for, assign it to a variable, and just check the value of the variable.
Was This Post Helpful? 0
  • +
  • -

#3 IamTw_  Icon User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 238
  • Joined: 25-February 11

Re: Show debug trace in Visual studio

Posted 17 April 2012 - 05:46 PM

The code is pretty much irrelevant here, I just want to know how I enable the debug window, so that I can check the code myself everytime :-)
But here it is anyway...
The problem is that I always get the message that the I have wrong username or password, and I can't see the values of "userID" and "password", since the debug window/trace wont show. I think that the userID and or password is null, or returns an empty string for some how.

But again, I'm mostly just interested in finding out how I can debug this, cus you will probably need more code to see what's going on here. I'm sure I'll need to debug again some other time :)
<script runat="server">
     void Logon_Click(object sender, EventArgs e)
    {       
        if ((userID.Text.Equals("Brian")) && (password.Text.Equals("James")))
        {
            FormsAuthentication.RedirectFromLoginPage 
                (userID.Text, Persist.Checked);
        }
        else
        {
            Msg.Text = "Wrong username or password";
        }
    }
</script>


Was This Post Helpful? 1
  • +
  • -

#4 Curtis Rutland  Icon User is online

  • (╯°□°)╯︵ (~ .o.)~
  • member icon


Reputation: 4463
  • View blog
  • Posts: 7,778
  • Joined: 08-June 10

Re: Show debug trace in Visual studio

Posted 17 April 2012 - 05:56 PM

Ok, there are the Locals, the Watch, and the Autos pallets. All useful.

The Locals shows all variables in local scope.
The Autos shows the variables used in the current/previous lines that the debugger is on.
The Watch can evaluate most expressions, including showing variables in a higher scope.

Here's how you enable them (while debugging):
Posted Image

Here's an example of the Watch1 window:

Posted Image

Of other note: the Immediate window. This can evaluate C# statements against a current stack. If execution is paused, you can enter statements into the Immediate window using currently in-scope variables, and have them evaluated. You can even create new variables (which will be added to the Locals pallet). This is incredibly useful for debugging. Try it out.

Last note: the Call Stack window. It's great too. If you're deep in a method, you can use the call stack window to "walk" back up to where the execution went deeper. If method 1 calls method 2 which calls method 3, and you have a breakpoint in 3, you can use the Call Stack window to go back to Method 1 at the point where it called 2.
Was This Post Helpful? 4
  • +
  • -

#5 IamTw_  Icon User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 238
  • Joined: 25-February 11

Re: Show debug trace in Visual studio

Posted 17 April 2012 - 06:12 PM

That's it man.
The locals are exactly what I've been looking for. I've been looking for them like forever, those little bastards.

So it shows out that my password field returns an empty string, it doesnt get the value that is in the textbox
                <p>Password:</p>
                <p><asp:TextBox ID="pwField" TextMode="Password" runat="server" />
                <asp:RequiredFieldValidator ID="pw" ControlToValidate="pwField" 
                    ErrorMessage="Password cannot be empty" ForeColor="Red" runat="server">
                </asp:RequiredFieldValidator>
                </p>


Any idea how to get this value, when TextMode = "Password"?
Was This Post Helpful? 0
  • +
  • -

#6 Curtis Rutland  Icon User is online

  • (╯°□°)╯︵ (~ .o.)~
  • member icon


Reputation: 4463
  • View blog
  • Posts: 7,778
  • Joined: 08-June 10

Re: Show debug trace in Visual studio

Posted 17 April 2012 - 07:30 PM

Well, in your first code snippet, you're using password as the variable name. But in your ASP.NET code here, you're using ID="pwField". So, where did you declare password?

Also, moving to ASP.NET forum.
Was This Post Helpful? 1
  • +
  • -

#7 IamTw_  Icon User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 238
  • Joined: 25-February 11

Re: Show debug trace in Visual studio

Posted 18 April 2012 - 12:49 AM

View PostCurtis Rutland, on 17 April 2012 - 07:30 PM, said:

Well, in your first code snippet, you're using password as the variable name. But in your ASP.NET code here, you're using ID="pwField". So, where did you declare password?

Also, moving to ASP.NET forum.

I don't get it how I could let this one slip.
You are right. I was using the variable of the "RequiredFieldValidater", and ofcourse that one return an empty string. I guess I spent too much time in front of several line of code :)

Thanks again
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1