I am going to do some code in c# using visual studio 2010. The problem is that every time I run program it does appear in command prompt.
I would like place the output of the program in the console like in the Eclipse. System.Diagnostics.Debug.Write("abc"); this does not work cause if I look at the output I see much more information than I want. I would like to see only data which would show in the command prompt.
Check out "Tools->Options->Debug->Output Window" - you should be able to decrease amount of traces to your liking.
Side note: normally "output of program" means results of Console.WriteXXXX methods, so maybe you are looking for something completely different.
I think you wish to turn off verbose Output logging so that only your Debug.Write's will be written to the output window.
To do this you goto Tools > Options > Debugging > Output Window > and turn off the verbose logging:
If you want to keep all of your output, you can redirect your Debug.Print to output to the Immediate Window instead.
Tools -> Options -> Debugging -> General | Click on Redirect all Output Window text to the Immediate Window.
This does not mean everything will be outputted to it, just the output that you designate in your code and any exception messages that get thrown. It's a lot less chatty and still keeps your Output window with all the standard messages.
Related
I am new to Visual Studio Express 2015 and whole C# stuff (I come from the JAVA world).
I want to see some test string output (like checking variable values etc.) I am sending with Debug.WriteLine() during Debug mode run (F5), but the output window disappears immediately (is replaced by split dual windows). Yet when I close the running app, output window shows up back again WITH MY TEST STRING OUTPUT from Debug.WriteLine(); there - how come?
This is what I call "output window" (sorry, don't know how to call it when it has written Output on it, really...)
This is what I see when I test/run (F5) my app ("output" window is gone):
And this is what I see when I stop/close my app - "output" window is back again also with my test string I sent with Debug.WriteLine():
How can I run my app in Debug mode and also make that output window still visible during the run/test, so I could see my string output in realtime?
I need to see some test values I am sending to the output, or is there some other way how to do this in C#/Visual Studio Express 2015?
In JAVA I use NetBeans and I use Output window/CMD exactly for this, so I thought this is its equivalent. And as I see the output actually is there, it probably is, right?
Just to clarify even more: I am not creating console app that runs in CMD window, I just need to see that test output somewhere and I thought - being completely new to C# coming from JAVA - that the Output window is the place where I can see it.
Like when you C# guys need to see some test values in realtime during the app run/test, how do you do that - where your output goes? Or are you telling me there is nothing like this in Visual Studio GUI (I don't think so as I see after the app is closed my test value is present in that "output" window - the window is just not there during the app run, so...)?
I have the namespace using System.Diagnostics; in place, yet it still act as described above: in Debug mode the output window disappears, so I don't know what the string output is (have no clue how to make the window being visible still) and only comes back again once the app is closed (then there is my string output presented in the output window), with the Release mode the output window is there but no string output is displayed - it stays completely empty during the app run/test.
You just need to enable it..through the Debug->Windows->Output
I'm debugging a C# console application using Visual Studio for the Mac. I'm using frequent Console.WriteLine() statements.
Is there anyway to clear the output of the Terminal - macOS pad where the Console output is displayed every time I run / debug the program? I've tried calls to Console.Clear() to no effect. I have seen suggestions to use Cmd-K but that doesn't work. Other suggestions are all for VSCode, not Visual Studio.
Surely I can't be the only one who finds seeing the old output distracting when debugging?
You aren't alone. I was just wondering why it didn't clear the screen either. There is an option to use Terminal, instead of the built in terminal. Check under Preferences > Terminal, then remove the check mark next to "Enable Integrated Terminal" and it will just pop up in a normal terminal which doesn't seem to have that issue. If you figure something else out let me know though.
You may deactivate and reactivate the integrated terminal in : preferences\terminal options\uncheck\check. You may have to close VSFM between the uncheck\check process in order to clear the entre data. That way, it does clear the terminal data, but I would prefer some fast “clear” kind of short-cut options instead.
Have a good one.
Prog
Close the terminal window, then the next run will open an empty one.
I call Console.Clear() at first line each time Run project
I came here looking for the solution as I couldn't figure it out for the life of me, tried 'cmd + k' and it worked.
I could have sworn I'd tried it in the past with no success.
Maybe a few points that will help:
Have the terminal selected.
The terminal line has to empty.
New to coding, first stack overflow comment, hope this has some value.
Have a look at the picture. No matter where i put console.writeline, nothing is showing in output. Where could be a mistake? Is something wrong with my output editor or what?
Use Debug.WriteLine to write to the Output window as you want.
See also What's the difference between Console.WriteLine() vs Debug.WriteLine()?
So you have 2 questions instead of one: your main one and the comment "How can i display console window instead of Output window?"
You can write to VS output by using Debug.WriteLine. This requires System.Diagnostics namespace.
You can also run console window alongside with your windows application. Right click the project in Solution Explorer, select Properties, change Output Type to "Console Application" like this.
How do you print or output text in Monogame?
I googled how to display text in monogame and was led to this:
Debug.WriteLine
Which says: "By default, the output is written to an instance of DefaultTraceListener."(and that page just confused me more).
So, if someone could direct me to a method of displaying DefaultTraceListener, or another method of outputting text in monogame, I would appreciate it.
I found it!
Using Debug.WriteLine writes to the debugger, which is in the output window in Visual Studio(by default at the bottom). It appears when you close the program(press F5 to start, Esc to close) by default in an OpenGL project.
If you like, you can use Console.WriteLine like you would in a normal C# console application, assuming you're developing a desktop application. There are a couple of steps.
Open the Properties for your MonoGame project
Select the Application tab
Change the Output Type to Console Application.
Your application should run as normal, only a console window should appear when you start the game.
Alternatively, you can use Debug.WriteLine, which will write to the output window in Visual Studio (it should appear when you start debugging your game).
If you use the standard Debug.WriteLine or Trace.WriteLine, then output goes to the default trace listener which can be viewed in the Visual Studio output window. Outside of Visual Studio, you can use programs such as DebugView (SysInternals) or LogFusion (Binary Fortress) to display the output. DebugView even has a feature for viewing debug output from a remote machine.
There are other trace listeners that can send output to a file, or to the Windows event log, or you can write your own trace listeners fairly easily.
You could also consider using a ready-made logging framework such as NLog, which would give you a great deal of flexibility. I have found in practice that using NLog turns out to be a lot easier than the built in stuff in .NET, because of the way it lets you easily reconfigure things and control/filter the output in a much more flexible way.
I know this has been answered, but if anyone else stumbles upon this, you can also use Console.Write(thing in here); or Console.WriteLine(thing in here); to write to the console window. WriteLine adds a line ending and Write does not.
When stepping through my C# code line by line via F10, it takes the debugger over one second to get to the next line.
I've tried deleting all watches and breakpoints, but that did not make any difference.
Is this normal? It's been like this for quite a long time now, so I can't even remember if this was ever better. My development computer is a Quad-core machine with no background task activity and plenty of RAM left.
If it's not normal, what else could I try? It's still ok to work with, but a less sluggish user interface would be great...
What's likely happening is you have a variable in the call stack frame which has an expensive .ToString method. In 2008, the data for the call stack window is rebuilt on every step regardless of whether or not the window is actually visible. Part of building this window will call .ToString on the values which appear in the parameter list if they have an overridden .ToString. Try disabling implicit .ToString calls and see if that fixes the problem.
Tools -> Options -> Debugger
Uncheck the "Enable Implicit .ToString calls"
I have found that if you have the option to debug unmanaged code turned on, the debugger can take a while to step between lines even if you are only debugging managed code. Try turning that option off (Project > Properties > Debug > Enable Debuggers > Enable unmanaged code debugging).
I tried all of the above. Unchecking 'Show Threads In Source' button fixed it.
In my case, disabling "break all processes when one process breaks" (Tools/Options/Debugger) reduced the time to "step over" from 2-3 seconds to a fraction of a second.
I have no idea why this option had such a big effect on doing a single step over.
BTW, I suppose that disabling this option might cause trouble if you are using threads that are not independent from each other.
I once experienced slow debugging as I had set up VS to look for pdb files on a network share that didn't exist any more.
Check here : Tools - options - Debugging - Symbols - Symbol file (.pdb) Locations
I've heard of this kind of problem if the "Auto" window is open. Try closing that and see if your performance improves.
If you haven't already, you should probably also install the "Visual Studio 2008 SP1 debugging and breakpoint" patch. Note that this patch goes on top of SP1. The docs for the patch don't specifically address the slowness that you're seeing, but it's a pretty large patch, and you might get lucky.
Turn off the Enable address-level debugging option in Tools > Options > Debugging > General.
It made a huge difference for me.
Do you have a lot of Watch expressions set up ? They will be evaluated after between each step, and if they take time to run, you will notice it as a delay when stepping.
I was experiencing a 10 second delay after stopping C# debugging before being able to start C# debugging again. VS2008 would hang during this time with nothing clickable. There is now a 0 second delay after I disabled the Visual Studio hosting process in Project Properties -> Debug.