Compartilhar via


Debugging Preparation: Console Projects 

Preparing to debug a Console project is similar to preparing to debug a Windows project, with a few additional considerations. For more information, see Debugging Preparation: Windows Forms Applications, andDebugging Preparation: Windows Forms Applications (.NET). Because of the similarity of all console applications, this topic covers the following project types:

  • C# Console Application

  • Visual Basic Console Application

  • J# Console Application

  • C++ Console Application (.NET)

  • C++ Console Application (Win32)

You may need to specify command-line arguments for your console application. For more information, see Project Settings for a C++ Debug Configuration, Project Settings for a Visual Basic Debug Configuration, or Project Settings for C# and J# Debug Configurations.

Like all project properties, these arguments persist between debug sessions and between Visual Studio sessions. So, if the console application is one you have debugged previously, remember that there may be arguments from previous sessions entered in the <Project> Property Pages dialog box.

A console application uses the Console window to accept input and to display output messages. To write to the Console window, your application must use the Console object rather than the Debug object. To write to the Visual Studio Output window, use the Debug object as usual. Be sure you know where your application is writing or you might be looking for messages in the wrong place. For more information, see Console Class, Debug Class, and Output Window.

When debugging a console application, you might want to start the application from the command prompt rather than from Visual Studio. In that case, you can start the application from the command prompt and attach the Visual Studio debugger to it. For more information, see Attaching to Running Processes.

When you start a console application from Visual Studio, the Console window sometimes appears behind the Visual Studio window. If you try to start your console application from Visual Studio and nothing seems to happen, try moving the Visual Studio window.

See Also

Reference

Project Settings for a C++ Debug Configuration

Concepts

Debugger Security

Other Resources

Debugging Native Code
Debugging Managed Code
Debugging Preparation: Visual C++ Project Types
Debugging Preparation: C#, J#, and Visual Basic Project Types