Dela via


Debugging Preparation: Console Projects

This topic applies to:

Edition

Visual Basic

C#

C++

Web Developer

Express

Topic applies Topic applies Topic applies Topic does not apply

Standard

Topic applies

Topic applies

Topic applies

Topic does not apply

Pro and Team

Topic applies

Topic applies

Topic applies

Topic does not apply

Table legend:

Topic applies

Applies

Topic does not apply

Does not apply

Topic applies but command hidden by default

Command or commands hidden by default.

Preparing to debug a Console project is similar to preparing to debug a Windows project, with some 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

  • C++ Console Application (.NET)

  • C++ Console Application (Win32)

You might have 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# Debug Configurations.

Like all project properties, these arguments persist between debug sessions and between Visual Studio sessions. Therefore, if the console application is one that you have debugged previously, remember that there might 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 instead of the [Debug] object. To write to the Visual Studio Output window, use the [Debug] object, as usual. Be sure that 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 you debug 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 to move the Visual Studio window.

See Also

Concepts

Debugger Security

Reference

Project Settings for a C++ Debug Configuration

Other Resources

Debugging Native Code

Debugging Managed Code

Debugging Preparation: Visual C++ Project Types

Debugging Preparation: C# and Visual Basic Project Types