How can I set Visual Studio to provide a similar level of debugging output to Aptana Studio 3?
I am using Visual Studio 2010, C# 4.0, and Windows Phone 7.1.
I am looking to have it output all of the debug information to the console automatically without me having to tell it to - like Aptana.
If you want to see variable values while debugging the application you can use "Quick Watch", "Add Watch" or Autos.
In Visual Studio 2010, the Autos Window displays variables on the current line and one line above and below.
Look at here for more debugging window help.
You can set the debug output in your code with Console.WriteLine or Debug.Writeline.
If you intend instead of build output, you can change verbosity by Tools > Options > Project and Solutions > Build and Run and change values of "MSBuild project build output verbosity"
Make sure you have the Output window showing, go to View -> Output. If this doesn't cover what you want then edit your question and mention the exact debugging info you are after - VS pretty much has it all, just not necessarily shown by default.
Related
As the title suggests, I'm getting no outup in VS2015 from a line such as :
System.Diagnostics.Debug.WriteLine("***************************************Terst output");
I've checked my Output window is set to display this (debug category).
I've had a many a google. Is there any obvious setting I may be missing? Thanks in advance for your input!
Make sure you press F5 to Start Debugging mode (not ctrl+F5).
F5 Starting Debugging
ctrl+F5 Starting Without Debugging
Ensure you have added the correct references. (Add references -> System, System.dll).
Check release config (make sure build type is Debug).
Ensure you are not building a Portable Class Libraries or ".NET for Metro style apps".
See related answers:
Missing reference
Why does System.Diagnostics.Debug.WriteLine not work in VS2010 C#
I've created a .NET 4.5 console application (an .exe file) with c# that processes some data in various files. The whole thing runs in less than one second. I have a problem with a testing version of the .exe that I'd like to step through in the Visual Studio 2013 debugger using particular input files (the filenames are passed as command line arguments). I can't do an "Attach to process..." since the process has completed too quickly to attach to it. How do I debug in this case.
Note that I'm from the python world, and the python equivalent of what I'm trying to do is python -m pdb pdb_script.py.
Thanks for any advice!
Right click on your project and go to "properties".
Then select the "debugging" tab on the left-hand side.
There's a box where you can input the desired command line arguments for use when running in debug mode.
EDIT: If you're asking how to start the debugger, then add some breakpoints to your code, then right click on the project in your solution and pick Debug > Start New Instance.
Alternatively you can right click and choose "Set as Startup Project", after which you can start debugging with F5 or the "Start" button at the top of the UI.
Add the following line in your code:
System.Diagnostics.Debugger.Break();
This will allow you to debug your application before it ends.
In Visual Studio, you can add commandline arguments before starting a debugging session by right-clicking your project, selecting properties and then going down to the debug tab.
Then you can start it in Visual Studio with f5
If that's too much trouble (because you are going to change the arguments a lot), you could do something like adding a Console.ReadLine to your program at the beginning that will give you a change to attach a debugger. You could even have an extra command line argument for debugging that will only pause for you to attach the debugger if you pass that argument.
Is there a way to see what the CSC (or VBC) parameters are, when building an application using the Visual Studio?
Visual Studio calls CSC.exe/VBC.exe behind the scenes. I want to know if there is a way to see that call.
I need this info to replicate the equivalent Build script using the command line.
I set the different levels of verbosity for the build, still I do not see any CSC.EXE call in the output window.
I'm really surprised why Microsoft did not put an easy way to see the underlying CSC command.
AJ if I go through your steps I get:
I do not see any reference to CSC
OK here is how I resolved this:
First I went to tools and options and set the verbosity to detail. (After this point still build output was empty).
Then I got Service pack for VS2010.
I also had similar issue for Visual Studio 2012 I had to get "update 4" to see the logs and CSC.EXE ion the output.
I think what you're looking for can be set up in your VS environment options. Under the Tools menu, select "Options," then "Projects and Solutions." Make sure "Show Output window when build starts" is checked.
Then, under "Projects and Solutions," select "Build and Run" and change the level of "MSBuild project build output verbosity." I changed it to "Detailed" as an experiment, but you can fiddle with the levels to get what you want.
Then, when you build/rebuild your solution, the easiest thing to do is to place your cursor in the build output window and search for "csc" (or "vbc" for VB). You should be able to see the entire command line call to the compiler.
EDIT
To answer your comment, change the "Show output from" drop-down option at the top of the output window from "Debug" to "Build" and do a build/rebuild without running the application in debug mode.
I have a C# project in Visual Studio 2010 and I wish to run/debug my application with a specific environment variable in place.
This strikes me as a feature that probably exists somewhere, but I can't find it despite some extensive searching. This question relates to 2008 and below and doesn't contain an answer that helps me. This question relates to the build process, not the act of debugging/running.
I appreciate a work-around would be to start my IDE with the environment variables in place, but I'd rather control this from the IDE. Is this possible?
It's not as clean as setting it from outside the application being debugged, but you can add to the Main something like this (NB I'm a VB programmer):
#if (DEBUG)
Environment.SetEnvironmentVariable("YourVar", "YourVal");
#endif
This is possible in the C++ IDE, not the C# IDE. I'd guess it was omitted intentionally because C# has better ways to configure a program. Environment variables are awkward since they require an installer that tinkers with the user's system environment when the app is deployed. That's brittle, another installer can easily destroy that and they often do.
The C# way is to use an application setting. Project + Properties, Settings tab.
A possible alternative is to use a command line argument. You'll get it in your Main() method, you specify a value in the Project + Properties, Debug tab.
You can still get what you want with a trick that takes using the C++ IDE to start your program:
Add a new project to your solution and select the Visual C++, General, Makefile project template.
Click Finish right away, the wizard asks too many questions.
Right-click the added project, Properties, select the NMake node.
Edit the "Build Command Line" setting, and set it to "echo Done".
Edit the "Output" setting, set it to the full path of your C# executable.
Select the Debugging node, change the Debugger type to Managed Only.
And you'll see the one below that, what you want, edit the "Environment" setting.
Right-click the project again, pick "Set as Startup Project".
For C# debugging with environment variables under Visual Studio 2013, what I do is open up the "Developer Command Prompt for VS2013" in the start menu under Visual Studio. From the command prompt I set the environment vars that I want and then run "devenv.exe" to launch Studio. Next open a solution and start debugging.
Keep in mind that if you want to change your environment vars you will need to stop debugging, quit visual studio and then tweak the vars in that open command prompt, then start again. Remember that an environment moves forward as a process (CMD.EXE) launches the next (DEVENV.EXE) and then the next (YourApp). Changes at the very beginning aren't moved forward, you need to start the chain over.
I'm a visual studio newbie, currently developing a game using VS 2010 express, C# and XNA 4.0 .
I'm trying to debug a little game I'm developing, using a Console.WriteLine call when a certain event occur. Unfortunately when I execute the program the visual studio layout changes and the output panel disappear until the program exits (so I can analyze the output only after the program ends).
I would like to know if it possible and how, to keep the output panel visible.
Whilst in Debug mode, simply show it again by going to View->Output
2 things:
I output my debug stuff in xna4.0 with
System.Diagnostic.Debug.WriteLine("stuff");
To view output just go to View -> Output or Alt+2
If you found this question through a search and you do not see the Output Window under the "View" menu, it is most likely because you are viewing Visual C# 2010 under 'Basic Settings.' Under basic settings, you can find the output menu as follows:
Debug -> Windows -> Output
If you want to get out of basic settings, you can change as well:
Tools > Settings > Expert Settings
And then you will be able to access the Output Window as described in the other answers.