I try to debug several applications that communicates with each other - and want to have ability to step over without switching to another process/thread.
So Visual Studio has command "Step Over Current Process (Ctrl-Alt-F10)" - which looks like what I want but it's disabled, why?
I've found the same question but for C++:
"Step over" when debugging multithreaded programs in Visual Studio
So write macros is only way for .net too?
My understanding is there is no real way to do this in visual studio. Unlike Eclipse :D. The best you can do is use the Threads debug window to freeze all threads other than the one you want to debug.
As stated in the comments you can also use a conditional break point and set a filter like "ThreadNameToStopOn" == Thread.CurrentThread.Name
Related
So I'm now using Visual Studio 2019 in C# .Net Framework.
I have been programming in Visual Basic 6.0, and when I pressed F5 the IDE run and if there were errors while debugging if I pressed the X to close the Vb6.0 IDE. a message box prompted saying if I wanted to save the changes since there were errors while debugging I pressed no.
Now in Visual Studio 2019 using C#, that doesn't happen. If I press F5 and an error occurs while debugging, it autosaves the solution with its error. How can I stop it from saving with the error in it?
No, you can't debug code that hasn't been saved with Visual Studio. If you want to see the process it goes through, do this:
Open Tools -> Options
Click "Projects and Solutions", then click "Build and Run"
Change "MSBuild project build output verbosity" to "Normal" (or, if you want to see a lot of stuff, "Detailed" or "Diagnostic"
Rebuild your project
You'll see VS invoking the compiler and passing the paths to each of your file (and to all of your references) to the compiler. It needs to save and to compile and then execute your code.
The VS debugger is a full Windows debugger. Open Windows Explorer, double-click your EXE. Now open VS, in the Debug menu, choose "Attach to process" and choose your running EXE. You are debugging it (you can attach to any process you have rights to, but attaching to a debug build where symbols are handy give you the best experience).
BASIC and pre-.NET VB started their lives as interpreted languages. A pre-processor would take your source and convert it to tokens. Then an interpreter would interpret those tokens as it ran your programs. Though the last few versions of traditional VB could compile your code to an EXE, that interpreter was still there.
In particular, the debugger used it. When you ran the VB6 (and earlier) debugger, the debugger didn't debug your program, it debugged your source - injecting itself into the interpreter, not attaching itself to the EXE. That's why the behavior you are asking about worked.
As I mentioned, getting a Source Code Control system set up (which is always a good idea) will help you get close to what you want. Git's probably the easiest to set up. Visual Studio Team Foundation Services (or whatever it is called this month) is also a possibility.
Is there a more visual way to differentiate what process you are busy debugging when hitting a break point and then switching between the processes using the process drop down?
Something in the line of different background windows colors per process?
Possibly a add on or plugin?
At present, I haven’t found any plug-in that could highlight the process that is currently debugging in Visual Studio.
But the tools those Visual Studio offers could help us to differentiate them while multi-process debugging:
You can see there are two places where we could find out the current process under debugging:
In the process window (Debug -> Windows -> Processes), it gives the golden arrow.
In the right hand, at the top of Diagnostic Tools, there is also a pop-up which indicates the process with PID that is under debugging.
I also found thread talking about the similar issue which also might help:
How can I tell which process I am debugging (attached to multiple processes)?
In an older version of Visual Studio (Like the one at home, guess 2013), I am able to edit my code while the system is running but I can't continue (and I don't want to continue). While step-ping through my code, I just want to start typing and once I finish editing then to recompile.
The advantage is that while typing I can hoover my mouse and watch values/structures of the variables and edit according. It's a nice guide sometimes, like a reminder or notes.
Why my Visual Studio 2015 prevents me from editing my code? saying:
Changes are not allowed when unmanaged debugging is enabled
P.S my Edit and Continue option is enabled as suggested everywhere on the internet. And there is no Enable Unmanaged debugging option for 2015 like suggested here for 2010 How to: Enable Debugging of Unmanaged Code
Edit: It's a C#/C++ application. I didn't start the project from scratch and it's a huge one. I start it as Debugger and sometimes Release. Doesn't work on both (I don't care about the Release)
How my settings under Tools -> Options -> Debugging -> General look like:
You're in the completely wrong place; that's the system-wide debug options.
As explained in the post you linked to, you need to go to the Debug tab in Project Properties.
use native compatibility mode when you want to break ok C++ code. Also right click on the project and check "enable native debugging" in the project properties. Those two things should allow you to debug c++ (not edit and continue, just normal debugging)
For Visual Studio 2022, you need to add
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
in your vcxproj files (under PropertyGroup Condition subset)
I am in the process of learning C#. I downloaded and installed Visual Studio 2010 Express with C#. The problem is it has all these templates that are a little overwhelming at the moment: ASP.NET website, Library, WCF, etc.
I just want to code something very simple that takes input from the Console and outputs to it. I am making do with WCF but that's really inconvenient. It is faster for me to load up ideone.com, type my code there and compile than doing it from own my machine.
Is it even possible to create simple programs like that in C# using VS2010 Express?
Thanks everyone who answered. I installed Visual C# and now I can create console applications. But now the command window closes immediately after it's done doing whatever it's doing. Can I have it output to the IDE like I would with Java on Eclipse or Netbeans?
You can create simple apps by choosing Windows Application (if you want a GUI) or Console Application (if you just want to take input from console as you describe in the question) as project types.
Regarding the question of the console window immediately closing, the quick-and-simple fix for this is to have
Console.ReadLine();
at the end of program execution -- it'll do all it needs to do, then wait for (any) keyboard input before closing the window.
"But now the command window closes immediately after it's done doing whatever it's doing. Can I have it output to the IDE like I would with Java on Eclipse or Netbeans?"
Try running without debug mode (Ctrl+F5 or Shift+F5 or some other binding depending on your keyboard setting). The program will wait for you to press a key to exit.
If you want to output it to the IDE, you could use System.Diagnostics.Trace.Write, which writes to the trace output in the bottom on the IDE. I do not believe there is a built in stdout view in Visual Studio... but it seems like a great idea for a feature...
Are you there, Microsoft?
Visual Studio can be extremely overwhelming. What you should remember is that it's a tool for professionals, ultimately. However, if you want to make a Console app, it's quite simple.
Open Visual Studio
File
New
Project
Other Languages
Visual C#
Windows
Console Application
Done.
Yes, Visual Studio Express is a very good free tool for creating applications. Of course it doesn't have all of the features of Visual Studio, but I use it at home for several reasons.
What you want is the "Console Project" template
This is what I'm looking for: I'd like to be able to get a real time method call listing when I am debugging my program. So for example, say I run my program via the debugger if I press a button or do anything in my program I'd like for it to spit out, say on a visual studio plugin, in real time, all the methods it went through when I pressed this button or did some kind of user action with my program.
I actually once wrote a visual studio plugin that does that by using the visual studio profiler api (I had to write a c++ com server dll that receives this information and pipes it back into my c# plugin). I did this a few years back and I have no idea where I put it. But I'm wondering if Microsoft did something like this in visual studio 2010 or if you know of any third party plugins like this because it is a very handy debugging utility.
Thanks
Check out Visual Studio 2010's Intellitrace feature - it might get you what you need: http://msdn.microsoft.com/en-us/library/dd264915.aspx
You should check IntelliTrace debugging in Visual Studio 2010. It works only with x86 though
It's not free, it's not even cheap, but RedGate's ANTS Performance Profiler can provide that data and more.
I think you could achieve that using AOP, e.g. PostSharp and an implementation of it's OnMethodBoundaryAspect and a MultiCastAttribute to apply your aspect to every method of your program. They even have an example for something quite similar to what you want on their site.
Updated link as of 8/15/2018: IntelliTrace
Note that this feature is in Enterprise edition only
From the linked page:
You can spend less time debugging your application when you use
IntelliTrace to record and trace your code's execution history. You
can find bugs easily because IntelliTrace lets you:
Record specific events
Examine related code, data that appears in the Locals window during debugger events, and function call information
Debug errors that are hard to reproduce or that happen in deployment
You can use IntelliTrace in Visual Studio Enterprise edition (but not
the Professional or Community editions).
My Runtime Flow extension shows method call listing when you press a button or do anything in a program. It works outside Visual Studio debugger.