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.
Related
I'm starting to use Xamarin Studio, and migrating from VS to it, but when I try to run a console application (the unique one loaded at the moment), fails and throws an exception in Console.Clear() (Supposing I can't do that in an integrated debugger), then i thought that one way to solve it was by compiling it and running it, like Visual Studio does, and Debug the application outside the IDE, but I can't figure out how. Could someone tell me how to solve this problem? Thanks.
EDIT: For any reason, it runs in the embedded window when selecting Release, but it can't read input, so it gets stuck.
You need to set the project option to have it run your console app in an external console:
Visual Studio For Mac:
Project Options / Run / Configurations / Default / Run on external console
Xamarin Studio:
Project Options / Run / General / Run on external console
You can fix this by running your program in a separate console window. It’s easy to do, although you need to follow the steps closely.
The first step is to bring up the project’s options window. You do this by finding your ‘Solution’ panel (normally on the left side of the Visual Studio window), and within that panel you much right-click on the project (this is pointed to by the “1” arrow in the below picture). Once that context menu appears you need to click on “Options”, which may be very close to the bottom)
Once the Project Options window appears, you should click on Run Configurations Default (next to the ‘1’ arrow, below), and then check off Run On External Console (next to the ‘2’ arrow, below)
Once that’s done you’ll need to click the ‘Ok’ button.
Everything should work fine at this point, but it’s always good to double-check: try running a program that asks you to type something and verify that it’s working correctly.
I'm starting to use Xamarin Studio, and migrating from VS to it, but when I try to run a console application (the unique one loaded at the moment), fails and throws an exception in Console.Clear() (Supposing I can't do that in an integrated debugger), then i thought that one way to solve it was by compiling it and running it, like Visual Studio does, and Debug the application outside the IDE, but I can't figure out how. Could someone tell me how to solve this problem? Thanks.
EDIT: For any reason, it runs in the embedded window when selecting Release, but it can't read input, so it gets stuck.
You need to set the project option to have it run your console app in an external console:
Visual Studio For Mac:
Project Options / Run / Configurations / Default / Run on external console
Xamarin Studio:
Project Options / Run / General / Run on external console
You can fix this by running your program in a separate console window. It’s easy to do, although you need to follow the steps closely.
The first step is to bring up the project’s options window. You do this by finding your ‘Solution’ panel (normally on the left side of the Visual Studio window), and within that panel you much right-click on the project (this is pointed to by the “1” arrow in the below picture). Once that context menu appears you need to click on “Options”, which may be very close to the bottom)
Once the Project Options window appears, you should click on Run Configurations Default (next to the ‘1’ arrow, below), and then check off Run On External Console (next to the ‘2’ arrow, below)
Once that’s done you’ll need to click the ‘Ok’ button.
Everything should work fine at this point, but it’s always good to double-check: try running a program that asks you to type something and verify that it’s working correctly.
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.
I recently started experimenting with Xamarin and Mono C# on my Mac. I am used to working on Windows with Visual Studio so I find it cumbersome when every time I run my console application, a new terminal window and mono compiler terminal open up. And I have to manually close them. Is there anyway to get the output of my programs from a window or pane inside the IDE ? Or is there anyway to set it up so only one terminal window shows up ?
If you open the Project Options there is a Run on external console check box in the Run - General category which controls this behaviour. If you uncheck this option when you run a console application the output will be shown in an Application Output window inside Xamarin Studio and no external console window will be opened.
For anyone else arriving at this question who can't locate 'Project Options', the item is found in a drop down menu under the Project Tab (located at the top of the screen on the app's main nav bar). When a solution/file is loaded, the item is listed with your project's actual name, ex: 'MyProject Options' or 'MyProject&Options' (–it does not literally read 'Project Options').
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.