Visual Studio Break all then f11 not breaking next event - c#

From this post I got this:
For debugging a button click without setting breakpoints:
Start the app with the debugger.
Get to the state immediately before the intended click.
Go back to the debugger and press Pause then F11 (Step Into) -- nothing will happen.
Go to the app and press the button -- the debugger should take over and drop you into the event handler.
This is Not Working for me however it was working for me Before. Dont know why its very awesome but not working now. Anyone?

Please reset your VS settings, and then debug it again.
I just use a simple Winform app in my side:
https://onedrive.live.com/embed?cid=55E83A59BF9AE3EB&resid=55E83A59BF9AE3EB%21893&authkey=AEmhE8zHWfnS4gE
It works well using the following steps:
(1)Debug the app(F5).
(2)Click "Ctrl+Alt+Break", I will get the result like the following screen shot.
(3)Click F11(Step Into).
(4)Click the button1, it will hit a breakpoint in the button1 click event, and then using F11 step into. The same steps as the button2 event.
I just use the default VS settings with the latest VS2015 Enterprise version 14.0.25431.01 update 3. So you could test it using the above simple sample, it still has this issue in your side, maybe we could think about the VS settings and the VS setup.

Related

Debug run time current Form in c#

I have multiple Form Application in C#, I want to debug current running Form button event with the specific line, as in the Visual Basic 6 current running Form is debug with pressing short key Ctrl+Break. Then press the button or place on the form to start the debugging process where I want.
Is there any debugging method in C# like Visual Basic 6 short key Ctrl+Break ?
Just click the line which is you suspect and press f9 it put a breakpoint and then you can use:
Step Into f11 : line by line debugging
Step Over f10 : without debugging each line it just return result
And other tactic to learn use Console.WriteLine() in form application also. In output window you can see whatever write in writeline.
Also if you want to see variable's value, you can use watch window.
To debug the code in Visual Studio, specify the breakpoint (by clicking the left side of line code) and then press the F5 key. Use F10 key to continue with step by step debugging.

Line by line inspection of code in VS 2012

I have a C# WPF Application code, which I want to understand. I am using f11 and f10 to step-in and step-over. However, once my application begins, I don't know which part of the code is executing.
Here is what I want:
I want to know which part of the code is getting executed even after the application begins and as and when I click on menu in the application, I want to see which part of code is being executed.
Please I am new to c# VS 2012 and WPF. Help me in analyzing the application code.
You have a few options:
Click Pause when running, and then Step Into. This will bring you to the line being called when you click on a button or menu item for example.
Set a break point at the point you want it to break.
Inside your code, place Debugger.Break() to stop the debugger at a specific line of code.
here are some steps you can follow.
Start your debugging from f10 not from F5. this will start you
application under debug mode but from start evetn from main method.
while runing application under debug mode you can use pause button to
peek into where your code is running right now.
Use F11 when you wish to go in to the code(code need to be in your source tree.) to see what calling function is doing.
Use mode Debug while following these steps.

ASP.NET Events Not Firing

When I run my app local through the debug button my text box changed event fires after typing something in the text box and tabbing off of it.
But if I deploy to an IIS sever and test the site, the event doesn't fire.
What could be causing this problem?
UPDATE*** Sorry for the confusion. This has nothing to do with DEBUGGING and BREAKPOINTS. The events won't fire at all when deployed to IIS but they do fire when running locally
Try this:
After deploying your code to IIS and launching the website in your browser of choice, then go to the Debug menu in Visual Studio and choose Attach To Process.... This will open up a dialog window where processes are listed, check the box Show processes from all users. and then locate the w3wp.exe process in the list, now click the Attach button. It will take a little bit of time (seconds, not minutes) to load the symbols and make your break points active. Now when you generate events and have their handlers breakpointed on the server-side, the debugger will stop at the breakpoints just like when you pressed F5 in Visual Studio before deploying to IIS.
For more information read Attach to Running Processes with the Visual Studio Debugger
Its not really the standard behaviour that the event gets fired automatically after you tab out.
For this to happen you have to say that the textbox should autopostback.
You should declare your asp:net textbox like this:
<asp:TextBox ID="helloWorldTextBox" runat="server" Text="Hello World!" AutoPostBack="True" OnTextChanged="helloWorldTextBox_TextChanged" />
If I understood you correctly you arent facing the problem of not being able to debug it, but simple that what ever should happen on the TextChanged Event isnt doing what it should do.
Another thing, if you are creating the textbox dynamically (in code behind) you have to make sure that the ID stays the same or the event wont fire. This is normally done in the Page_Init Event.

