Hello, I don't know where I should ask this question, but I found hard to continue my C# project while I can't debug it. When I start I see "Unexpected character" instead of objects in my watch. You can see problem on picture linked above. But when I move cursor to objects, I see what they have. What should I do?
Thanks in advance.
Watch != Locals window.
Simply delete that entry from watch window (it is probably what is left from previous debug session). It's not necessarily existing variable name (you can insert any text into watch window):
Related
I'm not sure what happened but the default behavior that I've grown accustomed to has stopped working in regards to foreach followed by TAB.
For example. I type the word foreach. I press TAB. I see this:
The first template region is the box with COLLECTION in it. Normally I start typing the collection name. When I'm done I type TAB then set the VARIABLE name. etc.
What I actually get is buggy.
For example, after I type in the collection name:
I press TAB again.
Expected: it moves over to VARIABLE so that I can provide a name.
Actual: it doesn't move over, and it deletes the closing parenthesis and moves the brace, like this:
Does anyone know how to get the normal behavior restored?
Note: I do NOT want to restore defaults. That will wipe out dozens of other fine-grained format settings that I have configured.
Maybe you have some other extensions that are interfering with Resharper.
See this link for more details:
Speeding up ReSharper (and Visual Studio)
The answer is simple: restart visual studio.
For some reason resharper stops responding to normal commands and fixed itself simply by restarting the IDE.
I am working with Visual Studio 2015.
I have a big c# class file with lot of properties and methods. I want to set breakpoints to all possible lines (set and get of properties, methods) at once. How can I do that?
You could add Debugger.Break() on the end of every single line. Therefore you could use the search and replace function of visual studio and replace \n with Debugger.Break()\n (Remember activating the regular expression option). This would cause the debugger to break at every single line, even though you won't have an indicated breakpoint.
I don't think that there's a method to add normal vs breakpoints to every single line though, due to the fact that it's quite useless, considering that you normally just step through the code with F11.
I think you are looking for this,
steps to follow:
1) Add a break point on the first line of code you want to debug.
2) Run the application.
3) When you want to run the next line of code, Select Debug | Step Into
4) Repeat step #3 for each line of the code
With vim (vsvim) you can set a breakpoint, move down a line, then repeat however many times you like, eg:
{Escape}qq:vsc Debug.ToggleBreakpoint{Enter}jq100#q
will set breakpoints on the next 100 lines
edit: here is example video, wouldnt let me embed gif https://imgur.com/SFhlEr7
Step Into(F11) or use the Debugger.Break() or add breakpoint directly would be the workarounds for you, of course, I suggest you use the Step Into(F11) which was much more convenient.
If you could use the latest VS2017 version, it has a new feature "Run to Click" which is also a better workaround for you during debugging.
Actually you don't have to debug every line code, that's also the reason I suggest you use this new feature.
Run to Click: Simply click the icon next to a line of code while debugging to run to that line. No longer set temporary breakpoints or
perform several steps to execute your code and stop on the line you
want. Now while stopped at a break state under the debugger, the Run
to Click icon subtly appears next to the line of code that your mouse
is hovered over. Move your mouse to the icon and click the button, now
your code will run and stop on that line the next time it is hit in
your code path. Turn it off from Debug> Options > Enable Run to
Click.
Reference:
https://www.visualstudio.com/en-us/news/releasenotes/vs2017-relnotes
Open a feature request with Microsoft https://learn.microsoft.com/en-us/visualstudio/ide/suggest-a-feature?view=vs-2022
There should be a mode that visual studio can be put in so that it automatically stops on every line of code in a particular project. This would be VERY valuable when you attach the debugger to a pre-existing process and you don't know where in the app is the current point of execution is, ie: web apps where you do not know the entry point.
I recently started having problems with breakpoints in Visual Studio 2010. When I set a breakpoint and then start debugging, another breakpoint appears on some other line nearby. The screenshots below shows the editor after I set a breakpoint, as well as the breakpoints window:
As soon as I start debugging, the breakpoint duplicates, as seen in the following screenshots:
Why is this happening and how can I stop it?
It looks like there is a child breakpoint set up, as described in the following MSDN articles:
http://msdn.microsoft.com/en-us/library/b98cwcyw.aspx (Link dead, see
Child breakpoints VS 2010)
http://msdn.microsoft.com/en-us/library/02ckd1z7%28VS.71%29.aspx#vctskbreakpointswindowchildbreakpoints
Here is a similar question on StackOverflow, for which one of the answers contains a macro to remove child breakpoints. Perhaps that might work for you?
Disable/remove child Breakpoints?
Alternatively, deleting the parent breakpoint (which will also remove the children) and re-creating it might help to resolve the problem.
I suspect it is because of mismatched newline endings. I had similar issue - multiple lines were marked as breakpoint location (say, 10 lines). Later I found it was because of only \n or \r present, instead of CRLF sequence.
Use Save-As, select Save With Encoding.. option under Save button in SaveAs dialog box.
I had the same problem in VS 2008 and I resolved by getting rid of the duplicated .dll files in the compiling / debugging folders.
Please refer to my full response here: https://stackoverflow.com/a/50063517/3603386
Do you use F10 (step over) when debugging?
F9 is the shortcut to add/remove a breakpoint, you may be inadvertently hitting that.
I recently started having problems with breakpoints in Visual Studio 2010. When I set a breakpoint and then start debugging, another breakpoint appears on some other line nearby. The screenshots below shows the editor after I set a breakpoint, as well as the breakpoints window:
As soon as I start debugging, the breakpoint duplicates, as seen in the following screenshots:
Why is this happening and how can I stop it?
It looks like there is a child breakpoint set up, as described in the following MSDN articles:
http://msdn.microsoft.com/en-us/library/b98cwcyw.aspx (Link dead, see
Child breakpoints VS 2010)
http://msdn.microsoft.com/en-us/library/02ckd1z7%28VS.71%29.aspx#vctskbreakpointswindowchildbreakpoints
Here is a similar question on StackOverflow, for which one of the answers contains a macro to remove child breakpoints. Perhaps that might work for you?
Disable/remove child Breakpoints?
Alternatively, deleting the parent breakpoint (which will also remove the children) and re-creating it might help to resolve the problem.
I suspect it is because of mismatched newline endings. I had similar issue - multiple lines were marked as breakpoint location (say, 10 lines). Later I found it was because of only \n or \r present, instead of CRLF sequence.
Use Save-As, select Save With Encoding.. option under Save button in SaveAs dialog box.
I had the same problem in VS 2008 and I resolved by getting rid of the duplicated .dll files in the compiling / debugging folders.
Please refer to my full response here: https://stackoverflow.com/a/50063517/3603386
Do you use F10 (step over) when debugging?
F9 is the shortcut to add/remove a breakpoint, you may be inadvertently hitting that.
i have windowapplication project which contain so many forms ,,i need to
debug the application ,,but i dont know which code is related to which
UI window,..Is there any way to find the code which correspond to related
window
Open the windows and press 'F7'
Right click on the form and say "View code"
Right click the form in Solution explorer and say "View code"
If you mean other files not related to the UI you can do a "Find all references" when you right click on a specific function. This shows you all places where this function is called.
I think you're looking for an easy way to locate the code for a particular form easily without having to go through the entire codebase to determine what code goes with what form. Unfortunately, there are no easy ways that I am aware of. However, there are a couple of things that you can try:
If the form you're looking at has some sort of a lengthy operation and you're quick enough :-), you can trigger that operation and immediately do 'Break All' from the debug menu or hit 'Ctrl+Alt+Break' to break the execution right there and examine the stack trace.
You can profile your application e.g. performance exporer in VS2008 and then examine the profiler reports to get some hints as to what code is getting called. This may pinpoint or at least narrow down the code you're looking for.
Just a couple of ideas that might helpful.