can't launch debug window to check code

I'm new to Visual Studio, I just started using it for my programming class. I downloaded C# 2010 from the website, and every time I try to debug the code the form window doesn't show up as the black box with the output, rather it displays a blank gray box. I have no clue how to check my code, I haven't been able to find anyone else with this problem, someone please help!
As you are assuming a black box - mean you want to start with a Console Application
and your are getting a gray box - mean you had chosen the Windows Form Application.
So What to do you is :
Select a Console Application.
Like File -> New -> Project -> Console Application.
Put breakpoints on your code. and press F5 to run your application in debug mode.
Put a debug point in the code on the left side where you have a empty column.. Then click F5 to run the code with debugging.. It will stop when the break point is hit..
Check this tutorial
Are you sure you have the solution configuration set to Debug ? Or is it Release? Read this for details.

Debugging all events in Visual Studio 2010 without setting break points

I am trying to debug a windows form application which has a large number of events: button presses, timers, etc..
Is there a way to catch every line of code being executed by the application without setting a break point?
edit:
The program was not written by me, so I am unfamiliar with the code. I wish to step through the entire program, catching every line of code being executed. Setting break points in every event is impractical as various controls are created dynamically.
For debugging a button click without setting breakpoints:
Start the app with the debugger.
Get to the state immediately before the intended click.
Go back to the debugger and press Pause then F11 (Step Into) -- nothing will happen.
Go to the app and press the button -- the debugger should take over and drop you into the event handler.
Note: This will not work if Paint, any Mouse event, or probably some other events are handled. The debugger will drop you into those handlers any time you attempt the steps above.
If you're using the Ultimate edition of your Visual Studio 2010 you can use its new feature called IntelliTrace (previously Historical Debugger). This will allow you to do exactly what you want - be able to see all method calls and events that happened during execution of your program, and you'll be able to jump back to the event which you need.
To enable IntelliTrace, go to Tools → Options → IntelliTrace, and check the "Enable IntelliTrace" checkbox, and select one of two modes: "events only" or "events and call information", then run your application with a debugger (F5).
The difference between the two modes is that the latter uses the profiler to collect all runtime information, so you get a complete call stack, however you won't be able to use edit-and-continue features of the debugger.
You can find more in this series of articles, and of course, on MSDN.
You could also try a code coverage tool.
For example, if you have Resharper and dotCover, you can run your application (via the dotCover->Cover Application... menu item) and when the application finishes, dotCover will show you which lines of code were run in the VS IDE by highlighting them in green. Lines of code which where not run are coloured in red.
I don't know if there are other tools which do this, but it's an option.
I developed the Runtime Flow tool to solve exactly this problem - to understand a large unfamiliar .NET codebase via realtime function calls monitoring. It's similar to IntelliTrace, but places more emphasis on control flow than on debugging.
Why would you want to break on every line? This would be very onerous and time consuming. If you want to see the activity of your program as it executes, use a logging mechanism or Debug.Writeline to output information to the Immediate window.
You cannot trace lines of code, but you can use Trace.TraceInformation calls where you want to have an idea of what's executed. There's also Debug.Write. Both output will write in the output window of Visual Studio.
Another solution would be to add logging to your application, for example with log4net, but that may be overkill for your needs.
This isn't exactly what you're asking for, but in case you didn't know you can toggle an existing breakpoint on or off. In your case, you could add break points at key places throughout your code and just disable them when you don't want to debug them. That way, you'll be able to re-enable them later when you want to use them again.
Enabling/disabling is available through the Breakpoints window found under the Debug > Windows > Breakpoints menu (CTRL+D, B). You can also include "Function" and "File" columns in the window, which might help you identify which breakpoints are in the event handlers that you care about
Not really, but you can set one breakpoint and single-step (F10/F11) through the rest of the code.
Nope 'fraid not - you need to set each breakpoint yourself.
If it helps F9 is the shortcut key for assigning a breakpoint - just set a breakpoint on the start of each method and use step through (F10) / step into (F11) from there.

Categories

Resources