100% found this document useful (1 vote)
543 views

Visual Studio Manual

Visual studio manual with examples

Uploaded by

exeri0n
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
543 views

Visual Studio Manual

Visual studio manual with examples

Uploaded by

exeri0n
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1028

Contents

Visual Studio IDE


Visual Studio IDE
Optimize Visual Studio Startup Time
Move Around in the IDE
Finding and Using Visual Studio Extensions
Get Started Developing with Visual Studio
Get Started Developing with Visual Studio
Getting Started with Visual C# and Visual Basic
Getting Started with Visual C# and Visual Basic
Create a Simple Application
Tutorial 1 - Create a Picture Viewer
Tutorial 1 - Create a Picture Viewer
Step 1 - Create a Windows Forms Application Project
Step 2 - Run Your Program
Step 3 - Set Your Form Properties
Step 4 - Lay Out Your Form with a TableLayoutPanel Control
Step 5 - Add Controls to Your Form
Step 6 - Name Your Button Controls
Step 7 - Add Dialog Components to Your Form
Step 8 - Write Code for the Show a Picture Button Event Handler
Step 9 - Review, Comment, and Test Your Code
Step 10 - Write Code for Additional Buttons and a Check Box
Step 11 - Run Your Program and Try Other Features
Tutorial 2 - Create a Timed Math Quiz
Tutorial 2 - Create a Timed Math Quiz
Step 1 - Create a Project and Add Labels to Your Form
Step 2 - Create a Random Addition Problem
Step 3 - Add a Countdown Timer
Step 4 - Add the CheckTheAnswer() Method
Step 5 - Add Enter Event Handlers for the NumericUpDown Controls
Step 6 - Add a Subtraction Problem
Step 7 - Add Multiplication and Division Problems
Step 8 - Customize the Quiz
Tutorial 3 - Create a Matching Game
Tutorial 3 - Create a Matching Game
Step 1 - Create a Project and Add a Table to Your Form
Step 2 - Add a Random Object and a List of Icons
Step 3 - Assign a Random Icon to Each Label
Step 4 - Add a Click Event Handler to Each Label
Step 5 - Add Label References
Step 6 - Add a Timer
Step 7 - Keep Pairs Visible
Step 8 - Add a Method to Verify Whether the Player Won
Step 9 - Try Other Features
Getting Started with C++
Getting Started with Debugging in Visual Studio 2015
Solutions and Projects
Creating Solutions and Projects
Adding and Removing Project Items
Managing Project and Solution Properties
Managing references in a project
Managing references in a project
Add or Remove References By Using the Reference Manager
Adding References Using NuGet Versus an Extension SDK
Add or Remove Imported Namespaces (Visual Basic)
Troubleshooting Broken References
Application Properties
Managing Application Resources (.NET)
Managing Application Settings (.NET)
Managing Assembly and Manifest Signing
Managing Assembly and Manifest Signing
Sign Application and Deployment Manifests
Specify an Application Icon (Visual Basic, C#)
Targeting a Specific .NET Framework Version
Targeting a Specific .NET Framework Version
Visual Studio Multi-Targeting Overview
Target a Version of the .NET Framework
Creating Project and Item Templates
Creating Project and Item Templates
Create Project Templates
Create Multi-Project Templates
Create Item Templates
Create Multi-file Item Templates
Manually Create Web Templates
Create Starter Kits
Locate and Organize Templates
Customizing Templates
Customizing Templates
Update Existing Templates
Substitute Parameters in a Template
Troubleshoot Templates
Visual Studio Template Reference
Visual Studio Template Reference
Template Parameters
Writing Code
Writing Code
Finding and Replacing Text
Finding and Replacing Text
Using Regular Expressions in Visual Studio
Find/Command Box
Find in Files
Replace in Files
Encodings and Line Breaks
Outlining
Refactoring
Productivity Tips
Productivity Tips
Tips and Tricks
Identifying and Customizing Keyboard Shortcuts
Identifying and Customizing Keyboard Shortcuts
Default Keyboard Shortcuts for Frequently Used Commands
Default Keyboard Shortcuts
Using IntelliSense
Using IntelliSense
Visual Basic-Specific IntelliSense
Visual Basic-Specific IntelliSense
Filtered Completion Lists in Visual Basic
Visual C# IntelliSense
Test-First Support with the Generate From Usage Feature
JavaScript IntelliSense
JavaScript IntelliSense
Create JSDoc Comments
Create XML Documentation Comments
Extending JavaScript IntelliSense
Statement Completion for Identifiers
Customizing IntelliSense for RequireJS
XML Documentation Comments
XML Documentation Comments
\<deprecated>
\<field>
\<loc>
\<param>
\<returns>
\<signature>
\<summary>
\<value>
\<var>
Visual C++ Intellisense
Supplying XML Code Comments
Customizing the Editor
Customizing the Editor
Change Text Case in the Editor
Manage Editor Modes
Manage Editor Windows
Track Your Code by Customizing the Scrollbar
View and Edit Code by Using Peek Definition (Alt+F12)
Perform quick actions with light bulbs
Code Snippets
Code Snippets
Creating a Code Snippet
Distribute Code Snippets
Visual C# Code Snippets
Visual C++ Code Snippets
Code Snippet Functions
Restore C# Refactoring Snippets
Use Surround-with Code Snippets
Best Practices for Using Code Snippets
Troubleshooting Snippets
Code Snippets Schema Reference
Using the Toolbox
Viewing the Structure of Code
Viewing the Structure of Code
Class View and Object Browser Icons
Designing and Viewing Classes and Types
Designing and Viewing Classes and Types
Working with Classes and Other Types (Class Designer)
Working with Classes and Other Types (Class Designer)
Working with Class Diagrams (Class Designer)
Designing Classes and Types (Class Designer)
Viewing Types and Relationships (Class Designer)
Refactoring Classes and Types (Class Designer)
Working with Visual C++ Code (Class Designer)
Additional Information About Class Designer Errors
Setting Bookmarks in Code
Using the Task List
Find code changes and other history
Find code changes and other history
CodeIndex Command
Using the Visual Studio Development Environment for C#
Using the Visual Studio Development Environment for C#
Add an Application Configuration File to a C# Project
Metadata as Source
Refactoring (C#)
Refactoring (C#)
Extract Method Refactoring (C#)
Rename Refactoring (C#)
Encapsulate Field Refactoring (C#)
Extract Interface Refactoring (C#)
Remove Parameters Refactoring (C#)
Reorder Parameters Refactoring (C#)
Debugging in Visual Studio
Profiling
Improve Code Quality
Designing User Interfaces
Analyzing and Modeling Architecture
Compiling and Building
Compiling and Building
Building an Application
Building and Cleaning Projects and Solutions in Visual Studio
Building and Cleaning Projects and Solutions in Visual Studio
Change the Build Output Directory
Build to a Common Output Directory
Specifying Custom Build Events in Visual Studio
Set Multiple Startup Projects
Create and Remove Project Dependencies
View, Save, and Configure Build Log Files
Exclude Projects from a Build
Suppress Compiler Warnings
Understanding Build Configurations
Understanding Build Configurations
Create and Edit Configurations
Manage Configurations with Visual Basic Developer Settings Applied
Build Multiple Configurations Simultaneously
Understanding Build Platforms
Understanding Build Platforms
Configure Projects to Target Platforms
Configure Projects to Target Multiple Platforms
Specify Build Events (Visual Basic)
Specify Build Events (C#)
Configuring Warnings in Visual Basic
Disable the Hosting Process
Disable the Hosting Process
Hosting Process (vshost.exe)
Creating a Multiple-Computer Build Environment
Deploying Applications, Services, and Components
Visual Studio IDE 64-Bit Support
Visual Studio Samples
User Accounts and Updates
User Accounts and Updates
Signing in to Visual Studio
Work with multiple user accounts
How to Unlock Visual Studio
Notifications
Personalizing the IDE
Personalizing the IDE
Change Fonts and Colors
Customize Menus and Toolbars
Customizing window layouts
Customizing the Start Page
Managing External Tools
Synchronized Settings
Security
Security
Securing Applications
Maintaining Security
User Permissions
Security Bibliography
Visual Studio Samples
Microsoft Help Viewer
Microsoft Help Viewer
Microsoft Help Viewer Installation
Help Viewer Administrator Guide
Help Viewer Administrator Guide
Command-Line Arguments for the Help Content Manager
Help Content Manager Overrides
Install and Manage Local Content
Locate Information
Locate Information
Find Topics in the Index
Find Topics in the Index
Index Search Tips
Find Topics in the Table of Contents
Search for Topics
Search for Topics
Full-Text Search Tips
Logical Operators in Search Expressions
Advanced Search Operators in Search Expressions
Customize Search Results
Manage the Help Viewer Window
Retain Topics for Later Use
Customize the Help Viewer
Troubleshooting the Help Viewer
Accessibility Features of the Help Viewer
Accessibility Features of the Help Viewer
Shortcut Keys (Help Viewer)
Globalizing and Localizing Applications
Globalizing and Localizing Applications
Introduction to International Applications Based on the .NET Framework
Localizing Applications
Localizing Applications
Hierarchical Organization of Resources for Localization
Security and Localized Satellite Assemblies
Version Numbers for Main and Localized Satellite Assemblies
Neutral Resources Languages for Localization
Globalizing Applications
Globalizing Applications
Culture-Specific Classes for Global Windows Forms and Web Forms
Creating Applications in Bi-directional Languages
Creating Applications in Bi-directional Languages
Save and Open Files with Encoding
Adding Visual Studio editor support for other languages
Reference
General User Interface Elements (Visual Studio)
General User Interface Elements (Visual Studio)
Call Hierarchy
Choose Toolbox Items, WPF Components
Code Snippet Picker
Command Window
Convert Dialog Box
Error List Window
File Properties, JavaScript
Go To Line
Immediate Window
Miscellaneous Files
Options Dialog Box
Environment Options Dialog Box
Environment Options Dialog Box
General, Environment, Options Dialog Box
AutoRecover, Environment, Options Dialog Box
Documents, Environment, Options Dialog Box
Extensions and Updates, Environment, Options Dialog Box
Find and Replace, Environment, Options Dialog Box
Fonts and Colors, Environment, Options Dialog Box
Import and Export Settings, Environment, Options Dialog Box
International Settings, Environment, Options Dialog Box
Keyboard, Environment, Options Dialog Box
Notifications, Environment, Options Dialog Box
Quick Launch, Environment, Options Dialog Box
Startup, Environment, Options Dialog Box
Synchronized Settings, Environment, Options Dialog Box
Tabs and Windows, Environment, Options Dialog Box
Task List, Environment, Options Dialog Box
Web Browser, Environment, Options Dialog Box
Options Page, Environment Node Properties
Text Editor Options Dialog Box
Text Editor Options Dialog Box
Change Fonts and Colors in the Editor
Manage Word Wrap in the Editor
Display Line Numbers in the Editor
Display URLs as Links in the Editor
Setting Language-Specific Editor Options
Options, Text Editor, General
Options, Text Editor, File Extension
Options, Text Editor, All Languages
Options, Text Editor, All Languages, Tabs
Options, Text Editor, Basic (Visual Basic)
Options, Text Editor, C/C++, Formatting
Options, Text Editor, C/C++, Advanced
Options, Text Editor, C/C++, Experimental
Options, Text Editor, C#, Formatting
Options, Text Editor, C#, Advanced
Options, Text Editor, C#, IntelliSense
Options, Text Editor, JavaScript, Formatting
Options, Text Editor, JavaScript, IntelliSense
Options, Text Editor, XAML, Formatting
Options Page, Fonts and Colors Node Properties
Options Page, Text Editor Node Properties
Options Page, Debugging Node Properties
Output Window
Project Properties Reference
Project Properties Reference
Application Page, Project Designer (Visual Basic)
Application Page, Project Designer (Visual Basic)
Assembly Information Dialog Box
Application Page, Project Designer (C#)
Build Events Page, Project Designer (C#)
Build Events Page, Project Designer (C#)
Pre-build Event/Post-build Event Command Line Dialog Box
Build Page, Project Designer (C#)
Build Page, Project Designer (C#)
Advanced Build Settings Dialog Box (C#)
Code Analysis, Project Designer
Compile Page, Project Designer (Visual Basic)
Compile Page, Project Designer (Visual Basic)
Advanced Compiler Settings Dialog Box (Visual Basic)
Build Events Dialog Box (Visual Basic)
Debug Page, Project Designer
My Extensions Page, Project Designer
Publish Page, Project Designer
Publish Page, Project Designer
Prerequisites Dialog Box
References Page, Project Designer (Visual Basic)
Security Page, Project Designer
Security Page, Project Designer
Advanced Security Settings Dialog Box
Services Page, Project Designer
Services Page, Project Designer
Advanced Settings for Services Dialog Box
Signing Page, Project Designer
Visual Basic Defaults, Projects, Options Dialog Box
VC++ Project Settings, Projects and Solutions, Options Dialog Box
Project and Solution File Types
Projects and Solutions, Options Dialog Box
Projects and Solutions, Options Dialog Box
Options Dialog Box, Projects and Solutions, Build and Run
Options Dialog Box, Projects and Solutions, Web Projects
Property Pages, JavaScript
Properties Window
Toolbox
Toolbox
Toolbox, Components Tab
Toolbox, Data Tab
Toolbox, HTML Tab
Devenv Command Line Switches
Devenv Command Line Switches
/?
/Build
/Clean
/Command
/DebugExe
/Deploy
/Diff
/Edit
/LCID
/Log
/Out
/Project
/ProjectConfig
/Rebuild
/ResetAddin
/InstallVSTemplates
/ResetSettings
/ResetSkipPkgs
/Run
/Runexit
/SafeMode
/Setup
/Updateconfiguration
/Upgrade
/UseEnv
Visual Studio Commands
Visual Studio Commands
Visual Studio Command Aliases
Add Existing Item Command
Add Existing Project Command
Add New Item Command
Alias Command
Evaluate Statement Command
Find Command
Find in Files Command
Go To Command
Import and Export Settings Command
List Call Stack Command
List Disassembly Command
List Memory Command
List Modules Command
List Registers Command
List Source Command
List Threads Command
Log Command Window Output Command
New File Command
Open File Command
Open Project Command
Open Solution Command
Print Command
Quick Watch Command
Replace Command
Replace In Files Command
Set Current Process
Set Current Stack Frame Command
Set Current Thread Command
Set Radix Command
Shell Command
ShowWebBrowser Command
Start Command
Symbol Path Command
Toggle Breakpoint Command
Watch Command
XML Tools
Visual Studio for Applications Reference
MSBuild
Resources for Troubleshooting IDE Errors
Accessibility for People with Disabilities
Accessibility for People with Disabilities
Accessibility Features of Visual Studio
Accessibility Features of Visual Studio
Set IDE Accessibility Options
Use the Keyboard Exclusively
Accessibility Tips and Tricks
Accessibility Products and Services from Microsoft
Resources for Designing Accessible Applications
Proxy Authorization Required
Visual Studio IDE
10/16/2020 • 16 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Microsoft Visual Studio 2015 is a suite of tools for creating software, from the planning phase through UI design,
coding, testing, debugging, analyzing code quality and performance, deploying to customers, and gathering
telemetry on usage. These tools are designed to work together as seamlessly as possible, and are all exposed
through the Visual Studio Integrated Development Environment (IDE).
You can use Visual Studio to create many kinds of applications, from simple store apps and games for mobile
clients, to large, complex systems that power enterprises and data centers. You can create:
Apps and games that run not only on Windows, but also Android and iOS.
Websites and web services based on ASP.NET, JQuery, AngularJS, and other popular frameworks.
Applications for platforms and devices as diverse as Azure, Office, Sharepoint, Hololens, Kinect, and Internet
of Things, to name just a few examples.
Games and graphics-intensive applications for a variety of Windows devices, including Xbox, using DirectX.
Visual Studio by default provides support for C#, C and C++, JavaScript, F#, and Visual Basic. Visual Studio works
and integrates well with third-party applications like Unity through the Visual Studio Tools for Unity extension and
Apache Cordova through Visual Studio Tools for Apache Cordova. You can extend Visual Studio yourself by
creating custom tools that perform specialized tasks.
If you’ve never used Visual Studio before, learn the basics with our Get Started Developing with Visual Studio
tutorials and walkthroughs.
If you want to find out about new features in Visual Studio 2015, see What's New in Visual Studio 2015.

Visual Studio Setup


You can find out which edition of Visual Studio is right for you at Visual Studio Editions.
You can install Visual Studio 2015 by downloading it from Visual Studio Downloads. If you need to know more
about the installation process, see Installing Visual Studio 2015.

IDE Basics
The following image shows the Visual Studio IDE with an open project, and the Solution Explorer window for
navigating in the project files, and the Team Explorer window for navigating source control and work item
tracking. The features in the title bar that are called out are explained below in more detail.
Signing in
When you start Visual Studio for the first time, you can sign in using your Microsoft account, or your work or
school account. Being signed in allows you to synchronize your settings, such as window layouts, across multiple
devices and connect automatically to the services you might need, such as Azure subscriptions and Visual Studio
Team Services. If you have a subscription-based license, you'll need to sign in to Visual Studio on a regular basis in
order to keep your license token fresh. If you have a product key license, you don't have to sign in, but doing so
makes it more convenient to connect to Visual Studio Team Services and your accounts with Azure, Office 365,
Salesforce.com. For more information, see Signing in to Visual Studio.
If you have multiple Visual Studio Team Services accounts, Azure accounts or MSDN subscriptions, you can link
them and access resources and services in all your accounts with a single sign-in. For more information, see Work
with multiple user accounts.
Staying up to date
The notification icon in the upper right of the title bar tells you when updates are available for Visual Studio or any
related components that you have installed. You can choose whether to dismiss or act on these notifications. For
more information, see Visual Studio Notifications.
Finding things and getting help
The Quick Launch window shown below is a fast way to find Visual Studio commands, tools, features, and so on
when you don't know the keyboard shortcut or menu location. Just type what you are looking for and Quick
Launch will give you a link to it.
MSDN is the Microsoft web site for technical documentation; you are reading this page on MSDN right now! In
Visual Studio, you can press F1 to go to the MSDN help page for the active window. You can also press F1 in the
code editor to go to the MSDN help page for the API or keyword at the current caret position. For example, in a C#
file, place the caret somewhere in or just at the end of a System.String declaration, and press F1 to go to the
MSDN help page for String.
Giving feedback
It's easy to give us feedback on Visual Studio whenever you like. Click the feedback icon in the title bar next to
QuickLaunch and then click on Repor t a Problem or Provide a Suggestion . Pre-release editions of Visual
Studio also have a Rate this Product option. We look at all these comments and use them to improve the
product. For more information, see Talk to Us.
Personalizing the IDE
You can customize the window layout to fit your development style. You can dock, float or hide any window at any
time, and you also can run the editor in full-screen mode. You can create and save multiple custom window
layouts that show only the windows you need for specific contexts. For example, you can create a full-screen
layout so that all you see is the code editor. And you can create different layouts for debugging and for team
operations. For more information, see Customizing window layouts.
You can customize Visual Studio in many other ways, and roam your settings if you work on multiple machines.
For more information, see Personalizing the IDE.
There are keyboard shortcuts for almost everything, and you can customize them as well. To create new shortcuts,
type "Keyboard" in Quick Launch to open the Keyboard dialog box. From there, you can press F1 to go to the
MSDN help page if you need more information about the options. For more information, see Default Keyboard
Shortcuts in Visual Studio.

Connecting to Visual Studio Team Services and Team Foundation


Server
Visual Studio Team Services (VSTS) is a cloud-based service for hosting software projects and enabling
collaboration in teams. VSTS supports both Git and Team Foundation Source Control systems, as well as Scrum,
CMMI and Agile development methodologies. Team Foundation Version Control (TFVC) uses a single, centralized
server repository to track and version files. Local changes are always checked in to the central server where other
developers can get the latest changes. Team Foundation Server (TFS) 2015 is the application lifecycle management
hub for Visual Studio. It enables everyone involved with the development process to participate using a single
solution. TFS is useful for managing heterogeneous teams and projects, too.
If you have a Visual Studio Team Services account or a Team Foundation Server on your network, you connect to it
through the Team Explorer window. From this window you can check code into or out of source control, manage
work items, start builds, and access team rooms and workspaces. You can open Team Explorer from Quick
Launch or on the main menu from View | Team Explorer or from Team | Manage Connections . For more
information about Visual Studio Team Services, see www.visualstudio.com. For more information about Team
Foundation Server, see Team Foundation Server.
The following image shows the Team Explorer pane for a solution that is hosted in VSTS:

Creating solutions and projects


Although you can use Visual Studio to browse individual code files, more commonly you will be working in a
project. A Visual Studio project is a collection of files and resources that are compiled to a single binary executable
file for applications (for example, an .exe, DLL, or appx). For non-ASP.NET websites, no executable is produced and
the project contains only the HTML, JavaScript files, and images. Because sometimes you might need to create
multiple binaries or websites that are closely related, Visual Studio has the concept of the Solution, which can
contain multiple projects or websites. When you create a project, you are actually creating a project-in-a-solution,
and you can add more projects to that solution later if you need to. For example, if you have a DLL project, you can
add an .exe project to the solution that loads and consumes the DLL.
A project template is a collection of pre-populated code files and configuration settings that get you set up quickly
to create a specific kind of application. Visual Studio comes with many project templates to choose from, and if
none of the default templates work for you, you can create your own. After you create a project with a template,
you can start writing your own code in it, either in the files provided or in new files you add. For more information,
see Solutions and Projects. The following illustration shows the New Project dialog with the project templates that
are available for ASP.NET applications.
Designing the user interface
A designer is an intuitive tool that enables you to create a user interface without writing code. You can drag UI
controls such as list boxes, calendars, and buttons from the Toolbox window onto a design surface that represents
the window or dialog box. You can resize and rearrange the elements without writing any code. Designers are
included for any project type that has a user interface.
If your project has a XAML-based user interface, the default designer is Blend for Visual Studio, a sophisticated
graphics tool that works seamlessly with Visual Studio.

IM A GE DESC RIP T IO N

Design view Displays the visual design of your document. In


this view, you can draw or modify objects on the design
surface.
IM A GE DESC RIP T IO N

Breadcrumb Quickly move between template-editing mode,


style-editing mode, and object-editing scope for a selected
object.

Zoom Use to zoom the design surface or objects on the


design surface.

Design surface controls Use these controls (Show snap


grid , Snap to gridlines and Turn on or off snapping to
snaplines ) to set snapping options. Snapping is useful for
lining objects up to each other or to evenly-spaced lines on
the design surface.

Code editor Edit your XAML, C#, C++ or Visual Basic code
manually in the Code editor.

For more information, see Designing XAML in Visual Studio and Blend for Visual Studio.

Writing, navigating and understanding code


If you are a developer, the editor window is where you will probably spend most of your time. Visual Studio
includes editors for C#, C++, Visual Basic, JavaScript, XML, HTML, CSS, and F#, and third parties offer plug-in
editors (and compilers) for many other languages.
You can edit individual files in the text editor by clicking File | Open | File. To edit files in an open project, click on
the file name in Solution Explorer. The code is colorized, and you can personalize the color scheme by typing
“Colors” in Quick Launch. You can have lots of text editor tabbed windows open at once. You can split each window
independently. You can also run the text editor in full-screen mode.

The text editor is highly interactive (if you want it to be) with many productivity features that help you write better
code faster. The features vary by language, and you don’t have to use any of them (Type "Editor" in Quick Launch)
to turn features on or off: Some of the common productivity features are:
1. Refactoring includes operations such as intelligent renaming of variables, moving selected lines of code
into a separate function, moving code to other locations, redordering function parameters, and more.
2. IntelliSense is an umbrella term for a set of popular features that display type information about your code
directly in the editor and, in some cases, write small bits of code for you. It’s like having basic
documentation inline in the editor, which saves you from having to look up type information in a separate
help window. IntelliSense features vary by language. For more information, see Visual C# IntelliSense,
Visual C++ Intellisense, JavaScript IntelliSense, Visual Basic-Specific IntelliSense. The following illustration
shows some IntelliSense features at work:
3. Squiggles alert you to errors or potential problems in your code in real time as you type, which enables
you to fix them immediately without waiting for the error to be discovered during compilation or run time.
If you hover over the squiggle, you see additional information about the error. A light bulb may also appear
in the left margin with suggestions for how to fix the error. For more information, see Perform quick actions
with light bulbs.

4. Bookmarks enable you to navigate quickly to specific lines in files that you are actively working on.
5. The Call Hierarchy window can be invoked in the text editor context menu to show the methods that call,
and are called by, the method under the caret.
6. Code Lens enables you to find references and changes to your code, linked bugs, work items, code
reviews, and unit tests, all without leaving the editor. For more information, see Find code changes and
other history.
7. The Peek to Definition window shows a method or type definition inline, without navigating away from
your current context. This window now works for XAML, too.
8. The Go To Definition context menu option takes you directly to the place where the function or object is
defined. Other navigation commands are also available by right-clicking in the editor.
9. A related tool, the Object Browser, enables you to inspect .NET or Windows Runtime assemblies on your
system to see what types they contain and what methods and properties those types contain.
Most of the items on the Edit menu and View menu relate to the code editor in some way. For more
information about the editor, see Writing Code and Editing Your Code.

Compiling and building your code


To build a project means to compile the source code and perform whatever steps are necessary to produce the
executable. Different languages have different build operations, and regular websites don't build at all. Regardless
of the project type, the Build menu is the standard location for these commands. To compile and run your code
with a single keystroke, press F5. Every compiler is completely configurable through the IDE. The Build toolbar
enables you to specify whether to build a debug version of your program, with symbols and extra error checking
enabled to support breakpoints and single stepping in the debugger, or a release build, which is what you will
ultimately give to customers. You can configure more build settings and many other settings on the property page
for a project. Right-click on the project node in Solution Explorer and choose Properties. You can also run builds
from the command line.
The output from the build, including an error or success messages, appear in the Output window. The Error List
shows detailed information on build errors.

Debugging your code


Visual Studio’s state-of-the-art debugger enables you to debug code running in your local project, on a remote
device, or on an emulator such as the ones for Android or Windows Phone. You can step through code one
statement at a time and inspect variables as you go, you can step through multi-threaded applications, and you
can set breakpoints that are only hit when a specified condition is true. All of this can be configured in the code
editor itself, so that you don't have to leave the context of your code.

The debugger itself has multiple windows that enable you to view and manipulate local variables, the call stack,
and other aspects of the runtime environment. You can find these windows on the Debug menu.
The Immediate Window enables you to type in an expression and see its result immediately.
The IntelliTrace window records each method call and other events in a running .NET program and can help you to
quickly locate where a problem originates.
For more information, see Debugging in Visual Studio.

Testing your code


Visual Studio includes a unit test framework for managed code (.NET) and one for native C++. To create unit tests,
simply add a Test Project to your solution, write your tests, and then run them from the Test Explorer window. For
more information, see Unit Test Your Code.

Analyzing code quality and performance


Visual Studio includes powerful tools for static and runtime analysis. The static analysis tools help you identify
potential errors in design, globalization, interoperability, performance, security, and other categories. Performance
testing, or profiling, involves measuring how your program runs. You access these tools from the Analyze menu.
For more information, see Improving Quality with Visual Studio Diagnostic Tools.

Connecting to cloud services and databases


The Server Explorer window in Visual Studio shows the resources in all the accounts managed under your
personalization account (the one you logged in with), including SQL Server instances, Azure, Salesforce.com,
Office 365, and websites.

Visual Studio includes Microsoft SQL Server Data Tools (SSDT), which enable you to build, debug, maintain, and
refactor databases. You can work with a database project, or directly with a connected database instance on- or
off-premises.
The SQL Server Object Explorer in Visual Studio offers a view of your database objects similar to SQL Server
Management Studio. SQL Server Object Explorer allows you to do light-duty database administration and design
work, including editing table data, comparing schemas, and executing queries by using contextual menus right
from the SQL Server Object Explorer. SSDT also includes special project types and tools for developing SQL Server
2012 Analysis Services, Reporting Services, and Integration Services Business Intelligence (BI) solutions (formerly
known as Business Intelligence Development Studio).

Deploying your finished application


When your application is ready to deploy to customers, Visual Studio provides the tools to do that, whether you’re
deploying to the Windows Store, to a SharePoint site, or with InstallShield or Windows Installer technologies. It's
all accessible via the IDE. For more information, see Deploying Applications, Services, and Components.

Architecture and modeling tools (Enterprise only)


You can use Visual Studio architecture and modeling tools to design and model your app. These tools help you to
visualize the code's structure, behavior, and relationships. You can create models at different levels of detail
throughout the application lifecycle as part of your development process. You can track requirements, tasks, test
cases, bugs, and other work associated with your models by linking model elements to Team Foundation Server
work items and your development plan. For more information, see Design and model your app.

Extending Visual Studio through the Visual Studio SDK


Visual Studio is an extensible platform. A Visual Studio extension is a custom tool that integrates with the IDE. You
can add third-party extensions or create your own. For more information, see Developing Visual Studio
Extensions.
The Visual Studio User Experience Guidelines are an essential reference for anyone writing extensions for Visual
Studio. These platform-specific guidelines include information on dialog design, fonts, colors, icons, common
controls, and other interaction patterns that will make your new feature integrate seamlessly with Visual Studio.

In this Guide
User Accounts and Updates
Personalizing the IDE
How to: Move Around in the IDE
Get Started Developing with Visual Studio
Finding and Using Visual Studio Extensions
Solutions and Projects
Writing Code
Debugging in Visual Studio
Profiling Tools
Improve Code Quality
Designing User Interfaces
Analyzing and Modeling Architecture
Compiling and Building
Deploying Applications, Services, and Components
Visual Studio IDE 64-Bit Support
Security
Visual Studio Samples
Microsoft Help Viewer
Globalizing and Localizing Applications
UI Reference

See Also
Installing Visual Studio 2015
Editing Your Code
What's New in Visual Studio 2015
Porting, Migrating, and Upgrading Visual Studio Projects
Talk to Us
Optimize Visual Studio Startup Time
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Ideally, Visual Studio should always start up as quickly as possible. However, Visual Studio extensions and open tool
windows can adversely affect startup time because they load automatically at startup. The Manage Visual Studio
Performance window enables you to not only see which extensions and features affect Visual Studio startup time,
but also lets you determine their loading behavior so you have more control over how quickly Visual Studio starts
up.

Control startup behavior


To avoid extending startup time, Visual Studio 2017 and later avoid loading extensions during startup, using an on-
demand-load approach. This means that extensions don't open immediately after Visual Studio starts, but rather
open asynchronously on an as-needed basis after startup. Also, because tool windows left open in a prior Visual
Studio session can slow startup time, Visual Studio opens tool windows in a more intelligent way to avoid
impacting startup time.
If Visual Studio detects slow startup, a pop-up message appears, alerting you to the extension or tool window that's
causing the slowdown. The message also provides a link to the Manage Visual Studio Performance dialog box,
which lists the extensions and tools windows that are affecting startup performance. This dialog box enables you to
change extension and tool window settings to improve startup performance.

The Manage Visual Studio Performance dialog box has two categories: Extensions and Tool Windows .
Control extensions
If an extension is slowing down Visual Studio startup, the extension appears in the Manage Visual Studio
Performance dialog box when you choose one of the extension types. If the impact on startup time (which is
listed under the Impact section) is unacceptably high, you can choose to always disable the extension at startup by
choosing the Disable button. You can re-enable the extension for future sessions by using the Extension Manager
or the Manage Visual Studio Performance dialog box.
In addition to startup extensions, you can also disable extensions that load when solutions load, or when a user
types. Just choose the scenario to see a list of the associated extensions.
Control tool windows
If a tool window is slowing down Visual Studio startup, you can choose to leave it at its default behavior (giving you
no benefit in startup speed), or you can override its behavior by choosing one of two behaviors:
Do not show window at star tup: If you choose this option, the specified tool window will always be closed
when you open Visual Studio, even if left open in a previous session. You can open the tool window from the
menu.
Auto hide window at star tup: If a tool window was left open in a previous session, choosing this option will
collapse the tool window's group at startup to avoid initializing the tool window. This is a good choice if you use
a tool window often, because the tool window is still available, but no longer negatively affects Visual Studio
startup time.

If you later change your mind, you can revert any of these options in the Manage Visual Studio Performance
dialog box. To open the Manage Visual Studio Performance dialog box, on the menu bar, choose Help ,
Manage Visual Studio Performance .
How to: Move Around in the Visual Studio IDE
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The integrated development environment (IDE) has been designed to allow you to move from window to window
and file to file in several different ways, depending on your preference or project requirements. You can choose to
cycle through open files in the editor, or cycle through all active tool windows in the IDE. You also can switch
directly to any file open in the editor, regardless of the order in which it was last accessed. These features can help
increase your productivity when working in the IDE.

NOTE
The options available in dialog boxes, and the names and locations of menu commands you see, might differ from what is
described in Help depending on your active settings or edition. This Help page was written with General Development
Settings in mind. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more
information, see Customizing Development Settings in Visual Studio.

Keyboard Shortcuts
Almost every menu command in Visual Studio has a keyboard shortcut. You can also create your own custom
shortcuts. For more information, see Identifying and Customizing Keyboard Shortcuts.

Navigating Among Files in the Editor


You can use several methods to move through the files open in the editor. You can move among files based on the
order in which you access them, use the IDE Navigator to quickly find any file currently open, or pin favorite files to
the tab well so that they are always visible.
Navigate Backward and Navigate Forward cycle through the open files in the editor based on the order in which
they were accessed, much like Back and Forward do for your viewing history in Microsoft Internet Explorer.
To move through open files in order of use
To activate open documents in the order they were most recently touched, press CTRL + MINUS SIGN.
To activate open documents in the reverse order, press CTRL + SHIFT + MINUS SIGN.

NOTE
Navigate Backward and Navigate For ward also can be found on the View menu.

You also can switch to a specific file open in the editor, regardless of when you last accessed the file, using
the IDE Navigator , the Active Files list in the editor, or the Windows dialog box.
The IDE Navigator works much like the Windows application switcher. It is not available from menus and
can be accessed only using shortcut keys. You can use either of two commands to access the IDE
Navigator (shown below) to cycle through files, depending on the order in which you want to cycle
through.

Window.PreviousDocumentWindowNavallows you to move to the file most recently accessed and


Window.NextDocumentWindowNav allows you to move in the reverse order. General Development Settings
assigns CTRL + SHIFT + TAB to Window.PreviousDocumentWindowNav and CTRL + TAB to
Window.NextDocumentWindowNav .

NOTE
If the settings combination you are using does not already have a shortcut key combination assigned to this command, you
can assign your own custom command using the Keyboard page of the Options dialog box. For more information, see
Identifying and Customizing Keyboard Shortcuts.

To switch to specific files in the editor


Press CTRL + TAB to display the IDE Navigator . Hold down the CTRL key and press TAB repeatedly until
you select the file you intend to switch to.

TIP
To reverse the order in which you go through the Active Files list, hold down the CTRL + SHIFT keys and press TAB.

- or -
In the upper right corner of the editor, choose the Active Files button, and then select a file from the list to
switch to.
- or -
On the menu bar, choose Window , Windows .
In the list, select the file you want to view and then choose Activate .

Navigating Among Tool Windows in the IDE


The IDE Navigator also lets you cycle through the tool windows you have open in the IDE. You can use either of
two commands to access the IDE Navigator to cycle through tool windows, depending on the order in which you
want to cycle through. Window.PreviousToolWindowNav allows you to move to the file most recently accessed and
Window.NextToolWindowNav allows you to move in the reverse order. General Development Settings assigns SHIFT +
ALT + F7 to Window.PreviousDocumentWindowNav and ALT + F7 to Window.NextDocumentWindowNav .
NOTE
If the settings combination you are using does not already have a shortcut key combination assigned to this command, you
can assign your own custom command using the Keyboard page of the Options dialog box. For more information, see
Identifying and Customizing Keyboard Shortcuts.

To switch to a specific tool window in the IDE


Press ALT+F7 to display the IDE Navigator . Hold down the ALT key and press F7 repeatedly until you select
the window you intend to switch to.

TIP
To reverse the order in which you go through the Active Tool Windows list, hold down the SHIFT + ALT keys and
press F7.

See Also
Customizing window layouts Default Keyboard Shortcuts
Finding and Using Visual Studio Extensions
10/18/2019 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Visual Studio extensions are code packages that run inside Visual Studio and provide new or improved Visual
Studio features. You can find more information about Visual Studio extensions here: Visual Studio SDK.
You can use the Extensions and Updates dialog box to install Visual Studio extensions and samples from
websites and other locations, and then enable, disable, update, or uninstall them. (Tools / Extensions and
Updates , or type Extensions in the Quick Launch window). The dialog box also shows updates for installed
samples and extensions. You can also download extensions from websites, or get them from other developers.

NOTE
Starting in Visual Studio 2015, extensions hosted on the Visual Studio Gallery will be automatically updated. You can change
this setting through the Extensions and Updates dialog. See the section on Automatic Extension Updates below for
details.

Finding Visual Studio Extensions


You can install extensions from the Visual Studio Marketplace or the Sample Gallery on the Microsoft website.
Extensions may be controls, samples, templates, tools, or other components that add functionality to Visual Studio.
Visual Studio supports extensions in the VSIX package format—these include project templates, item templates,
Toolbox items, Managed Extension Framework (MEF) components, and VSPackages. You can also download and
install MSI-based extensions, but the Extensions and Updates dialog box can't enable or disable them. The
Visual Studio Gallery contains both VSIX and MSI extensions.

Installing or Uninstalling Visual Studio Extensions


In the Extensions and Updates , find the extension you want to install. (If you know the name or part of the name
of the extension, you can search in the Search Visual Studio Galler y window.) Click Download , then Install .
You must restart Visual Studio in order to load the extension.
If you try to install an extension that has dependencies, the installer verifies whether they're already installed. If
they aren't installed, the Extensions and Updates dialog box lists the dependencies that must be installed before
you can install the extension.
If you want to stop using an extension, you can either disable it or uninstall it. Disabling an extension keeps it
installed but unloaded. You can disable only VSIX extensions; extensions that were installed using an MSI can only
be uninstalled. Find the extension and click Uninstall or Disable . You must restart Visual Studio in order to unload
a disabled extension.

Per-User and Administrative Extensions


Most extensions are per-user extensions and are installed in the %LocalAppData%\Microsoft\VisualStudio\
<Visual Studio version>\Extensions\ folder. A few extensions are administrative extensions, and are installed
in the <Visual Studio installation folder>\Common7\IDE\Extensions\ folder.
To protect your system against extensions that may contain errors or malicious code, you can restrict per-user
extensions to load only when Visual Studio is run with normal user permissions. This means that per-user
extensions are disabled when Visual Studio is run with administrative user permissions. To do this, go to the
Extensions and Updates options page (Tools / Options , Environment , Extensions and Updates , or just type
Extension in the Quick Launch window). Clear the Load per user extensions when running as
administrator check box, then restart Visual Studio.

Automatic Extension Updates


Per-user extensions are automatically updated when a new version is available on the Visual Studio Gallery. The
new version of the extension is detected and installed in the background and on the next restart of Visual Studio,
the new version of the extension will be running.
Only per-user extensions can be automatically updated. Administrative extensions which are installed for all users
will not be updated and you still manually install new versions through the Extensions and Updates dialog
Updates node. You can see which extensions will be automatically updated in the extension’s details pane of
Extensions and Updates dialog.
If you wish to disable automatic updates, you can disable the feature for all extensions or only specific extensions.
To disable automatic updates for all extensions, click the Change your Extensions and Updates settings
link on the Extensions and Updates dialog and uncheck Automatically update extensions .
To disable automatic updates for a specific extension, uncheck the Automatically update this extension
option in the extension’s details pane on the right side of the Extensions and Updates dialog.

NOTE
Starting in Visual Studio 2015 Update 2, you can specify (in Tools / Options / Environment / Extensions and
Updates ) whether you want automatic updates for per-user extensions, all user extensions or both (the default setting).

Sample Master Copies and Working Copies


When you install an online sample, the solution is stored in two locations:
A working copy is stored in the location that you specified in the New Project dialog box.
A separate master copy is stored on your computer.
You can use the Extensions and Updates dialog box to perform these samples-related tasks:
List the master copies of samples that you have installed.
Disable or uninstall the master copy of a sample.
Install Sample Packs, which are collections of samples that relate to a technology or feature.
Install individual online samples. (You can also do this in the New Project dialog box.)
View update notifications when source code changes are published for installed samples.
Update the master copy of an installed sample when there is an update notification.

Installing Without Using the Extensions and Updates Dialog Box


Extensions that have been packaged in .vsix files may be available in locations other than the Visual Studio Gallery.
The Extensions and Updates dialog box can't detect these files, but you can install a .vsix file by double-clicking
the file, or selecting the file and pressing the ENTER key. After that, just follow the instructions. When the extension
is installed, you can use the Extensions and Updates dialog box to enable it, disable it, or uninstall it.

Extension Types Not Supported by the Extensions and Updates Dialog


Box
Visual Studio continues to support extensions that are installed by the Microsoft Installer (MSI) but not through the
Extensions and Updates dialog box without modification.

TIP
If an MSI-based extension includes an extension.vsixmanifest file, the extension will appear in the Extensions and Updates
dialog box.
Get Started Developing with Visual Studio
10/16/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Welcome to Visual Studio! After you have downloaded the product, these pages will help you get started coding.
Make web apps : Tools to create and deploy modern web applications.
Do a tutorial | Browse the docs | Watch a video
Make cross-platform mobile apps in HTML/Javascript (Apache Cordova) : Apache Cordova is an
open-source cross-platform environment that is based on HTML/CSS/Javascript. Your Javascript code
executes in a wrapper that targets a specific platform and enables access to all the hardware capabilities of
the device. Develop apps for the Apple Store, the Android store, and the Windows Store.
Load a sample | Do a tutorial | Browse the docs | Watch a video
Make cross-platform mobile apps in C# or Visual Basic (Xamarin) : Get started using Visual Studio
and Tools for Xamarin to create mobile apps that run on Android, iOS, and the Universal Windows Platform
from a shared code base.
Load a sample: TaskyPortable (native UI) or Xamarin Forms Todo sample (Xamarin.Forms shared UI) | Do a
tutorial | Browse the docs | Watch a video
Make native cross-platform apps and libraries in C++ Go here to get started creating C++ apps and
libraries that run on Android, iOS, and the Universal Windows Platform.
Load a sample | Do a tutorial | Browse the docs | Watch a video
Make games with DirectX : Get started creating Universal Windows Platform games using DirectX.
Load a sample | Do a tutorial | Browse the docs | Watch a video
Make games with Unity : Get started creating cross-platform games using Unity framework.
Load a sample | Do a tutorial | Browse the docs | Watch a video
Make Universal Windows Platform apps : Get started creating apps that run on the Universal Windows
Platform (XBox, PCs, tablets, Windows Phone, Surface Hub, and Internet of Things).
Load a sample | Do a tutorial | Browse the docs | Watch a video
Make desktop applications : Go here to get started creating traditional desktop applications that run on
Windows PCs.
Load a sample | Do a tutorial | Browse the docs
Make Office applications : Get started creating Office applications that extend and customize Word,
Excel, Outlook and PowerPoint with Office 365 services.
Load a sample | Do a tutorial | Browse the docs | Watch a video
Tour Visual Studio Team Ser vices and Team Foundation Ser ver Learn more about Visual Studio
Team Services and Team Foundation Server.

In this section
T IT L E DESC RIP T IO N

Getting Started with Visual C# and Visual Basic Writing JavaScript Code

Visual C++ for Cross-Platform Mobile Development Introduction to Functional Programming with F#

Getting Started with C++ Getting Started with Debugging in Visual Studio 2015
Getting Started with Visual C# and Visual Basic
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Whether you are new to Visual C# or Microsoft Visual Basic, this is the place to start. Getting Started Help is a
series of sequential lessons that introduces you to Visual C# and Visual Basic. Have fun, and write some great
software.
To learn about Visual C++, see Visual C++ resources.

In This Section
Walkthrough: Create a Simple Application Identify the basic windows in the Visual Studio IDE, optimize your
development experience by configuring a setting, and then build a simple program.
Tutorial 1: Create a Picture Viewer Build a program that loads a picture from a file and displays it in a window.
Learn how to drag controls like buttons and picture boxes on your form, set their properties, and use containers to
smoothly resize the form. Get started writing code.
Tutorial 2: Create a Timed Math Quiz Build a timed math quiz game, where the player must answer four random
arithmetic problems within a specified time. Learn how to generate random numbers using the Random class,
trigger events using a Timer control, control program flow using if else statements, and perform basic
arithmetic operations.
Tutorial 3: Create a Matching Game Build a matching game, where the player must match pairs of hidden icons.
Learn how to hold objects using a List object, use a foreach loop, keep track of a form's state using reference
variables, build an event handler that you can use with multiple objects, and make a timer fire exactly once when
started.
Walkthrough: Create a Simple Application with Visual
C# or Visual Basic
11/21/2019 • 12 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

By completing this walkthrough, you’ll become familiar with many of the tools, dialog boxes, and designers that
you can use when you develop applications with Visual Studio. You’ll create a simple “Hello, World”-style
application, design the UI, add code, and debug errors, while you learn more about working in the integrated
development environment (IDE).
This topic contains the following sections:
Configure the IDE
Create a simple application
Debug and test the application

NOTE
This walkthrough is based on Visual Studio Professional, which offers the WPF Application template on which you'll build the
project for this walkthrough. Visual Studio Express for Windows Desktop also offers that template, but Visual Studio Express
for Windows and Visual Studio Express for Web don't. For introductory information about how to use Visual Studio Express
for Windows, see the Developer Center for Windows Store apps. For introductory information about how to use Visual
Studio Express for Web, see Get Started with ASP.NET. In addition, your edition of Visual Studio and the settings that you use
determine the names and locations of some elements of the user interface. See Customizing Development Settings in Visual
Studio.

Configure the IDE


When you start Visual Studio for the first time, Visual Studio prompts you to sign in with a Microsoft Service
Account (MSA), Sign into Visual Studio. You do not need to sign in and can do that later.
On your Visual Studio launch, you next must choose a settings combination that applies a set of pre-defined
customizations to the IDE. Each settings combination has been designed to make it easier for you to develop
applications.
This walkthrough assume you applied General Development Settings , which applies the least amount of
customization to the IDE. If you have already chosen C# or Visual Basic (both are good choices), you don’t have to
change your settings. If you want to change your settings, you can use the Impor t and Expor t Settings Wizard .
See Customizing Development Settings in Visual Studio.
After you open Visual Studio, you can identify the tool windows, the menus and toolbars, and the main window
space. Tool windows are docked on the left and right sides of the application window, with Quick Launch , the
menu bar, and the standard toolbar at the top. In the center of the application window is the Star t Page . When
you load a solution or project, editors and designers appear in the space where the Star t Page is. When you
develop an application, you’ll spend most of your time in this central area.
Figure 2: Visual Studio IDE

You can make additional customizations to Visual Studio, such as changing the font face and size of the text in the
editor or the color theme of the IDE, by using the Options dialog box. Depending on the settings combination that
you’ve applied, some items in that dialog box might not appear automatically. You can make sure that all possible
options appear by choosing the Show all settings check box.
Figure 3: Options dialog box

In this example, you’ll change the color theme of the IDE from light to dark. You can skip ahead to create a project
if you like.
To change the color theme of the IDE
1. Open the Options dialog box by choosing the Tools menu at the top and then the Options … item.
2. Change the Color theme to Dark , then click OK .

The colors in Visual Studio should match the following image:

The color theme used for pictures in the rest of this walkthrough is the light theme. For more information
about customizing the IDE, see Customizing Development Settings in Visual Studio.

Create a simple application


Create the project
When you create an application in Visual Studio, you first create a project and a solution. For this example, you’ll
create a Windows Presentation Foundation (WPF) project.
To c r e a t e t h e W P F p r o j e c t

1. Create a new project. On the menu bar, choose File , New , Project… .

You can also type New Project in the Quick Launch box to do the same thing.

2. Choose the Visual Basic or the Visual C# WPF Application template by choosing in the left pane Installed ,
Templates , Visual C# , Windows , for example, and then choosing WPF Application in the middle pane.
Name the project HelloWPFApp at the bottom of the New Project dialog.

OR
Visual Studio creates the HelloWPFApp project and solution, and the Solution Explorer shows the various
files. The WPF Designer shows a design view and an XAML view of MainWindow.xaml in a split view. You
can slide the splitter to show more or less of either view. You can choose to see only the visual view or only
the XAML view. (For more information, see WPF Designer for Windows Forms Developers). The following
items appear in Solution Explorer :
Figure 5: Project items

After you create the project, you can customize it. By using the Proper ties window (found on the View
menu), you can display and change options for project items, controls, and other items in an application. By
using the project properties and property pages, you can display and change options for projects and
solutions.
To c h a n g e t h e n a m e o f M a i n W i n d o w .x a m l

1. In the following procedure, you’ll give MainWindow a more specific name. In Solution Explorer , select
MainWindow.xaml. You should see the Proper ties window, but if you don’t, choose the View menu and
the Proper ty Window item. Change the File Name property to Greetings.xaml .
Solution Explorer shows that the name of the file is now Greetings.xaml, and if you expand the
MainWindow.xaml node (by putting focus in the node and pressing the rightarrow key), you see the name
of MainWindow.xaml.vb or MainWindow.xaml.cs is now Greetings.xaml.vb or Greetings.xaml.cs. This code
file is nested under the .xaml file node to show they are very closely related to each other.

WARNING
This change causes an error that you will learn how to debug and fix in a later step.

2. In Solution Explorer , open Greetings.xaml in the Designer view (by pressing the Enter key while the node
has focus) and select the title bar of the window by using the mouse.
3. In the Proper ties window, change the value of the Title property to Greetings .
The title bar for MainWindow.xaml now reads Greetings.
Design the user interface (UI )
We will add three types of controls to this application: a TextBlock control, two RadioButton controls, and a Button
control.
To a d d a Te x t B l o c k c o n t r o l

1. Open the Toolbox window by choosing the View menu and the Toolbox item.
2. In the Toolbox , search for the TextBlock control.

3. Add a TextBlock control to the design surface by choosing the TextBlock item and dragging it to the window
on the design surface. Center the control near the top of the window.
Your window should resemble the following illustration:
Figure 7: Greetings window with TextBlock control
The XAML markup should look something like the following:

<TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center"


RenderTransformOrigin="4.08,2.312" Margin="237,57,221,238"><Run Text="TextBlock"/><InlineUIContainer>
<TextBlock TextWrapping="Wrap" Text="TextBlock"/>

To c u st o m i z e t h e t e x t i n t h e t e x t b l o c k

1. In the XAML view, locate the markup for TextBlock and change the Text attribute:
Text=”Select a message option and then choose the Display button.”

2. If the TextBlock does not expand to fit the In the Design view, enlarge the TextBlock control (using the grab
handles on the edges) so that it displays all the text.
3. Save your changes by pressing Ctrl-s or using the File menu item.
Next, you’ll add two RadioButton controls to the form.
To a d d r a d i o b u t t o n s

1. In the Toolbox , search for the RadioButton control.

2. Add two RadioButton controls to the design surface by choosing the RadioButton item and dragging it to
the window on the design surface twice, and move the buttons (by selecting them and using the arrow
keys) so that the buttons appear side by side under the TextBlock control.
Your window should look like this:
Figure 8: RadioButtons in the Greetings window.
3. In the Proper ties window for the left RadioButton control, change the Name property (the property at the
top of the Proper ties window) to RadioButton1 . Make sure you have selected the RadioButton and not the
background Grid on the form; the Type field of the Property Window under the Name field should say
RadioButton.
4. In the Proper ties window for the right RadioButton control, change the Name property to RadioButton2 ,
and then save your changes by pressing Ctrl-s or using the File menu item. Make sure you selected the
RadioButton before changing and saving.
You can now add display text for each RadioButton control. The following procedure updates the Content
property for a RadioButton control.
To a d d d i sp l a y t e x t fo r e a c h r a d i o b u t t o n

1. On the design surface, open the shortcut menu for RadioButton1 by pressing the right mouse button while
selecting RadioButton1, choose Edit Text , and then enter Hello .
2. Open the shortcut menu for RadioButton2 by pressing the right mouse button while selecting
RadioButton2, choose Edit Text , and then enter Goodbye .
The final UI element that you’ll add is a Button control.
To a d d t h e b u t t o n c o n t r o l

1. In the Toolbox , search for the Button control, and then add it to the design surface under the RadioButton
controls by selecting Button and dragging it to the form in the design view.
2. In the XAML view, change the value of Content for the Button control from Content=”Button” to
Content=”Display” , and then save the changes (Ctrl-s or use the File menu).

The markup should resemble the following example:


<Button Content="Display" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75"
Margin="215,204,0,0"/>

Your window should resemble the following illustration.


Figure 9: Final Greetings UI
Add code to the Display Button
When this application runs, a message box appears after a user first chooses a radio button and then chooses the
Display button. One message box will appear for Hello, and another will appear for Goodbye. To create this
behavior, you’ll add code to the Button_Click event in Greetings.xaml.vb or Greetings.xaml.cs.
A d d c o d e t o d i sp l a y m e ssa g e b o x e s

1. On the design surface, double-click the Display button.


Greetings.xaml.vb or Greetings.xaml.cs opens, with the cursor in the Button_Click event. You can also add a
click event handler as follows (if the pasted code has a red squiggle under any names, then you probably
did not select the RadioButton controls on the design surface and rename them):
For Visual Basic, the event handler should look like this:

Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs)

End Sub

For Visual C#, the event handler should look like this:

private void Button_Click_1(object sender, RoutedEventArgs e)


{

2. For Visual Basic, enter the following code:

If RadioButton1.IsChecked = True Then


MessageBox.Show("Hello.")
Else RadioButton2.IsChecked = True
MessageBox.Show("Goodbye.")
End If

For Visual C#, enter the following code:


if (RadioButton1.IsChecked == true)
{
MessageBox.Show("Hello.");
}
else
{
RadioButton2.IsChecked = true;
MessageBox.Show("Goodbye.");
}

3. Save the application.

Debug and test the application


Next, you’ll debug the application to look for errors and test that both message boxes appear correctly. The
following instructions tell you how to build and launch the debugger, but later you might read Building a WPF
Application (WPF) and Debugging WPF for more information.
Find and fix errors
In this step, you’ll find the error that we caused earlier by changing the name of the main window XAML file.
To st a r t d e b u g g i n g a n d fi n d t h e e r r o r

1. Start the debugger by selecting Debug , then Star t Debugging .

A dialog box appears, indicating that an IOException has occurred: Cannot locate resource
‘mainwindow.xaml’.
2. Choose the OK button, and then stop the debugger.

We renamed Mainwindow.xaml to Greetings.xaml at the start of this walkthrough, but the code still refers to
Mainwindow.xaml as the startup URI for the application, so the project can't start.
To sp e c i fy G r e e t i n g s.x a m l a s t h e st a r t u p U R I

1. In Solution Explorer , open the App.xaml file (in the C# project) or the Application.xaml file (in the Visual
Basic project) in the XAML view (it cannot be opened in the Design view) by selecting the file and pressing
Enter or by double clicking it.
2. Change StartupUri="MainWindow.xaml" to StartupUri="Greetings.xaml" , and then save the changes with
Ctrl-s.
Start the debugger again (press F5). You should see the Greetings window of the application.
To debug with breakpoints
By adding some breakpoints, you can test the code during debugging. You can add breakpoints by choosing
Debug on the main menu, then Toggle Breakpoint or by clicking in the left margin of the editor next to the line
of code where you want the break to occur.
To a d d b r e a k p o i n t s

1. Open Greetings.xaml.vb or Greetings.xaml.cs, and select the following line: MessageBox.Show("Hello.")

2. Add a breakpoint from the menu by selecting Debug , then Toggle Breakpoint .

A red circle appears next to the line of code in the far left margin of the editor window.
3. Select the following line: MessageBox.Show("Goodbye.") .
4. Press the F9 key to add a breakpoint, and then press the F5 key to start debugging.
5. In the Greetings window, choose the Hello radio button, and then choose the Display button.
The line MessageBox.Show("Hello.") is highlighted in yellow. At the bottom of the IDE, the Autos, Locals, and
Watch windows are docked together on the left side, and the Call Stack, Breakpoints, Command, Immediate,
and Output windows are docked together on the right side.
6. On the menu bar, choose Debug , Step Out .
The application resumes execution, and a message box with the word “Hello” appears.
7. Choose the OK button on the message box to close it.
8. In the Greetings window, choose the Goodbye radio button, and then choose the Display button.
The line MessageBox.Show("Goodbye.") is highlighted in yellow.
9. Choose the F5 key to continue debugging. When the message box appears, choose the OK button on the
message box to close it.
10. Press the SHIFT + F5 keys (press shift first, and while holding it down, press F5) to stop debugging.
11. On the menu bar, choose Debug , Disable All Breakpoints .
Build a release version of the application
Now that you’ve verified that everything works, you can prepare a release build of the application.
To c l e a n t h e so l u t i o n fi l e s a n d b u i l d a r e l e a se v e r si o n

1. On the main menu, select Build , then Clean solution to delete intermediate files and output files that were
created during previous builds. This is not necessary, but it cleans up the debug build outputs.

2. Change the build configuration for HelloWPFApp from Debug to Release by using the dropdown control
on the toolbar (it says “Debug” currently).

3. Build the solution by choosing Build , then Build Solution or press the F6 key.

Congratulations on completing this walkthrough! You can find the .exe you built under your solution and
project directory (…\HelloWPFApp\HelloWPFApp\bin\Release\). If you want to explore more examples, see
Visual Studio Samples.

See Also
What's New in Visual Studio 2015 Get Started Developing with Visual Studio Productivity Tips
Tutorial 1: Create a Picture Viewer
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In this tutorial, you build a program that loads a picture from a file and displays it in a window. You learn how to
drag controls like buttons and picture boxes on your form, set their properties, and use containers to smoothly
resize the form. You also get started writing code. You learn how to:
Create a new project.
Test (debug) an application.
Add basic controls like check boxes and buttons to a form.
Position controls on a form using layouts.
Add Open File and Color dialog boxes to a form.
Write code using IntelliSense and code snippets.
Write event handler methods.
When you finish, your program will look like the following picture.

Picture that you create in


this tutorial
For a video version of this topic, see How Do I: Create a Picture Viewer in Visual Basic? or How Do I:
Create a Picture Viewer in C#?.
NOTE
These videos use an earlier version of Visual Studio, so there are slight differences in some menu commands and other user
interface elements. However, the concepts and procedures work similarly in the current version of Visual Studio. Visual C#
and Visual Basic are both covered in this tutorial, so focus on information specific to the programming language that you're
using.
To see code for Visual Basic, choose the VB tab at the top of code blocks, and to see code for Visual C#, choose the C# tab. If
you're interested in learning about Visual C++, see Getting Started and C++ Language Tutorial.
If you're interested in learning how to write Visual C# or Visual Basic apps for the Windows Store, see Create your first
Windows Store app using C# or Visual Basic. For information about creating JavaScript apps for the Windows Store, see
Create your first Windows Store app using JavaScript.

Related Topics
T IT L E DESC RIP T IO N

Step 1: Create a Windows Forms Application Project Begin by creating a Windows Forms application project.

Step 2: Run Your Program Run the Windows Forms application program that you created
in the previous step.

Step 3: Set Your Form Properties Change the way your form looks using the Proper ties
window.

Step 4: Lay Out Your Form with a TableLayoutPanel Control Add a TableLayoutPanel control to your form.

Step 5: Add Controls to Your Form Add controls, such as a PictureBox control and a
CheckBox control, to your form. Add buttons to your form.

Step 6: Name Your Button Controls Rename your buttons to something more meaningful.

Step 7: Add Dialog Components to Your Form Add an OpenFileDialog component and a ColorDialog
component to your form.

Step 8: Write Code for the Show a Picture Button Event Write code using the IntelliSense tool.
Handler

Step 9: Review, Comment, and Test Your Code Review and test your code. Add comments as needed.

Step 10: Write Code for Additional Buttons and a Check Box Write code to make other buttons and a check box work using
IntelliSense.

Step 11: Run Your Program and Try Other Features Run your program and set the background color. Try other
features, such as changing colors, fonts, and borders.
Step 1: Create a Windows Forms Application Project
1/10/2020 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

When you create a picture viewer, the first step is to create a Windows Forms Application project.
For a video version of this topic, see Tutorial 1: Create a Picture Viewer in Visual Basic - Video 1 or Tutorial 1:
Create a Picture Viewer in C# - Video 1. These videos use an earlier version of Visual Studio, so there are slight
differences in some menu commands and other user interface elements. However, the concepts and procedures
work similarly in the current version of Visual Studio.
To create a Windows Forms Application project
1. On the menu bar, choose File , New , Project . The dialog box should look like this.

New
project dialog box
2. Choose either Visual C# or Visual Basic in the Installed Templates list.
3. In the templates list, choose the Windows Forms Application icon. Name the new form PictureViewer ,
and then choose the OK button.
Visual Studio creates a solution for your program. A solution acts as a container for all of the projects and
files needed by your program. These terms will be explained in more detail later in this tutorial.
4. The following illustration shows what you should now see in the Visual Studio interface.
NOTE
Your window layout may not look exactly like this illustration. The precise window layout depends on the version of
Visual Studio, the programming language you are using, and other factors. However, you should verify that all three
windows appear.

IDE window
The interface contains three windows: a main window, Solution Explorer , and the Proper ties window.
If any of these windows are missing, restore the default window layout by, on the menu bar, choosing
Window , Reset Window Layout . You can also display windows by using menu commands. On the menu
bar, choose View , Proper ties Window or Solution Explorer . If any other windows are open, close them
by choosing the Close (x) button in their upper-right corners.
5. The illustration shows the following windows (going clockwise from the upper-left corner):
Main window In this window, you'll do most of your work, such as working with forms and editing
code. In the illustration, the window shows a form in the Form Editor. At the top of the window, the
Star t Page tab and the Form1.cs [Design] tab appear. (In Visual Basic, the tab name ends with .vb
instead of .cs.)
Solution Explorer window In this window, you can view and navigate to all items in your solution.
If you choose a file, the contents of the Proper ties window changes. If you open a code file (which
ends in .cs in Visual C# and .vb in Visual Basic), the code file or a designer for the code file appears. A
designer is a visual surface onto which you can add controls such as buttons and lists. For Visual
Studio forms, the designer is called the Windows Forms Designer.
Proper ties window In this window, you can change the properties of items that you choose in the
other windows. For example, if you choose Form1, you can change its title by setting the Text
property, and you can change the background color by setting the Backcolor property.

NOTE
The top line in Solution Explorer shows Solution 'PictureViewer' (1 project) , which means that Visual Studio
created a solution for you. A solution can contain more than one project, but for now, you'll work with solutions that
contain only one project.

6. On the menu bar, choose File , Save All .


As an alternative, choose the Save All button on the toolbar, which the following illustration shows.
Save All toolbar button
Visual Studio automatically fills in the folder name and the project name and then saves the project in your
projects folder.
To continue or review
To go to the next tutorial step, see Step 2: Run Your Program.
To return to the overview topic, see Tutorial 1: Create a Picture Viewer.
Step 2: Run Your Program
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

When you created a new solution, you actually built a program that runs. It doesn't do much yet—it just displays
an empty window that shows Form1 in the title bar. But it does run, as you're about to find out.
For a video version of this topic, see Tutorial 1: Create a Picture Viewer in Visual Basic - Video 1 or Tutorial 1:
Create a Picture Viewer in C# - Video 1. These videos use an earlier version of Visual Studio, so there are slight
differences in some menu commands and other user interface elements. However, the concepts and procedures
work similarly in the current version of Visual Studio.
To run your program
1. Use one of the following methods to run your program.
Choose the F5 key.
On the menu bar, choose Debug , Star t Debugging .
On the toolbar, choose the Star t Debugging button, which appears as follows.
Start Debugging toolbar button
2. Visual Studio runs your program, and a window called Form1 appears. The following diagram shows the
program you just built. The program is running, and you will soon add to it.

Windows Form Application program running


3. Go back to the Visual Studio integrated development environment (IDE), and look at the new toolbar.
Additional buttons appear on the toolbar when you run a program. These buttons let you do things like stop
and start your program, and help you track down any errors (bugs) it may have. For this example, we're just
using it to start and stop the program.

Debugging toolbar
4. Use one of the following methods to stop your program.
On the toolbar, choose the Stop Debugging button.
On the menu bar, choose Debug , Stop Debugging .
Choose the X button in the upper corner of the Form1 window.
NOTE
When you run your program from inside the IDE, it's called debugging because you typically do it to locate and fix
bugs (errors) in the program. Although this program is small and doesn't really do anything yet, it's still a real
program. You follow the same procedure to run and debug other programs. To learn more about debugging, see
Debugger Basics.

To continue or review
To go to the next tutorial step, see Step 3: Set Your Form Properties.
To return to the previous tutorial step, see Step 1: Create a Windows Forms Application Project.
Step 3: Set Your Form Properties
1/10/2020 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Next, you use the Proper ties window to change the way your form looks.
For a video version of this topic, see Tutorial 1: Create a Picture Viewer in Visual Basic - Video 1 or Tutorial 1:
Create a Picture Viewer in C# - Video 1. These videos use an earlier version of Visual Studio, so there are slight
differences in some menu commands and other user interface elements. However, the concepts and procedures
work similarly in the current version of Visual Studio.
To set your form properties
1. Be sure you're looking at Windows Forms Designer. In the Visual Studio integrated development
environment (IDE), choose the Form1.cs [Design] tab (or the Form1.vb [Design] tab in Visual Basic).
2. Choose anywhere inside the form Form1 to select it. Look at the Proper ties window, which should now be
showing the properties for the form. Forms have various properties. For example, you can set the
foreground and background color, title text that appears at the top of the form, size of the form, and other
properties.

NOTE
If the Proper ties window doesn't appear, stop your program by choosing the square Stop Debugging button on
the toolbar, or just close the window. If the program is stopped and you still don't see the Proper ties window, on
the menu bar, choose View , Proper ties Window .

3. After the form is selected, find the Text property in the Proper ties window. Depending on how the list is
sorted, you might need to scroll down. Choose Text , type Picture Viewer , and then choose ENTER. Your
form should now have the text Picture Viewer in its title bar, and the Proper ties window should look
similar to the following picture.

Properties window
NOTE
Properties can be ordered by a Categorized or Alphabetical view. You can switch between these two views by using
the buttons on the Proper ties window. In this tutorial, it's easier to find properties through the Alphabetical view.

4. Go back to Windows Forms Designer. Choose the form's lower-right drag handle, which is the small white
square in the lower-right of the form and appears as follows.

Drag handle
Drag the handle to resize the form so the form is wider and a bit taller.
5. Look at the Proper ties window, and notice that the Size property has changed. The Size property changes
each time you resize the form. Try dragging the form's handle to resize it to a form size of approximately
550, 350 (no need to be exact), which should work well for this project. As an alternative, you can enter the
values directly in the Size property and then choose the ENTER key.
6. Run your program again. Remember, you can use any of the following methods to run your program.
Choose the F5 key.
On the menu bar, choose Debug , Star t Debugging .
On the toolbar, choose the Star t Debugging button, which appears as follows.
Start Debugging toolbar button
Just like before, the IDE builds and runs your program, and a window appears.
7. Before going to the next step, stop your program, because the IDE won't let you change your program while
it's running. Remember, you can use any of the following methods to stop your program.
On the toolbar, choose the Stop Debugging button.
On the menu bar, choose Debug , Stop Debugging .
Choose the X button in the upper corner of the Form1 window.
To continue or review
To go to the next tutorial step, see Step 4: Lay Out Your Form with a TableLayoutPanel Control.
To return to the previous tutorial step, see Step 2: Run Your Program.
Step 4: Lay Out Your Form with a TableLayoutPanel
Control
1/10/2020 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In this step, you add a TableLayoutPanel control to your form. The TableLayoutPanel helps properly align controls
in the form that you will add later.
For a video version of this topic, see Tutorial 1: Create a Picture Viewer in Visual Basic - Video 2 or Tutorial 1:
Create a Picture Viewer in C# - Video 2. These videos use an earlier version of Visual Studio, so there are slight
differences in some menu commands and other user interface elements. However, the concepts and procedures
work similarly in the current version of Visual Studio.
To lay out your form with a TableLayoutPanel control
1. On the left side of the Visual Studio IDE, locate the Toolbox tab. Choose the Toolbox tab, and the Toolbox
appears. (Or, on the menu bar, choose View , Toolbox .)
2. Choose the small triangle symbol next to the Containers group to open it, as shown in the following
picture.

Containers group
3. You can add controls like buttons, check boxes, and labels to your form. Double-click the TableLayoutPanel
control in the Toolbox. (Or, you can drag the control from the toolbox onto the form.) When you do this, the
IDE adds a TableLayoutPanel control to your form, as shown in the following picture.
TableLayoutPanel
control

NOTE
After you add your TableLayoutPanel, if a window appears inside your form with the title TableLayoutPanel Tasks ,
choose anywhere inside the form to close it. You will learn more about this window later in the tutorial.

Notice how the Toolbox expands to cover your form when you choose its tab, and closes after you choose
anywhere outside of it. That's the IDE auto-hide feature. You can turn it on or off for any of the windows by
choosing the pushpin icon in the upper-right corner of the window to toggle auto-hide and lock it in place.
The pushpin icon appears as follows.
Pushpin icon
4. Be sure TableLayoutPanel is selected by choosing it. You can verify what control is selected by looking at
the drop-down list at the top of the Proper ties window, as shown in the following picture.

Properties window showing TableLayoutPanel control


5. Choose the Alphabetical button on the toolbar in the Proper ties window. This causes the list of
properties in the Proper ties window to display in alphabetical order, which will make it easier to locate
properties in this tutorial.
6. The control selector is a drop-down list at the top of the Proper ties window. In this example, it shows that a
control called tableLayoutPanel1 is selected. You can select controls either by choosing an area in Windows
Forms Designer or by choosing from the control selector. Now that TableLayoutPanel is selected, find the
Dock property and choose Dock , which should be set to None . Notice that a drop-down arrow appears
next to the value. Choose the arrow, and then select the Fill button (the large button in the middle), as
shown in the following picture.
Properties window with Fill selected
Docking in Visual Studio refers to when a window is attached to another window or area in the IDE. For
example, the Properties window can be undocked – that is, unattached and free-floating within Visual
Studio – or it can be docked against Solution Explorer .
7. After you set the TableLayoutPanel Dock property to Fill , the panel fills the entire form. If you resize the
form again, the TableLayoutPanel stays docked, and resizes itself to fit.

NOTE
A TableLayoutPanel works like a table in Microsoft Office Word: It has rows and columns, and an individual cell can
span multiple rows and columns. Each cell can hold one control (like a button, a check box, or a label). Your
TableLayoutPanel will have a PictureBox control spanning its entire top row, a CheckBox control in its lower-left
cell, and four Button controls in its lower-right cell.

8. Currently, the TableLayoutPanel has two equal-size rows and two equal-size columns. You need to resize
them so the top row and right column are both much bigger. In Windows Forms Designer, select the
TableLayoutPanel. In the upper-right corner, there is a small black triangle button, which appears as follows.
Triangle button
This button indicates that the control has tasks that help you set its properties automatically.
9. Choose the triangle to display the control's task list, as shown in the following picture.

TableLayoutPanel tasks
10. Choose the Edit Rows and Columns task to display the Column and Row Styles window. Choose
Column1 , and set its size to 15 percent by being sure the Percent button is selected and entering 15 in
the Percent box. (That's a NumericUpDown control, which you will use in a later tutorial.) Choose Column2
and set it to 85 percent. Don't choose the OK button yet, because the window will close. (But if you do, you
can reopen it using the task list.)

TableLayoutPanel column and row styles


11. From the Show drop-down list at the top of the window, choose Rows . Set Row1 to 90 percent and Row2
to 10 percent.
12. Choose the OK button. Your TableLayoutPanel should now have a large top row, a small bottom row, a small
left column, and a large right column. You can resize the rows and columns in the TableLayoutPanel by
choosing tableLayoutPanel1 in the form and then dragging its row and column borders.

Form1 with resized


TableLayoutPanel
To continue or review
To go to the next tutorial step, see Step 5: Add Controls to Your Form.
To return to the previous tutorial step, see Step 3: Set Your Form Properties.
Step 5: Add Controls to Your Form
1/10/2020 • 6 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In this step, you add controls, such as a PictureBox control and a CheckBox control, to your form. You then add
buttons to your form.
For a video version of this topic, see Tutorial 1: Create a Picture Viewer in Visual Basic - Video 2 or Tutorial 1:
Create a Picture Viewer in C# - Video 2. These videos use an earlier version of Visual Studio, so there are slight
differences in some menu commands and other user interface elements. However, the concepts and procedures
work similarly in the current version of Visual Studio.
To add controls to your form
1. Go to the Toolbox tab (located on the left side of the Visual Studio IDE) and expand the Common Controls
group. This shows the most common controls that you see on forms.
2. Choose the TableLayoutPanel control on the form. To verify that the TableLayoutPanel is selected, make sure
that its name appears in the dropdown list box at the top of the Proper ties window. You can also choose
form controls by using the dropdown list box at the top of the Proper ties window. Choosing a control this
way can often be easier than choosing a tiny control with a mouse.
3. Double-click the PictureBox item to add a PictureBox control to your form. Because the TableLayoutPanel is
docked to fill your form, the IDE adds the PictureBox control to the first empty cell (the upper left corner).
4. Choose the new PictureBox control to select it, and then choose the black triangle on the new PictureBox
control to display its task list, as shown in the following picture.

PictureBox tasks

NOTE
If you accidentally add the wrong type of control to your TableLayoutPanel, you can delete it. Right-click the control,
and then choose Delete on its context menu. You can also remove controls from the form by using the menu bar.
On the menu bar, choose Edit , Undo , or Edit , Delete .

5. Choose the Dock in parent container link. This automatically sets the PictureBox Dock property to Fill .
To see this, choose the PictureBox control to select it, go to the Proper ties window, and be sure that the
Dock property is set to Fill .
6. Make the PictureBox span both columns by changing its ColumnSpan property. Choose the PictureBox
control and set its ColumnSpan property to 2 . Also, when the PictureBox is empty, you want to show an
empty frame. Set its BorderStyle property to Fixed3D .
NOTE
If you don't see a ColumnSpan property for your PictureBox, then it's likely that the PictureBox was added to the
form rather than the TableLayoutPanel. To fix this, choose the PictureBox, delete it, choose the TableLayoutPanel, and
then add a new PictureBox.

7. Choose the TableLayoutPanel on the form and then add a CheckBox control to the form. Double-click the
CheckBox item in the Toolbox to add a new CheckBox control to the next free cell in your table. Because a
PictureBox takes up the first two cells in the TableLayoutPanel, the CheckBox control is added to the lower-
left cell. Choose the Text property and type in the word Stretch , as shown in the following picture.

TextBox control with Stretch property


8. Choose the TableLayoutPanel on the form, and then go to the Containers group in the Toolbox (where you
got your TableLayoutPanel control) and double-click the FlowLayoutPanel item to add a new control to the
last cell in the PictureBox (bottom right). Then dock the FlowLayoutPanel in the TableLayoutPanel (either by
choosing Dock in parent container on the FlowLayoutPanel's black triangle task list, or by setting the
FlowLayoutPanel's Dock property to Fill ).

NOTE
A FlowLayoutPanel is a container that arranges other controls in neat rows in order. When you resize a
FlowLayoutPanel, if it has room to lay out all of its controls in a single row, it does that. Otherwise, it arranges them
in lines, one on top of the other. You will use a FlowLayoutPanel to hold four buttons. If the buttons arrange one on
top another when added, be sure that the FlowLayoutPanel is selected before adding the buttons. Although it was
stated earlier that each cell can hold only one control, the lower-right cell of the TableLayoutPanel has four button
controls. This is because you can put a control in a cell that holds other controls. That kind of control is called a
container, and the FlowLayoutPanel is a container.

To add buttons
1. Choose the new FlowLayoutPanel that you added. Go to Common Controls in the Toolbox and double-
click the Button item to add a button control called button1 to your FlowLayoutPanel. Repeat to add
another button. The IDE determines that there's already a button called button1 and calls the next one
button2 .
2. Typically, you add the other buttons using the Toolbox. This time, choose button2 , and then on the menu
bar, choose Edit , Copy (or press Ctrl+C). On the menu bar, choose Edit , Paste (or press Ctrl+V) to paste a
copy of your button. Now paste it again. The IDE has now added button3 and button4 to the
FlowLayoutPanel.

NOTE
You can copy and paste any control. The IDE names and places the new controls in a logical manner. If you paste a
control into a container, the IDE chooses the next logical space for placement.
3. Choose the first button and set its Text property to Show a picture . Then set the Text properties of the
next three buttons to Clear the picture , Set the background color , and Close .
4. The next step is to size the buttons and arrange them so they align to the right side of the panel. Choose the
FlowLayoutPanel and look at its FlowDirection property. Change it so it's set to RightToLeft . As soon as
you do, the buttons should align themselves to the right side of the cell, and reverse their order so that the
Show a picture button is on the right.

NOTE
If the buttons are still in the wrong order, you can drag the buttons around the FlowLayoutPanel to rearrange them
in any order. You can choose a button and drag it left or right.

5. Choose the Close button to select it. Hold down the CTRL key and choose the other three buttons, so that
they are all selected. While all the buttons are selected, go to the Proper ties window and scroll up to the
AutoSize property. This property tells the button to automatically resize itself to fit all of its text. Set it to
true . Your buttons should now be sized properly and be in the right order. (As long as all four buttons are
selected, you can change all four AutoSize properties at the same time.) The following picture shows the
four buttons.

Picture Viewer with four


buttons
6. Now run your program again to see your newly laid out form. Choosing the buttons and the check box
doesn't do anything yet, but it will work soon.
To continue or review
To go to the next tutorial step, see Step 6: Name Your Button Controls.
To return to the previous tutorial step, see Step 4: Lay Out Your Form with a TableLayoutPanel Control.
Step 6: Name Your Button Controls
1/10/2020 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

There's only one PictureBox on your form. When you added it, the IDE automatically named it pictureBox1 .
There's only one CheckBox, which is named checkBox1 . Soon, you will write some code, and that code will refer to
the CheckBox and PictureBox. Because there's only one of each of these controls, you will know what it means
when you see pictureBox1 or checkBox1 in your code.

NOTE
In Visual Basic, the default first letter of any control name is initial cap, so the names are PictureBox1 , CheckBox1 , and so
on.

There are four buttons on your form, and the IDE named them button1 , button2 , button3 , and button4 . By just
looking at their current names, you don't know which button is the Close button and which one is the Show a
picture button. That's why giving your button controls more informative names is helpful.
For a video version of this topic, see Tutorial 1: Create a Picture Viewer in Visual Basic - Video 3 or Tutorial 1:
Create a Picture Viewer in C# - Video 3. These videos use an earlier version of Visual Studio, so there are slight
differences in some menu commands and other user interface elements. However, the concepts and procedures
work similarly in the current version of Visual Studio.
To name your button controls
1. On the form, choose the Close button. (If you still have all the buttons selected, choose the ESC key to
cancel the selection.) Scroll in the Proper ties window until you see the (Name) property. (The (Name)
property is near the top when the properties are alphabetical.) Change the name to closeButton , as shown
in the following picture.

Properties window with closeButton name


NOTE
If you try changing the name of your button to closeButton , with a space between the words close and Button, the
IDE displays an error message: "Property value is not valid." Spaces (and a few other characters) are not allowed in
control names.

2. Rename the other three buttons to backgroundButton , clearButton , and showButton . You can verify the
names by choosing the control selector drop-down list in the Proper ties window. The new button names
appear.
3. Double-click the Show a picture button on the form. As an alternative, choose the Show a picture button
on the form, and then choose the ENTER key. When you do, the IDE opens an additional tab in the main
window called Form1.cs (Form1.vb if you're using Visual Basic). This tab shows the code file behind the
form, as shown in the following picture.

Form1.cs tab
with Visual C# code
4. Focus on this part of the code. (Choose the VB tab below if you're using Visual Basic to view the Visual Basic
version of the code.)

private void showButton_Click(object sender, EventArgs e)


{
}

Private Sub showButton_Click() Handles showButton.Click

End Sub

You are looking at code called showButton_Click() . The IDE added this to the form's code when you opened
the code file for the showButton button. At design-time, when you open the code file for a control in a
form, code is generated for the control if it doesn't already exist. This code, known as a method, runs when
you run your program and choose the control - in this case, the Show a picture button.
NOTE
In this tutorial, the Visual Basic code that's automatically generated has been simplified by removing everything
between the parentheses, (). Whenever this occurs, you can remove the same code. Your program will work either
way. For the remainder of the tutorials, any automatically generated code is simplified whenever possible.

5. Choose the Windows Forms Designer tab again (Form1.cs [Design] in Visual C#, Form1.vb [Design] in
Visual Basic) and then open the code file for the Clear the picture button to create a method for it in the
form's code. Repeat this for the remaining two buttons. Each time, the IDE adds a new method to the form's
code file.
6. To add one more method, open the code file for the CheckBox control in Windows Forms Designer to make
the IDE add a checkBox1_CheckedChanged() method. That method is called whenever the user selects or
clears the check box.

NOTE
When working on a program, you often move between the code editor and Windows Forms Designer. The IDE
makes it easy to navigate in your project. Use Solution Explorer to open Windows Forms Designer by double-
clicking Form1.cs in Visual C# or Form1.vb in Visual Basic, or on the menu bar, choose View , Designer .

The following shows the new code that you see in the code editor.

private void clearButton_Click(object sender, EventArgs e)


{
}

private void backgroundButton_Click(object sender, EventArgs e)


{
}

private void closeButton_Click(object sender, EventArgs e)


{
}

private void checkBox1_CheckedChanged(object sender, EventArgs e)


{
}

Private Sub clearButton_Click() Handles clearButton.Click

End Sub

Private Sub backgroundButton_Click() Handles backgroundButton.Click

End Sub

Private Sub closeButton_Click() Handles closeButton.Click

End Sub

Private Sub CheckBox1_CheckedChanged() Handles CheckBox1.CheckedChanged

End Sub

The five methods that you added are called event handlers, because your program calls them whenever an
event (like a user choosing a button or selecting a box) happens.
When you view the code for a control in the IDE at design time, Visual Studio adds an event handler method
for the control if one isn't there. For example, when you double-click a button, the IDE adds an event handler
for its Click event (which is called whenever the user chooses the button). When you double-click a check
box, the IDE adds an event handler for its CheckedChanged event (which is called whenever the user selects
or clears the box).
After you add an event handler for a control, you can return to it at any time from Windows Forms Designer
by double-clicking the control, or on the menu bar, choosing View , Code .
Names are important when you build programs, and methods (including event handlers) can have any
name that you want. When you add an event handler with the IDE, it creates a name based on the control's
name and the event being handled. For example, the Click event for a button named showButton is called
the showButton_Click() event handler method. Also, opening and closing parentheses () are usually added
after the method name to indicate that methods are being discussed. If you decide you want to change a
code variable name, right-click the variable in the code and then choose Refactor , Rename . All instances of
that variable in the code are renamed. See Rename Refactoring (C#) or Refactoring and Rename Dialog Box
for more information.
To continue or review
To go to the next tutorial step, see Step 7: Add Dialog Components to Your Form.
To return to the previous tutorial step, see Step 5: Add Controls to Your Form.
Step 7: Add Dialog Components to Your Form
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

To enable your program to open picture files and choose a background color, in this step, you add an
OpenFileDialog component and a ColorDialog component to your form.
A component is like a control in some ways. You use the Toolbox to add a component to your form, and you set its
properties using the Proper ties window. But unlike a control, adding a component to your form doesn't add a
visible item that the user can see on the form. Instead, it provides certain behaviors that you can trigger with code.
It's a component that opens an Open File dialog box.
For a video version of this topic, see Tutorial 1: Create a Picture Viewer in Visual Basic - Video 3 or Tutorial 1:
Create a Picture Viewer in C# - Video 3. These videos use an earlier version of Visual Studio, so there are slight
differences in some menu commands and other user interface elements. However, the concepts and procedures
work similarly in the current version of Visual Studio.
To add dialog components to your form
1. Choose the Windows Forms Designer (Form1.cs [Design] or Form1.vb [Design]) and then open the Dialogs
group in the Toolbox.

NOTE
The Dialogs group in the Toolbox has components that open many useful dialog boxes for you, which can be used
for opening and saving files, browsing folders, and choosing fonts and colors. You use two dialog components in this
project: OpenFileDialog and ColorDialog .

2. To add a component called openFileDialog1 to your form, double-click OpenFileDialog . To add a


component called colorDialog1 to your form, double-click ColorDialog in the Toolbox. (You use that one
in the next tutorial step.) You should see an area at the bottom of Windows Forms Designer (beneath the
Picture Viewer form) that has an icon for each of the two dialog components that you added, as shown in
the following picture.

Dialog components
3. Choose the openFileDialog1 icon in the area at the bottom of the Windows Forms Designer. Set two
properties:
Set the Filter property to the following (you can copy and paste it):

JPEG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png|BMP Files (*.bmp)|*.bmp|All files (*.*)|*.*

Set the Title property to the following: Select a picture file


The Filter property settings specify the kinds of file types that will display in the Select a picture
file dialog box.
NOTE
To see an example of the Open File dialog box in a different application, open Notepad or Paint, and on the menu
bar, choose File , Open . Notice how there's a Files of type drop-down list at the bottom. You just used the Filter
property in the OpenFileDialog component to set that up. Also, notice how the Title and Filter properties are
bold in the Proper ties window. The IDE does that to show you any properties that have been changed from their
default values.

To continue or review
To go to the next tutorial step, see Step 8: Write Code for the Show a Picture Button Event Handler.
To return to the previous tutorial step, see Step 6: Name Your Button Controls.
Step 8: Write Code for the Show a Picture Button
Event Handler
1/10/2020 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In this step, you make the Show a picture button work like this:
When a user chooses that button, the program opens an Open File dialog box.
If a user opens a picture file, the program shows that picture in the PictureBox.
The IDE has a powerful tool called IntelliSense that helps you write code. As you enter code, the IDE opens a
box with suggested completions for partial words that you enter. It tries to determine what you want to do
next, and automatically jumps to the last item you choose from the list. You can use the up or down arrows
to move in the list, or you can keep typing letters to narrow the choices. When you see the choice you want,
choose the TAB key to select it. Or, you can ignore the suggestions, if not needed.
For a video version of this topic, see Tutorial 1: Create a Picture Viewer in Visual Basic - Video 4 or
Tutorial 1: Create a Picture Viewer in C# - Video 4. These videos use an earlier version of Visual Studio, so
there are slight differences in some menu commands and other user interface elements. However, the
concepts and procedures work similarly in the current version of Visual Studio.
To write code for the Show a picture button event handler
1. Go to Windows Forms Designer and double-click the Show a picture button. The IDE immediately goes to
the code designer and moves your cursor so it's inside the showButton_Click() method that you added
previously.
2. Type an i on the empty line between the two braces { }. (In Visual Basic, type on the empty line between
Private Sub… and End Sub.) An IntelliSense window opens, as shown in the following picture.

IntelliSense with Visual C# code


3. The IntelliSense window should be highlighting the word if . (If not, enter a lowercase f , and it will.)
Notice how a little tooltip box next to the IntelliSense window appears with the description, Code snippet
for if statement . (In Visual Basic, the tooltip also states that this is a snippet, but with slightly different
wording.) You want to use that snippet, so choose the TAB key to insert if into your code. Then choose the
TAB key again to use the if snippet. (If you chose somewhere else and your IntelliSense window
disappeared, backspace over the i and retype it, and the IntelliSense window opens again.)

Visual C# code
4. Next, you use IntelliSense to enter more code to open an Open File dialog box. If the user chose the OK
button, the PictureBox loads the file that the user selected. The following steps show how to enter the code,
and although it's numerous steps, it's just a few keystrokes:
a. Start with the selected text true in the snippet. Type op to overwrite it. (In Visual Basic, you start
with an initial cap, so type Op .)
b. The IntelliSense window opens and displays openFileDialog1 . Choose the TAB key to select it. (In
Visual Basic, it starts with an initial cap, so you see OpenFileDialog1 . Ensure that
OpenFileDialog1 is selected.)
To learn more about OpenFileDialog , see OpenFileDialog.
c. Type a period ( . ) (Many programmers call this a dot.) Because you typed a dot right after
openFileDialog1 , an IntelliSense window opens, filled in with all of the OpenFileDialog
component's properties and methods. These are the same properties that appear in the Proper ties
window when you choose it in Windows Forms Designer. You can also choose methods that tell the
component to do things (like open a dialog box).

NOTE
The IntelliSense window can show you both properties and methods. To determine what is being shown,
look at the icon on the left side of each item in the IntelliSense window. You see a picture of a block next to
each method, and a picture of a wrench (or spanner) next to each property. There's also a lightning bolt icon
next to each event. These pictures display as follows.

Method icon
Property icon
Event icon
d. Start to type ShowDialog (capitalization is unimportant to IntelliSense). The ShowDialog() method
will show the Open File dialog box. After the window has highlighted ShowDialog , choose the TAB
key. You can also highlight “ShowDialog” and choose the F1 key to get help for it.
To learn more about the ShowDialog() method, see ShowDialog Method.
e. When you use a method on a control or a component (referred to as calling a method), you need to
add parentheses. So enter opening and closing parentheses immediately after the "g" in ShowDialog :
() It should now look like "openFileDialog1.ShowDialog()".
NOTE
Methods are an important part of any program, and this tutorial has shown several ways to use methods.
You can call a component's method to tell it to do something, like how you called the OpenFileDialog
component's ShowDialog() method. You can create your own methods to make your program do things,
like the one you're building now, called the showButton_Click() method, which opens a dialog box and a
picture when a user chooses a button.

f. For Visual C#, add a space, and then add two equal signs ( == ). For Visual Basic, add a space, and
then use a single equal sign ( = ). (Visual C# and Visual Basic use different equality operators.)
g. Add another space. As soon as you do, another IntelliSense window opens. Start to type
DialogResult and choose the TAB key to add it.

NOTE
When you write code to call a method, sometimes it returns a value. In this case, the OpenFileDialog
component's ShowDialog() method returns a DialogResult value. DialogResult is a special value that tells
you what happened in a dialog box. An OpenFileDialog component can result in the user choosing OK or
Cancel, so its ShowDialog() method returns either DialogResult.OK or DialogResult.Cancel.

h. Type a dot to open the DialogResult value IntelliSense window. Enter the letter O and choose the
TAB key to insert OK .
To learn more about DialogResult , see DialogResult.

NOTE
The first line of code should be complete. For Visual C#, it should be the following.
if (openFileDialog1.ShowDialog() == DialogResult.OK)

For Visual Basic, it should be the following.


If OpenFileDialog1.ShowDialog() = DialogResult.OK Then

i. Now add one more line of code. You can type it (or copy and paste it), but consider using IntelliSense
to add it. The more familiar you are with IntelliSense, the more quickly you can write your own code.
Your final showButton_Click() method looks like the following. (Choose the VB tab to view the Visual
Basic version of the code.)

private void showButton_Click(object sender, EventArgs e)


{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox1.Load(openFileDialog1.FileName);
}
}

Private Sub showButton_Click() Handles showButton.Click


If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
PictureBox1.Load(OpenFileDialog1.FileName)
End If

End Sub
To continue or review
To go to the next tutorial step, see Step 9: Review, Comment, and Test Your Code.
To return to the previous tutorial step, see Step 7: Add Dialog Components to Your Form.
Step 9: Review, Comment, and Test Your Code
1/10/2020 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You next add a comment to your code. A comment is a note that doesn't change the way the program behaves. It
makes it easier for someone who is reading your code to understand what it does. Adding comments to your code
is a good habit to get into. In Visual C#, two forward slashes (//) mark a line as a comment. In Visual Basic, a single
quotation mark (') is used to mark a line as a comment. After you add a comment, you test your program. It's good
practice to run and test your code frequently while you're working on your projects, so you can catch and fix any
problems early, before the code gets more complicated. This is called iterative testing.
You just built something that works, and although it's not done yet, it can already load a picture. Before you add a
comment to your code and test it, take time to review the code concepts, because you will use these concepts
frequently:
When you double-clicked the Show a picture button in Windows Forms Designer, the IDE automatically
added a method to your program's code.
Methods are how you organize your code: It's how your code is grouped together.
Most of the time, a method does a small number of things in a specific order, like how your
showButton_Click() method shows a dialog box and then loads a picture.

A method is made up of code statements, or lines of code. Think of a method as a way to bundle code
statements together.
When a method is executed, or called, the statements in the method are executed in order, one after another,
starting with the first one.
The following is an example of a statement.

pictureBox1.Load(openFileDialog1.FileName);

pictureBox1.Load(openFileDialog1.FileName)

Statements are what make your programs do things. In Visual C#, a statement always ends in a semicolon.
In Visual Basic, the end of a line is the end of a statement. (No semicolon is needed in Visual Basic.) The
preceding statement tells your PictureBox control to load the file that the user selected with the
OpenFileDialog component.
For a video version of this topic, see Tutorial 1: Create a Picture Viewer in Visual Basic - Video 5 or
Tutorial 1: Create a Picture Viewer in C# - Video 5. These videos use an earlier version of Visual Studio, so
there are slight differences in some menu commands and other user interface elements. However, the
concepts and procedures work similarly in the current version of Visual Studio.
To add comments
1. Add the following comment to your code.

private void showButton_Click(object sender, EventArgs e)


{
// Show the Open File dialog. If the user clicks OK, load the
// picture that the user chose.
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox1.Load(openFileDialog1.FileName);
}
}

Private Sub showButton_Click() Handles showButton.Click

' Show the Open File dialog. If the user clicks OK, load the
' picture that the user chose.
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
PictureBox1.Load(OpenFileDialog1.FileName)
End If

End Sub

NOTE
Your showButton button's Click event handler is now finished, and it works. You have started writing code, starting
with an if statement. An if statement is how you tell your program, "Check this one thing, and if it's true, do
these actions." In this case, you tell your program to open the Open File dialog box, and if the user selects a file and
chooses the OK button, load that file in the PictureBox.

TIP
The IDE is built to make it easy for you to write code, and code snippets are one way it does that. A snippet is a
shortcut that gets expanded into a small block of code.
You can see all of the snippets available. On the menu bar, choose Tools , Code Snippets Manager . For Visual C#,
the if snippet is in Visual C# . For Visual Basic, the if snippets are in Conditionals and Loops , Code
Patterns . You can use this manager to browse existing snippets or add your own snippets.
To activate a snippet when typing code, type it and choose the TAB key. Many snippets appear in the IntelliSense
window, which is why you choose the TAB key twice: first to select the snippet from the IntelliSense window, and
then to tell the IDE to use the snippet. (IntelliSense supports the if snippet, but not the ifelse snippet.)

2. Before you run your program, save your program by choosing the Save All toolbar button, which appears
as follows.
Save All button
Alternatively, to save your program, on the menu bar, choose File , Save All . It's a best practice to save early
and often.
When it's running, your program should look like the following picture.
Picture Viewer
To test your program
1. Choose the F5 key or choose the Star t Debugging toolbar button.
2. Choose the Show a picture button to run the code you just wrote. First, the program opens an Open File
dialog box. Verify that your filters appear in the Files of type drop-down list at the bottom of the dialog
box. Then navigate to a picture and open it. You can usually find sample pictures that ship with the Windows
operating system in your My Documents folder, inside the My Pictures\Sample Pictures folder.

NOTE
If you don't see any images in the Select a picture file dialog box, be sure that the "All files (*.*)" filter is selected in
the drop-down list on the lower right side of the dialog box.

3. Load a picture, and it appears in your PictureBox. Then try resizing your form by dragging its borders.
Because you have your PictureBox docked inside a TableLayoutPanel, which itself is docked inside the form,
your picture area will resize itself so that it's as wide as the form, and fills the top 90 percent of the form.
That's why you used the TableLayoutPanel and FlowLayoutPanel containers: They keep your form sized
correctly when the user resizes it.
Right now, larger pictures go beyond the borders of your picture viewer. In the next step, you'll add code to
make pictures fit in the window.
To continue or review
To go to the next tutorial step, see Step 10: Write Code for Additional Buttons and a Check Box.
To return to the previous tutorial step, see Step 8: Write Code for the Show a Picture Button Event Handler.
Step 10: Write Code for Additional Buttons and a
Check Box
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Now you're ready to complete the other four methods. You could copy and paste this code, but if you want to learn
the most from this tutorial, type the code and use IntelliSense.
This code adds functionality to the buttons you added earlier. Without this code, the buttons don't do anything. The
buttons use code in their Click events (and the check box uses the CheckChanged event) to do different things
when you activate the controls. For example, the clearButton_Click event, which activates when you choose the
Clear the picture button, erases the current image by setting its Image property to null (or, nothing ). Each
event in the code includes comments that explain what the code does.
For a video version of this topic, see Tutorial 1: Create a Picture Viewer in Visual Basic - Video 5 or Tutorial 1:
Create a Picture Viewer in C# - Video 5. These videos use an earlier version of Visual Studio, so there are slight
differences in some menu commands and other user interface elements. However, the concepts and procedures
work similarly in the current version of Visual Studio.

NOTE
As a best practice: Always comment your code. Comments are information for a person to read, and it's worth the time to
make your code understandable. Everything on a comment line is ignored by the program. In Visual C#, you comment a line
by typing two forward slashes at the beginning (//), and in Visual Basic you comment a line by starting with a single
quotation mark (').

To write code for additional buttons and a check box


Add the following code to your Form1 code file (Form1.cs or Form1.vb). Choose the VB tab to view Visual
Basic code.
private void clearButton_Click(object sender, EventArgs e)
{
// Clear the picture.
pictureBox1.Image = null;
}

private void backgroundButton_Click(object sender, EventArgs e)


{
// Show the color dialog box. If the user clicks OK, change the
// PictureBox control's background to the color the user chose.
if (colorDialog1.ShowDialog() == DialogResult.OK)
pictureBox1.BackColor = colorDialog1.Color;
}

private void closeButton_Click(object sender, EventArgs e)


{
// Close the form.
this.Close();
}

private void checkBox1_CheckedChanged(object sender, EventArgs e)


{
// If the user selects the Stretch check box,
// change the PictureBox's
// SizeMode property to "Stretch". If the user clears
// the check box, change it to "Normal".
if (checkBox1.Checked)
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
else
pictureBox1.SizeMode = PictureBoxSizeMode.Normal;
}

Private Sub clearButton_Click() Handles clearButton.Click


' Clear the picture.
PictureBox1.Image = Nothing
End Sub

Private Sub backgroundButton_Click() Handles backgroundButton.Click


' Show the color dialog box. If the user clicks OK, change the
' PictureBox control's background to the color the user chose.
If ColorDialog1.ShowDialog() = DialogResult.OK Then
PictureBox1.BackColor = ColorDialog1.Color
End If
End Sub

Private Sub closeButton_Click() Handles closeButton.Click


' Close the form.
Close()
End Sub

Private Sub CheckBox1_CheckedChanged() Handles CheckBox1.CheckedChanged


' If the user selects the Stretch check box, change
' the PictureBox's SizeMode property to "Stretch". If the user
' clears the check box, change it to "Normal".
If CheckBox1.Checked Then
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
Else
PictureBox1.SizeMode = PictureBoxSizeMode.Normal
End If
End Sub

To continue or review
To go to the next tutorial step, see Step 11: Run Your Program and Try Other Features.
To return to the previous tutorial step, see Step 9: Review, Comment, and Test Your Code.
Step 11: Run Your Program and Try Other Features
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Your program is finished and ready to run. You can run your program and set the background color of the
PictureBox. To learn more, try to improve the program by changing the color of the form, customizing the buttons
and check box, and changing the properties of the form.
For a video version of this topic, see Tutorial 1: Create a Picture Viewer in Visual Basic - Video 5 or Tutorial 1:
Create a Picture Viewer in C# - Video 5. These videos use an earlier version of Visual Studio, so there are slight
differences in some menu commands and other user interface elements. However, the concepts and procedures
work similarly in the current version of Visual Studio.
To run your program and set the background color
1. Choose F5, or on the menu bar, choose Debug , Star t Debugging .
2. Before you open a picture, choose the Set the background color button. The Color dialog box opens.

Color dialog box


3. Choose a color to set the PictureBox background color. Look closely at the backgroundButton_Click()
method to understand how it works.

NOTE
You can load a picture from the Internet by pasting its URL into the Open File dialog box. Try to find an image with
a transparent background, so your background color shows.

4. Choose the Clear the picture button to make sure it clears. Then, exit the program by choosing the Close
button.
To try other features
Change the color of the form and the buttons by using the BackColor property.
Customize your buttons and check box using the Font and ForeColor properties.
Change your form's FormBorderStyle and ControlBox properties.
Use your form's AcceptButton and CancelButton properties so that buttons are automatically chosen
when the user chooses the ENTER or ESC key. Make the program open the Open File dialog box when the
user chooses ENTER and close the box when the user chooses ESC.
To continue or review
To learn more about programming in Visual Studio, see Programming Concepts.
To learn more about Visual Basic, see Developing Applications with Visual Basic.
To learn more about Visual C#, see Introduction to the C# Language and the .NET Framework.
To go to the next tutorial, see Tutorial 2: Create a Timed Math Quiz.
To return to the previous tutorial step, see Step 10: Write Code for Additional Buttons and a Check Box.
Tutorial 2: Create a Timed Math Quiz
11/21/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In this tutorial, you build a quiz in which the quiz taker must answer four random arithmetic problems within a
specified time. You learn how to:
Generate random numbers by using the Random class.
Trigger events to occur at a specific time by using a Timer control.
Control program flow by using if else statements.
Perform basic arithmetic operations in code.
When you finish, your quiz will look like the following picture, except with different numbers.

Quiz that you create in this tutorial

NOTE
This tutorial covers both Visual C# and Visual Basic, so focus on the information that's specific to the programming
language that you're using.

Related Topics
T IT L E DESC RIP T IO N

Step 1: Create a Project and Add Labels to Your Form Start by creating the project, changing properties, and adding
Label controls.

Step 2: Create a Random Addition Problem Create an addition problem, and use the Random class to
generate random numbers.

Step 3: Add a Countdown Timer Add a countdown timer so that the quiz can be timed.
T IT L E DESC RIP T IO N

Step 4: Add the CheckTheAnswer() Method Add a method to check whether the quiz taker entered a
correct answer for the problem.

Step 5: Add Enter Event Handlers for the NumericUpDown Add event handlers that make your quiz easier to take.
Controls

Step 6: Add a Subtraction Problem Add a subtraction problem that generates random numbers,
uses the timer, and checks for correct answers.

Step 7: Add Multiplication and Division Problems Add multiplication and division problems that generate
random numbers, use the timer, and check for correct
answers.

Step 8: Customize the Quiz Try other features, such as changing colors and adding a hint.
Step 1: Create a Project and Add Labels to Your Form
10/18/2019 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

As the first steps in developing this quiz, you create the project, and you add labels, a button, and other controls to
a form. You also set properties for each control that you add. The project will contain the form, the controls, and
(later in the tutorial) code. The button starts the quiz, the labels show the quiz problems, and the other controls
show the quiz answers and the time that remains to finish the quiz.

NOTE
This topic is part of a tutorial series about basic coding concepts. For an overview of the tutorial, see Tutorial 2: Create a
Timed Math Quiz.

To create a project and set properties for a form


1. On the menu bar, choose File , New , Project .
2. In the Installed Templates list, choose either C# or Visual Basic .
3. In the list of templates, choose the Windows Forms Application template, name it Math Quiz , and then
choose the OK button.
A form that's named Form1.cs or Form1.vb appears, depending on the programming language that you
chose.
4. Choose the form, and then change its Text property to Math Quiz .
The Proper ties window contains properties for the form.
5. Change the size of the form to 500 pixels wide by 400 pixels tall.
You can resize the form by dragging its edges until the correct size appears in the lower-left corner of the
integrated development environment (IDE). As an alternative, you can change the values of the Size
property.
6. Change the value of the FormBorderStyle property to Fixed3D , and set the MaximizeBox property to
False .
These values prevent quiz takers from resizing the form.
To create the Time Remaining box
1. Add a Label control from the Toolbox, and then set the value of its (Name) property to timeLabel .
This label will become a box in the upper-right corner that shows the number of seconds that remain in the
quiz.
2. Change the AutoSize property to False so that you can resize the box.
3. Change the BorderStyle property to FixedSingle to draw a line around the box.
4. Set the Size property to 200, 30 .
5. Move the label to the upper-right corner of the form, where blue spacer lines will appear.
These lines help you align controls on the form.
6. In the Proper ties window, choose the Text property, and then choose the Backspace key to clear its value.
7. Choose the plus sign (+) next to the Font property, and then change the value of the Size property to
15.75 .
You can change several font properties, as the following picture shows.

Properties window showing font size


8. Add another Label control from the Toolbox, and then set its font size to 15.75 .
9. Set the Text property to Time Left .
10. Move the label so that it lines up just to the left of the timeLabel label.
To add controls for the addition problems
1. Add a Label control from the Toolbox, and then set its Text property to ? (question mark).
2. Set the AutoSize property to False .
3. Set the Size property to 60, 50 .
4. Set the font size to 18 .
5. Set the TextAlign property to MiddleCenter .
6. Set the Location property to 50, 75 to position the control on the form.
7. Set the (Name) property to plusLeftLabel .
8. Choose the plusLeftLabel label, and then choose either the Ctrl+C keys or Copy on the Edit menu.
9. Paste the label three times by choosing either the Ctrl+V keys or Paste on the Edit menu.
10. Arrange the three new labels so that they are in a row to the right of the plusLeftLabel label.
You can use the spacer lines to space them out and line them up.
11. Set the value of the second label's Text property to + (plus sign).
12. Set the value of the third label's (Name) property to plusRightLabel .
13. Set the value of the fourth label's Text property to = (equal sign).
14. Add a NumericUpDown control from the Toolbox, set its font size to 18 , and set its width to 100 .
You'll learn more about this kind of control later.
15. Line up the NumericUpDown control with the label controls for the addition problem.
16. Change the value of the (Name) property for the NumericUpDown control to sum .
You've created the first row, as the following picture shows.

First row of math quiz


To add controls for the subtraction, multiplication, and division problems
1. Copy all five controls for the addition problem (the four Label controls and the NumericUpDown control),
and then paste them.
The form contains five new controls, which are still selected.
2. Move all of the controls into place so that they line up below the addition controls.
You can use the spacer lines to give enough distance between the two rows.
3. Change the value of the Text property for the second label to – (minus sign).
4. Name the first question-mark label minusLeftLabel .
5. Name the second question-mark label minusRightLabel .
6. Name the NumericUpDown control difference .
7. Paste the five controls two more times.
8. For the third row, name the first label timesLeftLabel , change the second label's Text property to ×
(multiplication sign), name the third label timesRightLabel , and name the NumericUpDown control
product .
9. For the fourth row, name the first label dividedLeftLabel , change the second label's Text property to ÷
(division sign), name the third label dividedRightLabel , and name the NumericUpDown control quotient .

NOTE
You can copy the multiplication sign × and the division sign ÷ from this tutorial and paste them onto the form.

To add a start button and set the tab-index order


1. Add a Button control from the Toolbox, and then set its (Name) property to star tButton .
2. Set the Text property to Star t the quiz .
3. Set the font size to 14 .
4. Set the AutoSize property to True , which causes the button to automatically resize to fit the text.
5. Center the button near the bottom of the form.
6. Set the value of the TabIndex property for the star tButton control to 1 .
NOTE
The TabIndex property sets the order of the controls when the quiz taker chooses the Tab key. To see how it works,
open any dialog box (for example, on the menu bar, choose File , Open ), and then choose the Tab key a few times.
Watch how your cursor moves from control to control each time that you choose the Tab key. A programmer decided
the order when creating that form.

7. Set the value of the TabIndex property for the NumericUpDown sum control to 2 , for the difference control
to 3 , for the product control to 4 , and for the quotient control to 5 .
The form should look like the following illustration.

Initial math quiz form


8. To verify whether the TabIndex property works as you expect, save and run your program by choosing the
F5 key, or by choosing Debug , Star t Debugging on the menu bar, and then choose the Tab key a few
times.
To continue or review
To go to the next tutorial step, see Step 2: Create a Random Addition Problem.
To return to the overview topic, see Tutorial 2: Create a Timed Math Quiz.
Step 2: Create a Random Addition Problem
10/18/2019 • 6 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In the second part of this tutorial, you make the quiz challenging by adding math problems that are based on
random numbers. You also create a method that's named StartTheQuiz() and that fills in the problems and starts
the countdown timer. Later in this tutorial, you'll add the subtraction, multiplication, and division problems.

NOTE
This topic is part of a tutorial series about basic coding concepts. For an overview of the tutorial, see Tutorial 2: Create a
Timed Math Quiz.

To create a random addition problem


1. In the form designer, choose the form (Form1).
2. On the menu bar, choose View , Code .
Form1.cs or Form1.vb appears, depending on the programming language that you're using, so that you can
view the code behind the form.
3. Create a Random object by adding a new statement near the top of the code, like the following.

public partial class Form1 : Form


{
// Create a Random object called randomizer
// to generate random numbers.
Random randomizer = new Random();

Public Class Form1

' Create a Random object called randomizer


' to generate random numbers.
Private randomizer As New Random

You've added a Random object to your form and named the object randomizer .
Random is known as an object. You've probably heard that word before, and you learn more about what it
means for programming in the next tutorial. For now, just remember that you can use new statements to
create buttons, labels, panels, OpenFileDialogs, ColorDialogs, SoundPlayers, Randoms, and even forms, and
those items are referred to as objects. When you run your program, the form is started, and the code
behind it creates a Random object and names it randomizer .
Soon you'll build a method to check the answers, so your quiz must use variables to store the random
numbers that it generates for each problem. See Variables or Types. To properly use variables, you must
declare them, which means listing their names and data types.
4. Add two integer variables to the form, and name them addend1 and addend2 .

NOTE
An integer variable is known as an int in C# or an Integer in Visual Basic. This kind of variable stores a positive or
negative number from -2147483648 through 2147483647 and can store only whole numbers, not decimals.

You use a similar syntax to add an integer variable as you did to add the Random object, as the following
code shows.

// Create a Random object called randomizer


// to generate random numbers.
Random randomizer = new Random();

// These integer variables store the numbers


// for the addition problem.
int addend1;
int addend2;

' Create a Random object called randomizer


' to generate random numbers.
Private randomizer As New Random

' These integer variables store the numbers


' for the addition problem.
Private addend1 As Integer
Private addend2 As Integer

5. Add a method that's named StartTheQuiz() and that uses the Random object's Next() method to show the
random numbers in the labels. StartTheQuiz() will eventually fill in all of the problems and then start the
timer, so add a comment. The function should look like the following.

/// <summary>
/// Start the quiz by filling in all of the problems
/// and starting the timer.
/// </summary>
public void StartTheQuiz()
{
// Fill in the addition problem.
// Generate two random numbers to add.
// Store the values in the variables 'addend1' and 'addend2'.
addend1 = randomizer.Next(51);
addend2 = randomizer.Next(51);

// Convert the two randomly generated numbers


// into strings so that they can be displayed
// in the label controls.
plusLeftLabel.Text = addend1.ToString();
plusRightLabel.Text = addend2.ToString();

// 'sum' is the name of the NumericUpDown control.


// This step makes sure its value is zero before
// adding any values to it.
sum.Value = 0;
}
''' <summary>
''' Start the quiz by filling in all of the problems
''' and starting the timer.
''' </summary>
''' <remarks></remarks>
Public Sub StartTheQuiz()
' Fill in the addition problem.
' Generate two random numbers to add.
' Store the values in the variables 'addend1' and 'addend2'.
addend1 = randomizer.Next(51)
addend2 = randomizer.Next(51)

' Convert the two randomly generated numbers


' into strings so that they can be displayed
' in the label controls.
plusLeftLabel.Text = addend1.ToString()
plusRightLabel.Text = addend2.ToString()

' 'sum' is the name of the NumericUpDown control.


' This step makes sure its value is zero before
' adding any values to it.
sum.Value = 0
End Sub

Notice that when you enter the dot (.) after randomizer in the code, an IntelliSense window opens and
shows you all of the Random object's methods that you can call. For example, Intellisense lists the Next()
method, as follows.

Next
method
When you enter a dot after an object, IntelliSense shows a list of the object's members, such as properties,
methods, and events.

NOTE
When you use the Next() method with the Random object, such as when you call randomizer.Next(50) , you
get a random number that's less than 50 (from 0 through 49). In this example, you called randomizer.Next(51) .
You used 51 and not 50 so that the two random numbers will add up to an answer that's from 0 through 100. If you
pass 50 to the Next() method, it chooses a number from 0 through 49, so the highest possible answer is 98, not
100. After the first two statements in the method run, each of the two integer variables, addend1 and addend2 ,
hold a random number from 0 through 50. This screenshot shows Visual C# code, but IntelliSense works the same
way for Visual Basic.

Take a closer look at these statements.

plusLeftLabel.Text = addend1.ToString();
plusRightLabel.Text = addend2.ToString();
' Convert the two randomly generated numbers
' into strings so that they can be displayed
' in the label controls.
plusLeftLabel.Text = addend1.ToString()
plusRightLabel.Text = addend2.ToString()

The statements set the Text properties of plusLeftLabel and plusRightLabel so that they display the two
random numbers. You must use the integer's ToString() method to convert the numbers to text. (In
programming, string means text. Label controls display only text, not numbers.
6. In the design window, either double-click the Star t button, or choose it and then choose the Enter key.
When a quiz taker chooses this button, the quiz should start, and you've just added a Click event handler to
implement that behavior.
7. Add the following two statements.

private void startButton_Click(object sender, EventArgs e)


{
StartTheQuiz();
startButton.Enabled = false;
}

' Call the StartTheQuiz() method and enable


' the Start button.
Private Sub startButton_Click() Handles startButton.Click
StartTheQuiz()
startButton.Enabled = False
End Sub

The first statement calls the new StartTheQuiz() method. The second statement sets the Enabled property
of the star tButton control to False so that the quiz taker can't choose the button during a quiz.
8. Save your code, run it, and then choose the Star t button.
A random addition problem appears, as the following illustration shows.

Random addition problem


In the next step of the tutorial, you'll add the sum.
To continue or review
To go to the next tutorial step, see Step 3: Add a Countdown Timer.
To return to the previous tutorial step, see Step 1: Create a Project and Add Labels to Your Form.
Step 3: Add a Countdown Timer
10/18/2019 • 6 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In the third part of this tutorial, you'll add a countdown timer to track the number of seconds that remain for the
quiz taker to finish.

NOTE
This topic is part of a tutorial series about basic coding concepts. For an overview of the tutorial, see Tutorial 2: Create a
Timed Math Quiz.

To add a countdown timer


1. Add an integer variable that's named timeLeft , just like you did in the previous procedure. Your code
should look like the following.

public partial class Form1 : Form


{
// Create a Random object called randomizer
// to generate random numbers.
Random randomizer = new Random();

// These integer variables store the numbers


// for the addition problem.
int addend1;
int addend2;

// This integer variable keeps track of the


// remaining time.
int timeLeft;

Public Class Form1

' Create a Random object called randomizer


' to generate random numbers.
Private randomizer As New Random

' These integer variables store the numbers


' for the addition problem.
Private addend1 As Integer
Private addend2 As Integer

' This integer variable keeps track of the


' remaining time.
Private timeLeft As Integer

Now you need a method that actually counts the seconds, such as a timer, which raises an event after the
amount of time that you specify.
2. In the design window, move a Timer control from the Components category of the Toolbox to your form.
The control appears in the gray area at the bottom of the design window.
3. On the form, choose the timer1 icon that you just added, and set its Inter val property to 1000 .
Because the interval value is milliseconds, a value of 1000 causes the Tick event to fire every second.
4. On the form, double-click the Timer control, or choose it and then choose the Enter key.
The code editor appears and displays the method for the Tick event handler that you just added.
5. Add the following statements to the new event handler method.

private void timer1_Tick(object sender, EventArgs e)


{
if (timeLeft > 0)
{
// Display the new time left
// by updating the Time Left label.
timeLeft = timeLeft - 1;
timeLabel.Text = timeLeft + " seconds";
}
else
{
// If the user ran out of time, stop the timer, show
// a MessageBox, and fill in the answers.
timer1.Stop();
timeLabel.Text = "Time's up!";
MessageBox.Show("You didn't finish in time.", "Sorry!");
sum.Value = addend1 + addend2;
startButton.Enabled = true;
}
}

Private Sub Timer1_Tick() Handles Timer1.Tick

If timeLeft > 0 Then


' Display the new time left
' by updating the Time Left label.
timeLeft -= 1
timeLabel.Text = timeLeft & " seconds"
Else
' If the user ran out of time, stop the timer, show
' a MessageBox, and fill in the answers.
Timer1.Stop()
timeLabel.Text = "Time's up!"
MessageBox.Show("You didn't finish in time.", "Sorry!")
sum.Value = addend1 + addend2
startButton.Enabled = True
End If

End Sub

Based on what you added, the timer checks each second whether time has run out by determining whether
the timeLeft integer variable is greater than 0. If it is, time still remains. The timer first subtracts 1 from
timeLeft and then updates the Text property of the timeLabel control to show the quiz taker how many
seconds remain.
If no time remains, the timer stops and changes the text of the timeLabel control so that it shows Time's
up! A message box announces that the quiz is over, and the answer is revealed—in this case, by adding
addend1 and addend2. The Enabled property of the startButton control is set to true so that the quiz
taker can start another quiz.
You just added an if else statement, which is how you tell programs to make decisions. An if else
statement looks like the following.

NOTE
The following example is for illustration only–don't add it to your project.

If (something that your program will check) Then


' One or more statements that will run
' if what the program checked is true.
Else
' One or more statements that will run
' if what the program checked is false.
End If

if (something that your program will check)


{
// One or more statements that will run
// if what the program checked is true.
}
else
{
// One or more statements that will run
// if what the program checked is false.
}

Look closely at the statement that you added in the else block to show the answer to the addition
problem.

sum.Value = addend1 + addend2;

sum.Value = addend1 + addend2

The statement addend1 + addend2 adds the values in the two variables together. The first part ( sum.Value )
uses the Value property of the sum NumericUpDown control to display the correct answer. You use the same
property later to check the answers for the quiz.
Quiz takers can enter numbers more easily by using a NumericUpDown control, which is why you use one for
the answers to the math problems. All of the potential answers are whole numbers from 0 through 100. By
leaving the default values of the Minimum , Maximum , and DecimalPlaces properties, you ensure that
quiz takers can't enter decimals, negative numbers, or numbers that are too high. (If you wanted to allow
quiz takers to enter 3.141 but not 3.1415, you could set the DecimalPlaces property to 3.)
6. Add three lines to the end of the StartTheQuiz() method, so the code looks like the following.
/// <summary>
/// Start the quiz by filling in all of the problem
/// values and starting the timer.
/// </summary>
public void StartTheQuiz()
{
// Fill in the addition problem.
// Generate two random numbers to add.
// Store the values in the variables 'addend1' and 'addend2'.
addend1 = randomizer.Next(51);
addend2 = randomizer.Next(51);

// Convert the two randomly generated numbers


// into strings so that they can be displayed
// in the label controls.
plusLeftLabel.Text = addend1.ToString();
plusRightLabel.Text = addend2.ToString();

// 'sum' is the name of the NumericUpDown control.


// This step makes sure its value is zero before
// adding any values to it.
sum.Value = 0;

// Start the timer.


timeLeft = 30;
timeLabel.Text = "30 seconds";
timer1.Start();
}

''' <summary>
''' Start the quiz by filling in all of the problem
''' values and starting the timer.
''' </summary>
''' <remarks></remarks>
Public Sub StartTheQuiz()

' Fill in the addition problem.


' Generate two random numbers to add.
' Store the values in the variables 'addend1' and 'addend2'.
addend1 = randomizer.Next(51)
addend2 = randomizer.Next(51)

' Convert the two randomly generated numbers


' into strings so that they can be displayed
' in the label controls.
plusLeftLabel.Text = addend1.ToString()
plusRightLabel.Text = addend2.ToString()

' 'sum' is the name of the NumericUpDown control.


' This step makes sure its value is zero before
' adding any values to it.
sum.Value = 0

' Start the timer.


timeLeft = 30
timeLabel.Text = "30 seconds"
Timer1.Start()

End Sub

Now, when your quiz starts, the timeLeft variable is set to 30 and the Text property of the timeLabel
control is set to 30 seconds. Then the Start() method of the Timer control starts the countdown. (The
quiz doesn't check the answer yet—that comes next.)
7. Save your program, run it, and then choose the Star t button on the form.
The timer starts to count down. When time runs out, the quiz ends, and the answer appears. The following
illustration shows the quiz in progress.

Math quiz in progress


To continue or review
To go to the next tutorial step, see Step 4: Add the CheckTheAnswer() Method.
To return to the previous tutorial step, see Step 2: Create a Random Addition Problem.
Step 4: Add the CheckTheAnswer() Method
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In the fourth part of this tutorial, you'll write a method, CheckTheAnswer() , that determines whether the answers to
the math problems are correct. This topic is part of a tutorial series about basic coding concepts. For an overview
of the tutorial, see Tutorial 2: Create a Timed Math Quiz.

NOTE
If you're following along in Visual Basic, you'll use the Function keyword instead of the usual Sub keyword because this
method returns a value. It's really that simple: a sub doesn't return a value, but a function does.

To verify whether the answers are correct


1. Add the CheckTheAnswer() method.
When this method is called, it adds the values of addend1 and addend2 and compares the result to the
value in the sum NumericUpDown control. If the values are equal, the method returns a value of true .
Otherwise, the method returns a value of false . Your code should look like the following.

/// <summary>
/// Check the answer to see if the user got everything right.
/// </summary>
/// <returns>True if the answer's correct, false otherwise.</returns>
private bool CheckTheAnswer()
{
if (addend1 + addend2 == sum.Value)
return true;
else
return false;
}

''' <summary>
''' Check the answer to see if the user got everything right.
''' </summary>
''' <returns>True if the answer's correct, false otherwise.</returns>
''' <remarks></remarks>
Public Function CheckTheAnswer() As Boolean

If addend1 + addend2 = sum.Value Then


Return True
Else
Return False
End If

End Function

Next, you'll check the answer by updating the code in the method for the timer's Tick event handler to call
the new CheckTheAnswer() method.
2. Add the following code to the if else statement.

private void timer1_Tick(object sender, EventArgs e)


{
if (CheckTheAnswer())
{
// If CheckTheAnswer() returns true, then the user
// got the answer right. Stop the timer
// and show a MessageBox.
timer1.Stop();
MessageBox.Show("You got all the answers right!",
"Congratulations!");
startButton.Enabled = true;
}
else if (timeLeft > 0)
{
// If CheckTheAnswer() return false, keep counting
// down. Decrease the time left by one second and
// display the new time left by updating the
// Time Left label.
timeLeft--;
timeLabel.Text = timeLeft + " seconds";
}
else
{
// If the user ran out of time, stop the timer, show
// a MessageBox, and fill in the answers.
timer1.Stop();
timeLabel.Text = "Time's up!";
MessageBox.Show("You didn't finish in time.", "Sorry!");
sum.Value = addend1 + addend2;
startButton.Enabled = true;
}
}

Private Sub Timer1_Tick() Handles Timer1.Tick

If CheckTheAnswer() Then
' If CheckTheAnswer() returns true, then the user
' got the answer right. Stop the timer
' and show a MessageBox.
Timer1.Stop()
MessageBox.Show("You got all of the answers right!", "Congratulations!")
startButton.Enabled = True
ElseIf timeLeft > 0 Then
' If CheckTheAnswer() return false, keep counting
' down. Decrease the time left by one second and
' display the new time left by updating the
' Time Left label.
timeLeft -= 1
timeLabel.Text = timeLeft & " seconds"
Else
' If the user ran out of time, stop the timer, show
' a MessageBox, and fill in the answers.
Timer1.Stop()
timeLabel.Text = "Time's up!"
MessageBox.Show("You didn't finish in time.", "Sorry!")
sum.Value = addend1 + addend2
startButton.Enabled = True
End If

End Sub
If the answer is correct, CheckTheAnswer() returns true . The event handler stops the timer, shows a
congratulatory message, and then makes the Star t button available again. Otherwise, the quiz continues.
3. Save your program, run it, start a quiz, and provide a correct answer to the addition problem.

NOTE
When you enter your answer, you must either select the default value before you start to enter your answer, or you
must delete the zero manually. You'll correct this behavior later in this tutorial.

When you provide a correct answer, a message box opens, the Star t button becomes available, and the
timer stops.
To continue or review
To go to the next tutorial step, see Step 5: Add Enter Event Handlers for the NumericUpDown Controls.
To return to the previous tutorial step, see Step 3: Add a Countdown Timer.
Step 5: Add Enter Event Handlers for the
NumericUpDown Controls
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In the fifth part of this tutorial, you'll add Enter event handlers to make entering answers for quiz problems a little
easier. This code will select and clear the current value in each NumericUpDown control as soon as the quiz taker
chooses it and starts to enter a different value.

NOTE
This topic is part of a tutorial series about basic coding concepts. For an overview of the tutorial, see Tutorial 2: Create a
Timed Math Quiz.

To verify the default behavior


1. Run your program, and start the quiz.
In the NumericUpDown control for the addition problem, the cursor flashes next to 0 (zero).
2. Enter 3 , and note that the control shows 30 .
3. Enter 5 , and note that 350 appears but changes to 100 after a second.
Before you fix this problem, think about what's happening. Consider why the 0 didn't disappear when you
entered 3 and why 350 changed to 100 but not immediately.
This behavior may seem odd, but it makes sense given the logic of the code. When you choose the Star t
button, its Enabled property is set to False , and the button appears dimmed and is unavailable. Your
program changes the current selection (focus) to the control that has the next lowest TabIndex value, which
is the NumericUpDown control for the addition problem. When you use the Tab key to go to a
NumericUpDown control, the cursor is automatically positioned at the start of the control, which is why the
numbers that you enter appear from the left side and not the right side. When you specify a number that's
higher than the value of the MaximumValue property, which is set to 100, the number that you enter is
replaced with the value of that property.
To add an Enter event handler for a NumericUpDown control
1. Choose the first NumericUpDown control (named "sum") on the form, and then, in the Proper ties dialog
box, choose the Events icon on the toolbar.
The Events tab in the Proper ties dialog box displays all of the events that you can respond to (handle) for
the item that you choose on the form. Because you chose the NumericUpDown control, all of the events
listed pertain to it.
2. Choose the Enter event, enter answer_Enter , and then choose the Enter key.
Properties dialog box
You've just added an Enter event handler for the sum NumericUpDown control, and you've named the
handler answer_Enter .
3. In the method for the answer_Enter event handler, add the following code.

private void answer_Enter(object sender, EventArgs e)


{
// Select the whole answer in the NumericUpDown control.
NumericUpDown answerBox = sender as NumericUpDown;

if (answerBox != null)
{
int lengthOfAnswer = answerBox.Value.ToString().Length;
answerBox.Select(0, lengthOfAnswer);
}
}

''' <summary>
''' Modify the behavior of the NumericUpDown control
''' to make it easier to enter numeric values for
''' the quiz.
''' </summary>
Private Sub answer_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sum.Enter

' Select the whole answer in the NumericUpDown control.


Dim answerBox = TryCast(sender, NumericUpDown)

If answerBox IsNot Nothing Then


Dim lengthOfAnswer = answerBox.Value.ToString().Length
answerBox.Select(0, lengthOfAnswer)
End If

End Sub

This code may look complex, but you can understand it if you look at it step by step. First, look at the top of
the method: object sender in C# or sender As System.Object in Visual Basic. This parameter refers to the
object whose event is firing, which is known as the sender. In this case, the sender object is the
NumericUpDown control. So, in the first line of the method, you specify that the sender isn't just any generic
object but specifically a NumericUpDown control. (Every NumericUpDown control is an object, but not
every object is a NumericUpDown control.) The NumericUpDown control is named answerBox in this
method, because it will be used for all of the NumericUpDown controls on the form, not just the sum
NumericUpDown control. Because you declare the answerBox variable in this method, its scope applies only
to this method. In other words, the variable can be used only within this method.
The next line verifies whether answerBox was successfully converted (cast) from an object to a
NumericUpDown control. If the conversion was unsuccessful, the variable would have a value of null (C#)
or Nothing (Visual Basic). The third line gets the length of the answer that appears in the NumericUpDown
control, and the fourth line selects the current value in the control based on this length. Now, when the quiz
taker chooses the control, Visual Studio fires this event, which causes the current answer to be selected. As
soon as the quiz taker starts to enter a different answer, the previous answer is cleared and replaced with
the new answer.
4. In Windows Forms Designer, choose the difference NumericUpDown control.
5. In the Events page of the Proper ties dialog box, scroll down to the Enter event, choose the drop-down
arrow at the end of the row, and then choose the answer_Enter event handler that you just added.
6. Repeat the previous step for the product and quotient NumericUpDown controls.
7. Save your program, and then run it.
When you choose a NumericUpDown control, the existing value is automatically selected and then cleared
when you start to enter a different value.
To continue or review
To go to the next tutorial step, see Step 6: Add a Subtraction Problem.
To return to the previous tutorial step, see Step 4: Add the CheckTheAnswer() Method.
Step 6: Add a Subtraction Problem
10/18/2019 • 6 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In the sixth part of this tutorial, you'll add a subtraction problem and learn how to perform the following tasks:
Store the subtraction values.
Generate random numbers for the problem (and be sure that the answer is between 0 and 100).
Update the method that checks the answers so that it checks the new subtraction problem too.
Update your timer's Tick event handler so that the event handler fills in the correct answer when time runs
out.
To add a subtraction problem
1. Add two integer variables for the subtraction problem to your form, between the integer variables for the
addition problem and the timer. The code should look like the following.

public partial class Form1 : Form


{
// Create a Random object called randomizer
// to generate random numbers.
Random randomizer = new Random();

// These integer variables store the numbers


// for the addition problem.
int addend1;
int addend2;

// These integer variables store the numbers


// for the subtraction problem.
int minuend;
int subtrahend;

// This integer variable keeps track of the


// remaining time.
int timeLeft;
Public Class Form1

' Create a Random object called randomizer


' to generate random numbers.
Private randomizer As New Random

' These integer variables store the numbers


' for the addition problem.
Private addend1 As Integer
Private addend2 As Integer

' These integer variables store the numbers


' for the subtraction problem.
Private minuend As Integer
Private subtrahend As Integer

' This integer variable keeps track of the


' remaining time.
Private timeLeft As Integer

The names of the new integer variables—minuend and subtrahend —aren't programming terms. They're
the traditional names in arithmetic for the number that's being subtracted (the subtrahend) and the number
from which the subtrahend is being subtracted (the minuend). The difference is the minuend minus the
subtrahend. You could use other names, because your program doesn't require specific names for variables,
controls, components, or methods. You must follow rules such as not starting names with digits, but you
can generally use names such as x1, x2, x3, and x4. However, generic names make code difficult to read and
problems nearly impossible to track down. To keep variable names unique and helpful, you'll use the
traditional names for multiplication (multiplicand × multiplier = product) and division (dividend ÷ divisor =
quotient) later in this tutorial.
Next, you'll modify the StartTheQuiz() method to provide random values for the subtraction problem.
2. Add the following code after the "Fill in the subtraction problem" comment.
/// <summary>
/// Start the quiz by filling in all of the problem
/// values and starting the timer.
/// </summary>
public void StartTheQuiz()
{
// Fill in the addition problem.
// Generate two random numbers to add.
// Store the values in the variables 'addend1' and 'addend2'.
addend1 = randomizer.Next(51);
addend2 = randomizer.Next(51);

// Convert the two randomly generated numbers


// into strings so that they can be displayed
// in the label controls.
plusLeftLabel.Text = addend1.ToString();
plusRightLabel.Text = addend2.ToString();

// 'sum' is the name of the NumericUpDown control.


// This step makes sure its value is zero before
// adding any values to it.
sum.Value = 0;

// Fill in the subtraction problem.


minuend = randomizer.Next(1, 101);
subtrahend = randomizer.Next(1, minuend);
minusLeftLabel.Text = minuend.ToString();
minusRightLabel.Text = subtrahend.ToString();
difference.Value = 0;

// Start the timer.


timeLeft = 30;
timeLabel.Text = "30 seconds";
timer1.Start();
}
''' <summary>
''' Start the quiz by filling in all of the problem
''' values and starting the timer.
''' </summary>
''' <remarks></remarks>
Public Sub StartTheQuiz()

' Fill in the addition problem.


' Generate two random numbers to add.
' Store the values in the variables 'addend1' and 'addend2'.
addend1 = randomizer.Next(51)
addend2 = randomizer.Next(51)

' Convert the two randomly generated numbers


' into strings so that they can be displayed
' in the label controls.
plusLeftLabel.Text = addend1.ToString()
plusRightLabel.Text = addend2.ToString()

' 'sum' is the name of the NumericUpDown control.


' This step makes sure its value is zero before
' adding any values to it.
sum.Value = 0

' Fill in the subtraction problem.


minuend = randomizer.Next(1, 101)
subtrahend = randomizer.Next(1, minuend)
minusLeftLabel.Text = minuend.ToString()
minusRightLabel.Text = subtrahend.ToString()
difference.Value = 0

' Start the timer.


timeLeft = 30
timeLabel.Text = "30 seconds"
Timer1.Start()

End Sub

To prevent negative answers for the subtraction problem, this code uses the Next() method of the Random
class a little differently from how the addition problem does. When you give the Next() method two
values, it picks a random number that's greater than or equal to the first value and less than the second one.
The following code chooses a random number from 1 through 100 and stores it in the minuend variable.

minuend = randomizer.Next(1, 101);

minuend = randomizer.Next(1, 101)

You can call the Next() method of the Random class, which you named "randomizer" earlier in this tutorial,
in multiple ways. Methods that you can call in more than one way are referred to as overloaded, and you
can use IntelliSense to explore them. Look again at the tooltip of the IntelliSense window for the Next()
method.
Intellisense window tooltip
The tooltip shows (+ 2 overload(s)) , which means that you can call the Next() method in two other ways.
Overloads contain different numbers or types of arguments, so that they work slightly differently from one
another. For example, a method might take a single integer argument, whereas one of its overloads might
take an integer and a string. You choose the correct overload based on what you want it to do. When you
add the code to the StartTheQuiz() method, more information appears in the Intellisense window as soon
as you enter randomizer.Next( . Choose the Up Arrow and Down Arrow keys to cycle through the overloads,
as the following illustration shows.

Overload for Next() method


in IntelliSense
In this case, you want to choose the last overload, because you can specify minimum and maximum values.
3. Modify the CheckTheAnswer() method to check for the correct subtraction answer.

/// <summary>
/// Check the answers to see if the user got everything right.
/// </summary>
/// <returns>True if the answer's correct, false otherwise.</returns>
private bool CheckTheAnswer()
{
if ((addend1 + addend2 == sum.Value)
&& (minuend - subtrahend == difference.Value))
return true;
else
return false;
}

''' <summary>
''' Check the answers to see if the user got everything right.
''' </summary>
''' <returns>True if the answer's correct, false otherwise.</returns>
''' <remarks></remarks>
Public Function CheckTheAnswer() As Boolean

If addend1 + addend2 = sum.Value AndAlso


minuend - subtrahend = difference.Value Then

Return True
Else
Return False
End If

End Function
In Visual C#, && is the logical and operator. In Visual Basic, the equivalent operator is AndAlso . These
operators indicate "If the sum of addend1 and addend2 equals the value of the sum NumericUpDown and if
minuend minus subtrahend equals the value of the difference NumericUpDown." The CheckTheAnswer()
method returns true only if the answers to the addition and the subtraction problems are both correct.
4. Replace the last part of the timer's Tick event handler with the following code so that it fills in the correct
answer when time runs out.

else
{
// If the user ran out of time, stop the timer, show
// a MessageBox, and fill in the answers.
timer1.Stop();
timeLabel.Text = "Time's up!";
MessageBox.Show("You didn't finish in time.", "Sorry!");
sum.Value = addend1 + addend2;
difference.Value = minuend - subtrahend;
startButton.Enabled = true;
}

Else
' If the user ran out of time, stop the timer, show
' a MessageBox, and fill in the answers.
Timer1.Stop()
timeLabel.Text = "Time's up!"
MessageBox.Show("You didn't finish in time.", "Sorry!")
sum.Value = addend1 + addend2
difference.Value = minuend - subtrahend
startButton.Enabled = True
End If

5. Save and run your code.


Your program includes a subtraction problem, as the following illustration shows.

Math quiz with subtraction problem


To continue or review
To go to the next tutorial step, see Step 7: Add Multiplication and Division Problems.
To return to the previous tutorial step, see Step 5: Add Enter Event Handlers for the NumericUpDown
Controls.
Step 7: Add Multiplication and Division Problems
10/18/2019 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In the seventh part of this tutorial, you'll add multiplication and division problems, but first think about how to
make that change. Consider the initial step, which involves storing values.
To add multiplication and division problems
1. Add four more integer variables to the form.

public partial class Form1 : Form


{
// Create a Random object called randomizer
// to generate random numbers.
Random randomizer = new Random();

// These integer variables store the numbers


// for the addition problem.
int addend1;
int addend2;

// These integer variables store the numbers


// for the subtraction problem.
int minuend;
int subtrahend;

// These integer variables store the numbers


// for the multiplication problem.
int multiplicand;
int multiplier;

// These integer variables store the numbers


// for the division problem.
int dividend;
int divisor;

// This integer variable keeps track of the


// remaining time.
int timeLeft;
Public Class Form1

' Create a Random object called randomizer


' to generate random numbers.
Private randomizer As New Random

' These integer variables store the numbers


' for the addition problem.
Private addend1 As Integer
Private addend2 As Integer

' These integer variables store the numbers


' for the subtraction problem.
Private minuend As Integer
Private subtrahend As Integer

' These integer variables store the numbers


' for the multiplication problem.
Private multiplicand As Integer
Private multiplier As Integer

' These integer variables store the numbers


' for the division problem.
Private dividend As Integer
Private divisor As Integer

' This integer variable keeps track of the


' remaining time.
Private timeLeft As Integer

2. As you did before, modify the StartTheQuiz() method to fill in random numbers for the multiplication and
division problems.
/// <summary>
/// Start the quiz by filling in all of the problem
/// values and starting the timer.
/// </summary>
public void StartTheQuiz()
{
// Fill in the addition problem.
// Generate two random numbers to add.
// Store the values in the variables 'addend1' and 'addend2'.
addend1 = randomizer.Next(51);
addend2 = randomizer.Next(51);

// Convert the two randomly generated numbers


// into strings so that they can be displayed
// in the label controls.
plusLeftLabel.Text = addend1.ToString();
plusRightLabel.Text = addend2.ToString();

// 'sum' is the name of the NumericUpDown control.


// This step makes sure its value is zero before
// adding any values to it.
sum.Value = 0;

// Fill in the subtraction problem.


minuend = randomizer.Next(1, 101);
subtrahend = randomizer.Next(1, minuend);
minusLeftLabel.Text = minuend.ToString();
minusRightLabel.Text = subtrahend.ToString();
difference.Value = 0;

// Fill in the multiplication problem.


multiplicand = randomizer.Next(2, 11);
multiplier = randomizer.Next(2, 11);
timesLeftLabel.Text = multiplicand.ToString();
timesRightLabel.Text = multiplier.ToString();
product.Value = 0;

// Fill in the division problem.


divisor = randomizer.Next(2, 11);
int temporaryQuotient = randomizer.Next(2, 11);
dividend = divisor * temporaryQuotient;
dividedLeftLabel.Text = dividend.ToString();
dividedRightLabel.Text = divisor.ToString();
quotient.Value = 0;

// Start the timer.


timeLeft = 30;
timeLabel.Text = "30 seconds";
timer1.Start();
}
''' <summary>
''' Start the quiz by filling in all of the problem
''' values and starting the timer.
''' </summary>
''' <remarks></remarks>
Public Sub StartTheQuiz()

' Fill in the addition problem.


' Generate two random numbers to add.
' Store the values in the variables 'addend1' and 'addend2'.
addend1 = randomizer.Next(51)
addend2 = randomizer.Next(51)

' Convert the two randomly generated numbers


' into strings so that they can be displayed
' in the label controls.
plusLeftLabel.Text = addend1.ToString()
plusRightLabel.Text = addend2.ToString()

' 'sum' is the name of the NumericUpDown control.


' This step makes sure its value is zero before
' adding any values to it.
sum.Value = 0

' Fill in the subtraction problem.


minuend = randomizer.Next(1, 101)
subtrahend = randomizer.Next(1, minuend)
minusLeftLabel.Text = minuend.ToString()
minusRightLabel.Text = subtrahend.ToString()
difference.Value = 0

' Fill in the multiplication problem.


multiplicand = randomizer.Next(2, 11)
multiplier = randomizer.Next(2, 11)
timesLeftLabel.Text = multiplicand.ToString()
timesRightLabel.Text = multiplier.ToString()
product.Value = 0

' Fill in the division problem.


divisor = randomizer.Next(2, 11)
Dim temporaryQuotient As Integer = randomizer.Next(2, 11)
dividend = divisor * temporaryQuotient
dividedLeftLabel.Text = dividend.ToString()
dividedRightLabel.Text = divisor.ToString()
quotient.Value = 0

' Start the timer.


timeLeft = 30
timeLabel.Text = "30 seconds"
Timer1.Start()

End Sub

3. Modify the CheckTheAnswer() method so that it also checks the multiplication and division problems.
/// <summary>
/// Check the answers to see if the user got everything right.
/// </summary>
/// <returns>True if the answer's correct, false otherwise.</returns>
private bool CheckTheAnswer()
{
if ((addend1 + addend2 == sum.Value)
&& (minuend - subtrahend == difference.Value)
&& (multiplicand * multiplier == product.Value)
&& (dividend / divisor == quotient.Value))
return true;
else
return false;
}

''' <summary>
''' Check the answers to see if the user got everything right.
''' </summary>
''' <returns>True if the answer's correct, false otherwise.</returns>
''' <remarks></remarks>
Public Function CheckTheAnswer() As Boolean

If addend1 + addend2 = sum.Value AndAlso


minuend - subtrahend = difference.Value AndAlso
multiplicand * multiplier = product.Value AndAlso
dividend / divisor = quotient.Value Then

Return True
Else
Return False
End If

End Function

You can't easily enter the multiplication sign (×) and the division sign (÷) using the keyboard, so Visual C#
and Visual Basic accept an asterisk (*) for multiplication and a slash mark (/) for division.
4. Change the last part of the timer's Tick event handler so that it fills in the correct answer when time runs
out.

else
{
// If the user ran out of time, stop the timer, show
// a MessageBox, and fill in the answers.
timer1.Stop();
timeLabel.Text = "Time's up!";
MessageBox.Show("You didn't finish in time.", "Sorry");
sum.Value = addend1 + addend2;
difference.Value = minuend - subtrahend;
product.Value = multiplicand * multiplier;
quotient.Value = dividend / divisor;
startButton.Enabled = true;
}
Else
' If the user ran out of time, stop the timer, show
' a MessageBox, and fill in the answers.
Timer1.Stop()
timeLabel.Text = "Time's up!"
MessageBox.Show("You didn't finish in time.", "Sorry!")
sum.Value = addend1 + addend2
difference.Value = minuend - subtrahend
product.Value = multiplicand * multiplier
quotient.Value = dividend / divisor
startButton.Enabled = True
End If

5. Save and run your program.


Quiz takers must answer four problems to complete the quiz, as the following illustration shows.

Math quiz with four problems


To continue or review
To go to the next tutorial step, see Step 8: Customize the Quiz.
To return to the previous tutorial step, see Step 6: Add a Subtraction Problem.
Step 8: Customize the Quiz
11/21/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In the last part of the tutorial, you'll explore some ways to customize the quiz and expand on what you've already
learned. For example, think about how the program creates random division problems for which the answer is
never a fraction. To learn more, turn the timeLabel control a different color, and give the quiz taker a hint.
To customize the quiz
When only five seconds remain in a quiz, turn the timeLabel control red by setting its BackColor property
( timeLabel.BackColor = Color.Red; ). Reset the color when the quiz is over.
Give the quiz taker a hint by playing a sound when the correct answer is entered into a NumericUpDown
control. (You must write an event handler for each control's ValueChanged() event, which fires whenever the
quiz taker changes the control's value.)
To continue or review
To go to the next tutorial, see Tutorial 3: Create a Matching Game.
To return to the previous tutorial step, see Step 7: Add Multiplication and Division Problems.
Tutorial 3: Create a Matching Game
11/21/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In this tutorial, you build a matching game, where the player must match pairs of hidden icons. You learn how to:
Store objects, such as icons, in a List object.
Use a foreach loop in Visual C# or a For Each loop in Visual Basic to iterate through items in a list.
Keep track of a form's state by using reference variables.
Build an event handler to respond to events that you can use with multiple objects.
Make a timer that counts down and then fires an event exactly once after being started.
When you finish this tutorial, your program will look like the following picture.

Game that you create in this tutorial

NOTE
In this tutorial, both Visual C# and Visual Basic are covered, so focus on information specific to the programming language
that you're using.

If you get stuck or have programming questions, try posting your question on one of the MSDN forums. See
Visual Basic Forum and Visual C# Forum. Also, there are great, free video learning resources available to you. To
learn more about programming in Visual Basic, see Visual Basic Fundamentals: Development for Absolute
Beginners. To learn more about programming in Visual C#, see C# Fundamentals: Development for Absolute
Beginners.
Related Topics
T IT L E DESC RIP T IO N

Step 1: Create a Project and Add a Table to Your Form Begin by creating the project and adding a
TableLayoutPanel control to keep the controls aligned
properly.

Step 2: Add a Random Object and a List of Icons Add a Random object and a List object, to create a list of
icons.

Step 3: Assign a Random Icon to Each Label Assign the icons randomly to the Label controls, so that
each game is different.

Step 4: Add a Click Event Handler to Each Label Add a Click event handler that changes the color of the label
that is clicked.

Step 5: Add Label References Add reference variables to keep track of which labels are
clicked.

Step 6: Add a Timer Add a timer to the form to keep track of the time that has
passed in the game.

Step 7: Keep Pairs Visible Keep pairs of icons visible, if a matching pair is selected.

Step 8: Add a Method to Verify Whether the Player Won Add a CheckForWinner() method to verify whether the
player won.

Step 9: Try Other Features Try other features, such as changing icons and colors, adding
a grid, and adding sounds. Try making the board bigger and
adjusting the timer.
Step 1: Create a Project and Add a Table to Your
Form
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The first step in creating a matching game is to create the project and add a table to your form. The table helps
align the icons into an orderly 4x4 grid. You also set several properties to enhance the appearance of the game
board.
To create a project and add a table to your form
1. On the menu bar, choose File , New , Project .
2. If you’re not using Visual Studio Express, you need to select a programming language first. From the
Installed Templates list, choose either Visual C# or Visual Basic .
3. In the list of project templates, choose Windows Forms Application , name the project MatchingGame ,
and then choose the OK button.
4. In the Proper ties window, set the following form properties.
a. Change the form's Text property from Form1 to Matching Game . This text appears at the top of
the game window.
b. Set the size of the form to 550 pixels wide by 550 tall. You can do this either by setting the Size
property to 550, 550 , or by dragging the corner of the form until you see the correct size in the
lower-right corner of the integrated development environment (IDE).
5. Display the toolbox by choosing the Toolbox tab on the left side of the IDE.
6. Drag a TableLayoutPanel control from the Containers category in the toolbox, and then set the following
properties for it.
a. Set the BackColor property to CornflowerBlue . To do this, open the BackColor dialog box by
choosing the drop-down arrow next to the BackColor property in the Proper ties window. Then,
choose the Web tab in the BackColor dialog box to view a list of available color names.

NOTE
The colors are not in alphabetical order, and CornflowerBlue is near the bottom of the list.

b. Set the Dock property to Fill by choosing the drop-down button next to the property and choosing
the large middle button. This spreads the table out so that it covers the entire form.
c. Set the CellBorderStyle property to Inset . This provides visual borders between each cell on the
board.
d. Choose the triangle button in the upper-right corner of the TableLayoutPanel to display its task menu.
e. On the task menu, choose Add Row twice to add two more rows, and then choose Add Column
twice to add two more columns.
f. On the task menu, choose Edit Rows and Columns to open the Column and Row Styles window.
Choose each of the columns, choose the Percent option button, and then set each column's width to
25 percent of the total width. Then select Rows from the drop-down box at the top of the window,
and set each row's height to 25 percent. When you're done, choose the OK button.
Your TableLayoutPanel should now be a 4x4 grid, with sixteen equally sized square cells. These rows
and columns are where the icon images will appear later.
7. Be certain that the TableLayoutPanel is selected in the form editor. To verify this, you should see
tableLayoutPanel1 at the top of the Proper ties window. If it is not selected, choose the TableLayoutPanel
on the form, or choose it in the dropdown control at the top of the Proper ties window.
While the TableLayoutPanel is selected, open the toolbox and add a Label control (located in the Common
Controls category) to the upper-left cell of the TableLayoutPanel. The Label control should now be
selected in the IDE. Set the following properties for it.
a. Be sure that the label's BackColor property is set to CornflowerBlue .
b. Set the AutoSize property to False .
c. Set the Dock property to Fill .
d. Set the TextAlign property to MiddleCenter by choosing the drop-down button next to the
property, and then choosing the middle button. This ensures the icon appears in the middle of the
cell.
e. Choose the Font property. An ellipsis (…) button should appear.
f. Choose the ellipsis button, and set the Font value to Webdings , the Font Style to Bold , and the
Size to 72 .
g. Set the Text property of the label to the letter c .
The upper-left cell in the TableLayoutPanel should now contain a black box centered on a blue
background.

NOTE
The Webdings font is a font of icons that ships with the Windows operating system. In your matching game,
the player needs to match pairs of icons, so you use this font to display the icons to match. Instead of putting
c in the Text property, try entering different letters to see what icons are displayed. An exclamation point is a
spider, an uppercase N is an eye, and a comma is a chili pepper.

8. Choose your label control and copy it to the next cell in the TableLayoutPanel. (Choose the Ctrl+C keys, or on
the menu bar, choose Edit , Copy .) Then paste it. (Choose the Ctrl+V keys, or on the menu bar, choose Edit ,
Paste .) A copy of the first label appears in the second cell of the TableLayoutPanel. Paste it again, and
another label appears in the third cell. Keep pasting Label controls until all of the cells are filled.

NOTE
If you paste too many times, the IDE adds a new row to the TableLayoutPanel so that it has a place to add your new
label control. You can undo it. To remove the new cell, choose the Ctrl+Z keys, or on the menu bar, choose Edit ,
Undo .
Now your form is laid out. It should look like the following picture.

Initial matching game form


To continue or review
To go to the next tutorial step, see Step 2: Add a Random Object and a List of Icons.
To return to the overview topic, see Tutorial 3: Create a Matching Game.
Step 2: Add a Random Object and a List of Icons
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In this step, you create a set of matching symbols for the game. Each symbol is added to two random cells in the
TableLayoutPanel on the form. To do this, you use two new statements to create two objects. The first is a Random
object, like the one you used in the math quiz game. It is used in this code to randomly choose cells in the
TableLayoutPanel. The second object, which may be new to you, is a List object which is used to store the
randomly-chosen symbols.
To add a Random object and a list of icons
1. In Solution Explorer , choose Form1.cs if you're using Visual C#, or Form1.vb if you're using Visual Basic,
and then on the menu bar, choose View , Code . As an alternative, you can choose the F7 key or double-click
Form1 in Solution Explorer .
This displays the code module behind Form1.
2. In the existing code, add the following code.

public partial class Form1 : Form


{
// Use this Random object to choose random icons for the squares
Random random = new Random();

// Each of these letters is an interesting icon


// in the Webdings font,
// and each icon appears twice in this list
List<string> icons = new List<string>()
{
"!", "!", "N", "N", ",", ",", "k", "k",
"b", "b", "v", "v", "w", "w", "z", "z"
};

Public Class Form1

' Use this Random object to choose random icons for the squares
Private random As New Random

' Each of these letters is an interesting icon


' in the Webdings font,
' and each icon appears twice in this list
Private icons =
New List(Of String) From {"!", "!", "N", "N", ",", ",", "k", "k",
"b", "b", "v", "v", "w", "w", "z", "z"}

If you're using Visual C#, be sure you put the code after the opening curly brace and just after the class
declaration ( public partial class Form1 : Form ). If you're using Visual Basic, put the code right after the
class declaration ( Public Class Form1 ).
3. When adding the List object, notice the IntelliSense window that opens. The following is a Visual C#
example, but similar text appears when you add a list in Visual Basic.

IntelliSense window

NOTE
The Intellisense window appears only when you enter code manually. If you copy and paste the code, it doesn't
appear.

If you look at the code (and remarks) in small sections, it's easier to understand. Your programs can use
List objects to keep track of many different types of items. A list can hold numbers, true/false values, text,
or other objects. You can even have a List object that holds other List objects. The items in a list are
called elements, and each list only holds one type of element. So, a list of numbers can only hold numbers
—you can't add text to that list. Similarly, you can't add numbers to a list of true/false values.
When you create a List object using a new statement, you need to specify the kind of data you want to
store in it. That's why the tooltip at the top of the IntelliSense window shows the types of elements in the
list. Also, that's what List<string> (in Visual C#) and List(Of String) (in Visual Basic) means: It's a List
object that holds elements of string data type. A string is what your program uses to store text, which is
what the tooltip to the right of the IntelliSense window is telling you.
4. Consider why in Visual Basic a temporary array must be created first, but in Visual C#, the list can be
created with one statement. This is because the Visual C# language has collection initializers, which prepare
the list to accept values. In Visual Basic, you can use a collection initializer. However, for compatibility with
the previous version of Visual Basic, we recommend using the preceding code.
When you use a collection initializer with a new statement, after the new List object is created, the
program fills it with the data you provided inside the curly braces. In this case, you get a list of strings
named icons , and that list will be initialized so that it contains sixteen strings. Each of those strings is a
single letter, and they all correspond to the icons that will be in the labels. So, the game will have a pair of
exclamation points, a pair of uppercase N letters, a pair of commas, and so on. (When these characters are
set to the Webdings font, they will appear as symbols, such as a bus, a bike, a spider, and so forth.) Your
List object will have sixteen strings in all, one for each cell in the TableLayoutPanel panel.

NOTE
In Visual Basic, you get the same result, but first the strings are put into a temporary array, which is then converted
into a List object. An array is similar to a list, except, for example, arrays are created with a fixed size. Lists can
shrink and grow as needed, which is important in this program.

To continue or review
To go to the next tutorial step, see Step 3: Assign a Random Icon to Each Label.
To return to the previous tutorial step, see Step 1: Create a Project and Add a Table to Your Form.
Step 3: Assign a Random Icon to Each Label
10/18/2019 • 6 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

If the icons show up in the same cells every game, it's not very challenging. To avoid this, assign the icons
randomly to the label controls on your form by using an AssignIconsToSquares() method.
To assign a random icon to each label
1. Before adding the following code, consider how the method works. There's a new keyword: foreach in
Visual C# and For Each in Visual Basic. (One of the lines is commented out on purpose, which is explained
at the end of this procedure.)

/// <summary>
/// Assign each icon from the list of icons to a random square
/// </summary>
private void AssignIconsToSquares()
{
// The TableLayoutPanel has 16 labels,
// and the icon list has 16 icons,
// so an icon is pulled at random from the list
// and added to each label
foreach (Control control in tableLayoutPanel1.Controls)
{
Label iconLabel = control as Label;
if (iconLabel != null)
{
int randomNumber = random.Next(icons.Count);
iconLabel.Text = icons[randomNumber];
// iconLabel.ForeColor = iconLabel.BackColor;
icons.RemoveAt(randomNumber);
}
}
}
''' <summary>
''' Assign each icon from the list of icons to a random square
''' </summary>
''' <remarks></remarks>
Private Sub AssignIconsToSquares()

' The TableLayoutPanel has 16 labels,


' and the icon list has 16 icons,
' so an icon is pulled at random from the list
' and added to each label
For Each control In TableLayoutPanel1.Controls
Dim iconLabel = TryCast(control, Label)
If iconLabel IsNot Nothing Then
Dim randomNumber = random.Next(icons.Count)
iconLabel.Text = icons(randomNumber)
' iconLabel.ForeColor = iconLabel.BackColor
icons.RemoveAt(randomNumber)
End If
Next

End Sub

2. Add the AssignIconsToSquares() method as shown in the previous step. You can put it just below the code
you added in Step 2: Add a Random Object and a List of Icons.
As mentioned earlier, there's something new in your AssignIconsToSquares() method: a foreach loop in
Visual C# and For Each in Visual Basic. You can use a For Each loop any time you want to do the same
action multiple times. In this case, you want to execute the same statements for every label on your
TableLayoutPanel, as explained by the following code. The first line creates a variable named control that
stores each control one at a time while that control has the statements in the loop executed on it.

foreach (Control control in tableLayoutPanel1.Controls)


{
// The statements you want to execute
// for each label go here
// The statements use iconLabel to access
// each label's properties and methods
}

For Each control In TableLayoutPanel1.Controls


' The statements you want to execute
' for each label go here
' The statements use iconLabel to access
' each label's properties and methods
Next

NOTE
The names "iconLabel" and "control" are used because they are descriptive. You can replace these names with any
names, and the code will work exactly the same as long as you change the name in each statement inside the loop.

The AssignIconsToSquares() method iterates through each label control in the TableLayoutPanel and
executes the same statements for each of them. Those statements pull a random icon from the list that you
added in Step 2: Add a Random Object and a List of Icons. (That's why you included two of each icon in the
list, so there would be a pair of icons assigned to random label controls.)
Look more closely at the code that runs inside the foreach or For Each loop. This code is reproduced here.
Label iconLabel = control as Label;
if (iconLabel != null)
{
int randomNumber = random.Next(icons.Count);
iconLabel.Text = icons[randomNumber];
// iconLabel.ForeColor = iconLabel.BackColor;
icons.RemoveAt(randomNumber);
}

Dim iconLabel = TryCast(control, Label)


If iconLabel IsNot Nothing Then
Dim randomNumber = random.Next(icons.Count)
iconLabel.Text = icons(randomNumber)
' iconLabel.ForeColor = iconLabel.BackColor
icons.RemoveAt(randomNumber)
End If

The first line converts the control variable to a label named iconLabel . The line after that is an if
statement that checks to make sure the conversion worked. If the conversion does work, the statements in
the if statement run. (As you may recall from the previous tutorials, the if statement is used to evaluate
whatever condition you specify.) The first line in the if statement creates a variable named randomNumber
that contains a random number that corresponds to one of the items in the icons list. To do this, it uses the
Next method of the Random object that you created earlier. The Next method returns the random number.
This line also uses the Count property of the icons list to determine the range from which to choose the
random number. The next line assigns one of the icon list items to the Text property of the label. The
commented-out line is explained later in this topic. Finally, the last line in the if statement removes from
the list the icon that has been added to the form.
Remember, if you're not sure about what some part of the code does, you can position the mouse pointer
over a code element and review the resulting tooltip. You can also step through each line of code while the
program is running by using the Visual Studio debugger. See How Do I: Step with The Debugger in Visual
Studio? or Navigating through Code with the Debugger for more information.
3. To fill up the game board with icons, you need to call the AssignIconsToSquares() method as soon as the
program starts. If you're using Visual C#, add a statement just below the call to the InitializeComponent()
method in the Form1 constructor, so your form calls your new method to set itself up before it's shown.
Constructors are called when you create a new object, such as a class or struct. See Constructors (C#
Programming Guide) or Using Constructors and Destructors in Visual Basic for more information.

public Form1()
{
InitializeComponent();

AssignIconsToSquares();
}

For Visual Basic, add the AssignIconsToSquares() method call to the Form1_Load method so that the code
looks like the following.

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


AssignIconsToSquares()
End Sub

4. Save your program and run it. It should show a form with random icons assigned to each label.
5. Close your program, and then run it again. Notice that different icons are assigned to each label, as shown
in the following picture.

Matching game with random icons


The icons are visible now because you haven't hidden them. To hide them from the player, you can set each
label's Forecolor property to the same color as its BackColor property.

TIP
Another way to hide controls like labels is to set their Visible property to False .

6. To hide the icons, stop the program and remove the comment marks for the commented line of code inside
the For Each loop.

iconLabel.ForeColor = iconLabel.BackColor;

iconLabel.ForeColor = iconLabel.BackColor

7. On the menu bar, choose the Save All button to save your program, and then run it. The icons seem to
have disappeared—only a blue background appears. However, the icons are randomly assigned and are still
there. Because the icons are the same color as the background, it hides them from the player. After all, it
wouldn't be a very challenging game if the player could see all of the icons right away!
To continue or review
To go to the next tutorial step, see Step 4: Add a Click Event Handler to Each Label.
To return to the previous tutorial step, see Step 2: Add a Random Object and a List of Icons.
Step 4: Add a Click Event Handler to Each Label
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The matching game works as follows:


1. When a player chooses one of the squares with a hidden icon, the program shows the icon to the player by
changing the icon color to black.
2. Then the player chooses another hidden icon.
3. If the icons match, they stay visible. If not, both icons are hidden again.
To get your program to work that way, you add a Click event handler that changes the color of the label that
is chosen.
To add a Click event handler to each label
1. Open the form in the Windows Forms Designer. In Solution Explorer, choose Form1.cs or Form1.vb. On the
menu bar, choose View , Designer .
2. Choose the first label control to select it. Then, hold down the CTRL key while you choose each of the other
labels to select them. Be sure that every label is selected.
3. Choose the Events button on the tool bar in the Proper ties window to view the Events page in the
Proper ties window. Scroll down to the Click event, and enter label_Click in the box, as shown in the
following picture.

Properties window showing Click event


4. Choose the ENTER key. The IDE adds a Click event handler called label_Click() to the code, and hooks it to
each of the labels on the form.
5. Fill in the rest of the code, as follows:
/// <summary>
/// Every label's Click event is handled by this event handler
/// </summary>
/// <param name="sender">The label that was clicked</param>
/// <param name="e"></param>
private void label_Click(object sender, EventArgs e)
{
Label clickedLabel = sender as Label;

if (clickedLabel != null)
{
// If the clicked label is black, the player clicked
// an icon that's already been revealed --
// ignore the click
if (clickedLabel.ForeColor == Color.Black)
return;

clickedLabel.ForeColor = Color.Black;
}
}

''' <summary>
''' Every label's Click event is handled by this event handler
''' </summary>
''' <param name="sender">The label that was clicked</param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub label_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Label9.Click,
Label8.Click, Label7.Click, Label6.Click, Label5.Click, Label4.Click,
Label3.Click, Label2.Click, Label16.Click, Label15.Click, Label14.Click,
Label13.Click, Label12.Click, Label11.Click, Label10.Click, Label1.Click

Dim clickedLabel = TryCast(sender, Label)

If clickedLabel IsNot Nothing Then

' If the clicked label is black, the player clicked


' an icon that's already been revealed --
' ignore the click
If clickedLabel.ForeColor = Color.Black Then Exit Sub

clickedLabel.ForeColor = Color.Black
End If
End Sub

NOTE
If you copy and paste the label_Click() code block rather than entering the code manually, be sure to replace the
existing label_Click() code. Otherwise, you'll end up with a duplicate code block.

NOTE
You may recognize object sender at the top of the event handler as the same one used in the Tutorial 2: Create a
Timed Math Quiz tutorial. Because you hooked up different label control Click event to a single event handler
method, the same method is called no matter which label the user chooses. The event handler method needs to
know which label was chosen, so it uses the name sender to identify the label control. The first line of the method
tells the program that it's not just a generic object, but specifically a label control, and that it uses the name
clickedLabel to access the label's properties and methods.
This method first checks whether clickedLabel was successfully converted (cast) from an object to a label
control. If unsuccessful, it has a value of null (C#) or Nothing (Visual Basic), and you don't want to execute
the remainder of the code in the method. Next, the method checks the chosen label's text color by using the
label's ForeColor property. If the label's text color is black, then that means the icon's already been chosen
and the method is done. (That's what the return statement does: It tells the program to stop executing the
method.) Otherwise, the icon hasn't been chosen, so the program changes the label's text color to black.
6. On the menu bar, choose File , Save All to save your progress, and then, on the menu bar, choose Debug ,
Star t Debugging to run your program. You should see an empty form with a blue background. Choose
any of the cells in the form, and one of the icons should become visible. Continue choosing different places
in the form. As you choose the icons, they should appear.
To continue or review
To go to the next tutorial step, see Step 5: Add Label References.
To return to the previous tutorial step, see Step 3: Assign a Random Icon to Each Label.
Step 5: Add Label References
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The program needs to track which label controls the player chooses. Right now, the program shows all labels
chosen by the player. But we're going to change that. After the first label is chosen, the program should show the
label's icon. After the second label is chosen, the program should display both icons for a brief time, and then hide
both icons again. Your program will now keep track of which label control is chosen first and which is chosen
second by using reference variables.
To add label references
1. Add label references to your form by using the following code.

public partial class Form1 : Form


{
// firstClicked points to the first Label control
// that the player clicks, but it will be null
// if the player hasn't clicked a label yet
Label firstClicked = null;

// secondClicked points to the second Label control


// that the player clicks
Label secondClicked = null;

Public Class Form1

' firstClicked points to the first Label control


' that the player clicks, but it will be Nothing
' if the player hasn't clicked a label yet
Private firstClicked As Label = Nothing

' secondClicked points to the second Label control


' that the player clicks
Private secondClicked As Label = Nothing

These reference variables look similar to the statements you used earlier to add objects (like Timer objects,
List objects, and Random objects) to your form. However, these statements don't cause two extra label
controls to appear on the form because there's no new keyword used in either of the two statements.
Without the new keyword, no object is created. That's why firstClicked and secondClicked are called
reference variables: They just keep track (or, refer to) Label objects.
When a variable isn't keeping track of an object, it's set to a special reserved value: null in Visual C# and
Nothing in Visual Basic. So, when the program starts, both firstClicked and secondClicked are set to
null or Nothing , which means that the variables aren't keeping track of anything.

2. Modify your Click event handler to use the new firstClicked reference variable. Remove the last statement
in the label_Click() event handler method ( clickedLabel.ForeColor = Color.Black; ) and replace it with the
if statement that follows. (Be sure you include the comment, and the whole if statement.)
/// <summary>
/// Every label's Click event is handled by this event handler
/// </summary>
/// <param name="sender">The label that was clicked</param>
/// <param name="e"></param>
private void label_Click(object sender, EventArgs e)
{
Label clickedLabel = sender as Label;

if (clickedLabel != null)
{
// If the clicked label is black, the player clicked
// an icon that's already been revealed --
// ignore the click
if (clickedLabel.ForeColor == Color.Black)
return;

// If firstClicked is null, this is the first icon


// in the pair that the player clicked,
// so set firstClicked to the label that the player
// clicked, change its color to black, and return
if (firstClicked == null)
{
firstClicked = clickedLabel;
firstClicked.ForeColor = Color.Black;

return;
}
}
}

''' <summary>
''' Every label's Click event is handled by this event handler
''' </summary>
''' <param name="sender">The label that was clicked</param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub label_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Label9.Click,
Label8.Click, Label7.Click, Label6.Click, Label5.Click, Label4.Click,
Label3.Click, Label2.Click, Label16.Click, Label15.Click, Label14.Click,
Label13.Click, Label12.Click, Label11.Click, Label10.Click, Label1.Click

Dim clickedLabel = TryCast(sender, Label)

If clickedLabel IsNot Nothing Then

' If the clicked label is black, the player clicked


' an icon that's already been revealed --
' ignore the click
If clickedLabel.ForeColor = Color.Black Then Exit Sub

' If firstClicked is Nothing, this is the first icon


' in the pair that the player clicked,
' so set firstClicked to the label that the player
' clicked, change its color to black, and return
If firstClicked Is Nothing Then
firstClicked = clickedLabel
firstClicked.ForeColor = Color.Black
Exit Sub
End If
End If

End Sub
3. Save and run your program. Choose one of the label controls, and its icon appears.
4. Choose the next label control, and notice that nothing happens. The program is already keeping track of the
first label that the player chose, so firstClicked isn't equal to null in Visual C# or Nothing in Visual
Basic. When your if statement checks firstClicked to determine if it's equal to null or Nothing , it finds
that it isn't, and it doesn't execute the statements in the if statement. So, only the first icon that's chosen
turns black, and the other icons are invisible, as shown in the following picture.

Matching game showing one icon


You'll fix this situation in the next step of the tutorial by adding a Timer control.
To continue or review
To go to the next tutorial step, see Step 6: Add a Timer.
To return to the previous tutorial step, see Step 4: Add a Click Event Handler to Each Label.
Step 6: Add a Timer
10/18/2019 • 7 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Next, you add a Timer control to the matching game. A timer waits a specified number of milliseconds, and then
fires an event, referred to as a tick. This is useful for starting an action, or repeating an action on a regular basis. In
this case, you'll use a timer to enable players to choose two icons, and if the icons don't match, hide the two icons
again after a short period of time.
To add a timer
1. From the toolbox in Windows Forms Designer, choose Timer (in the Components category) and then
choose the ENTER key, or double-click the timer to add a timer control to the form. The timer's icon, called
Timer1 , should appear in a space below the form, as shown in the following picture.

Timer

NOTE
If the toolbox is empty, be sure to select the form designer, and not the code behind the form, before opening the
toolbox.

2. Choose the Timer1 icon to select the timer. In the Proper ties window, switch from viewing events to
viewing properties. Then, set the timer's Inter val property to 750 , but leave its Enabled property set to
False . The Inter val property tells the timer how long to wait between ticks, or when it triggers its Tick
event. A value of 750 tells the timer to wait three quarters of a second (750 milliseconds) before it fires its
Tick event. You'll call the Start() method to start the timer only after the player chooses the second label.
3. Choose the timer control icon in Windows Forms Designer and then choose the ENTER key, or double-click
the timer, to add an empty Tick event handler. Either replace the code with the following code, or manually
enter the following code into the event handler.
/// <summary>
/// This timer is started when the player clicks
/// two icons that don't match,
/// so it counts three quarters of a second
/// and then turns itself off and hides both icons
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void timer1_Tick(object sender, EventArgs e)
{
// Stop the timer
timer1.Stop();

// Hide both icons


firstClicked.ForeColor = firstClicked.BackColor;
secondClicked.ForeColor = secondClicked.BackColor;

// Reset firstClicked and secondClicked


// so the next time a label is
// clicked, the program knows it's the first click
firstClicked = null;
secondClicked = null;
}

''' <summary>
''' This timer is started when the player clicks
''' two icons that don't match,
''' so it counts three quarters of a second
''' and then turns itself off and hides both icons
''' </summary>
''' <remarks></remarks>
Private Sub Timer1_Tick() Handles Timer1.Tick

' Stop the timer


Timer1.Stop()

' Hide both icons


firstClicked.ForeColor = firstClicked.BackColor
secondClicked.ForeColor = secondClicked.BackColor

' Reset firstClicked and secondClicked


' so the next time a label is
' clicked, the program knows it's the first click
firstClicked = Nothing
secondClicked = Nothing

End Sub

The Tick event handler does three things: First, it makes sure the timer isn't running by calling the Stop()
method. Then it uses two reference variables, firstClicked and secondClicked , to make the icons of the
two labels that the player chose invisible again. Finally, it resets the firstClicked and secondClicked
reference variables to null in Visual C# and Nothing in Visual Basic. This step is important because it's
how the program resets itself. Now it's not keeping track of any Label controls, and it's ready for the player
to choose a label again.
NOTE
A Timer object has a Start() method that starts the timer, and a Stop() method that stops it. When you set
the timer's Enabled property to True in the Proper ties window, it starts ticking as soon as the program begins.
But when you leave it set to False , it doesn't start ticking until its Start() method is called. Normally, a timer fires
its Tick event over and over again, using the Inter val property to determine how many milliseconds to wait
between ticks. You may have noticed how the timer's Stop() method is called inside the Tick event. That puts the
timer into one shot mode, meaning that when the Start() method is called, it waits for the specified interval,
triggers a single Tick event, and then stops.

4. To see the new timer in action, go to the code editor and add the following code to the top and bottom of
the label_Click() event handler method. (You're adding an if statement to the top, and three statements
to the bottom; the rest of the method stays the same.)

/// <summary>
/// Every label's Click event is handled by this event handler
/// </summary>
/// <param name="sender">The label that was clicked</param>
/// <param name="e"></param>
private void label_Click(object sender, EventArgs e)
{
// The timer is only on after two non-matching
// icons have been shown to the player,
// so ignore any clicks if the timer is running
if (timer1.Enabled == true)
return;

Label clickedLabel = sender as Label;

if (clickedLabel != null)
{
// If the clicked label is black, the player clicked
// an icon that's already been revealed --
// ignore the click
if (clickedLabel.ForeColor == Color.Black)
return;

// If firstClicked is null, this is the first icon


// in the pair that the player clicked,
// so set firstClicked to the label that the player
// clicked, change its color to black, and return
if (firstClicked == null)
{
firstClicked = clickedLabel;
firstClicked.ForeColor = Color.Black;
return;
}

// If the player gets this far, the timer isn't


// running and firstClicked isn't null,
// so this must be the second icon the player clicked
// Set its color to black
secondClicked = clickedLabel;
secondClicked.ForeColor = Color.Black;

// If the player gets this far, the player


// clicked two different icons, so start the
// timer (which will wait three quarters of
// a second, and then hide the icons)
timer1.Start();
}
}
''' <summary>
''' Every label's Click event is handled by this event handler
''' </summary>
''' <param name="sender">The label that was clicked</param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub label_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Label9.Click,
Label8.Click, Label7.Click, Label6.Click, Label5.Click, Label4.Click,
Label3.Click, Label2.Click, Label16.Click, Label15.Click, Label14.Click,
Label13.Click, Label12.Click, Label11.Click, Label10.Click, Label1.Click

' The timer is only on after two non-matching


' icons have been shown to the player,
' so ignore any clicks if the timer is running
If Timer1.Enabled Then Exit Sub

Dim clickedLabel = TryCast(sender, Label)

If clickedLabel IsNot Nothing Then


' If the clicked label is black, the player clicked
' an icon that's already been revealed --
' ignore the click
If clickedLabel.ForeColor = Color.Black Then Exit Sub

' If firstClicked is Nothing, this is the first icon


' in the pair that the player clicked,
' so set firstClicked to the label that the player
' clicked, change its color to black, and return
If firstClicked Is Nothing Then
firstClicked = clickedLabel
firstClicked.ForeColor = Color.Black
Exit Sub
End If

' If the player gets this far, the timer isn't


' running and firstClicked isn't Nothing,
' so this must be the second icon the player clicked
' Set its color to black
secondClicked = clickedLabel
secondClicked.ForeColor = Color.Black

' If the player gets this far, the player


' clicked two different icons, so start the
' timer (which will wait three quarters of
' a second, and then hide the icons)
Timer1.Start()
End If

End Sub

The code at the top of the method checks whether the timer was started by checking the value of the
Enabled property. That way, if the player chooses the first and second Label controls and the timer starts,
choosing a third label won't do anything.
The code at the bottom of the method sets the secondClicked reference variable to track the second Label
control that the player chose, and then it sets that label's icon color to black to make it visible. Then, it starts
the timer in one shot mode, so that it waits 750 milliseconds and then fires a single Tick event. The timer’s
Tick event handler hides the two icons and resets the firstClicked and secondClicked reference variables
so the form is ready for the player to choose another pair of icons.
5. Save and run your program. Choose an icon, and it becomes visible.
6. Choose another icon. It appears briefly, and then both icons disappear. Repeat this numerous times. The
form now keeps track of the first and second icons that you choose, and uses the timer to pause before
making the icons disappear.
To continue or review
To go to the next tutorial step, see Step 7: Keep Pairs Visible.
To return to the previous tutorial step, see Step 5: Add Label References.
Step 7: Keep Pairs Visible
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The game works well, as long as the player only chooses pairs of icons that don't match. But consider what should
happen when the player chooses a matching pair. Instead of making the icons disappear by turning on the timer
(using the Start() method), the game should reset itself so that it's no longer keeping track of any labels using
the firstClicked and secondClicked reference variables, without resetting the colors for the two labels that were
chosen.
To keep pairs visible
1. Add the following if statement to the label_Click() event handler method, near the end of the code just
above the statement where you start the timer. Take a close look at the code while adding it to the program.
Consider how the code works.

// If the player gets this far, the timer isn't


// running and firstClicked isn't null,
// so this must be the second icon the player clicked
// Set its color to black
secondClicked = clickedLabel;
secondClicked.ForeColor = Color.Black;

// If the player clicked two matching icons, keep them


// black and reset firstClicked and secondClicked
// so the player can click another icon
if (firstClicked.Text == secondClicked.Text)
{
firstClicked = null;
secondClicked = null;
return;
}

// If the player gets this far, the player


// clicked two different icons, so start the
// timer (which will wait three quarters of
// a second, and then hide the icons)
timer1.Start();
}
}
' If the player gets this far, the timer isn't
' running and firstClicked isn't Nothing,
' so this must be the second icon the player clicked
' Set its color to black
secondClicked = clickedLabel
secondClicked.ForeColor = Color.Black

' If the player clicked two matching icons, keep them


' black and reset firstClicked and secondClicked
' so the player can click another icon
If firstClicked.Text = secondClicked.Text Then
firstClicked = Nothing
secondClicked = Nothing
Exit Sub
End If

' If the player gets this far, the player


' clicked two different icons, so start the
' timer (which will wait three quarters of
' a second, and then hide the icons)
Timer1.Start()
End If
End Sub

The first line of the if statement you just added checks whether the icon in the first label that the player
chooses is the same as the icon in the second label. If the icons are identical, the program executes the three
statements between the curly braces in C# or the three statements within the if statement in Visual Basic.
The first two statements reset the firstClicked and secondClicked reference variables so that they no
longer keep track of any of the labels. (You may recognize those two statements from the timer's Tick event
handler.) The third statement is a return statement, which tells the program to skip the rest of the
statements in the method without executing them.
If programming in Visual C#, you may have noticed that some of the code uses a single equal sign ( = ),
while other statements use two equal signs ( == ). Consider why = is used in some places but == is used
in other places.
This is a good example that shows the difference. Take a careful look at the code between the parentheses in
the if statement.

firstClicked.Text = secondClicked.Text

firstClicked.Text == secondClicked.Text

Then look closely at the first statement in the block of code after the if statement.

firstClicked = Nothing

firstClicked = null;

The first of those two statements checks whether two icons are the same. Because two values are being
compared, the Visual C# program uses the == equality operator. The second statement actually changes
the value (called assignment), setting the firstClicked reference variable equal to null to reset it. That's
why it uses the = assignment operator instead. Visual C# uses = to set values, and == to compare them.
Visual Basic uses = for both variable assignment and comparison.
2. Save and run the program, and then start choosing icons on the form. If you choose a pair that doesn't
match, the timer's Tick event triggers, and both icons disappear. If you choose a matching pair, the new if
statement executes, and the return statement causes the method to skip the code that starts the timer, so
the icons stay visible, as shown in the following picture.

Matching game with visible icon pairs


To continue or review
To go to the next tutorial step, see Step 8: Add a Method to Verify Whether the Player Won.
To return to the previous tutorial step, see Step 6: Add a Timer.
Step 8: Add a Method to Verify Whether the Player
Won
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You've created a fun game, but it needs an additional item to finish it. The game should end when the player wins,
so you need to add a CheckForWinner() method to verify whether the player won.
To add a method to verify whether the player won
1. Add a CheckForWinner() method to the bottom of your code, below the timer1_Tick() event handler, as
shown in the following code.

/// <summary>
/// Check every icon to see if it is matched, by
/// comparing its foreground color to its background color.
/// If all of the icons are matched, the player wins
/// </summary>
private void CheckForWinner()
{
// Go through all of the labels in the TableLayoutPanel,
// checking each one to see if its icon is matched
foreach (Control control in tableLayoutPanel1.Controls)
{
Label iconLabel = control as Label;

if (iconLabel != null)
{
if (iconLabel.ForeColor == iconLabel.BackColor)
return;
}
}

// If the loop didn’t return, it didn't find


// any unmatched icons
// That means the user won. Show a message and close the form
MessageBox.Show("You matched all the icons!", "Congratulations");
Close();
}
''' <summary>
''' Check every icon to see if it is matched, by
''' comparing its foreground color to its background color.
''' If all of the icons are matched, the player wins
''' </summary>
Private Sub CheckForWinner()

' Go through all of the labels in the TableLayoutPanel,


' checking each one to see if its icon is matched
For Each control In TableLayoutPanel1.Controls
Dim iconLabel = TryCast(control, Label)
If iconLabel IsNot Nothing AndAlso
iconLabel.ForeColor = iconLabel.BackColor Then Exit Sub
Next

' If the loop didn't return, it didn't find


' any unmatched icons
' That means the user won. Show a message and close the form
MessageBox.Show("You matched all the icons!", "Congratulations")
Close()

End Sub

The method uses another foreach loop in Visual C# or For Each loop in Visual Basic to go through each
label in the TableLayoutPanel. It uses the equality operator ( == in Visual C# and = in Visual Basic) to check
each label's icon color to verify whether it matches the background. If the colors match, the icon remains
invisible, and the player hasn't matched all of the icons remaining. In that case, the program uses a return
statement to skip the rest of the method. If the loop gets through all of the labels without executing the
return statement, that means that all of the icons on the form were matched. The program shows a
MessageBox to congratulate the player on winning, and then calls the form's Close() method to end the
game.
2. Next, have the label's Click event handler call the new CheckForWinner() method. Be sure that your program
checks for a winner immediately after it shows the second icon that the player chooses. Look for the line
where you set the second chosen icon's color, and then call the CheckForWinner() method right after that, as
shown in the following code.

// If the player gets this far, the timer isn't


// running and firstClicked isn't null,
// so this must be the second icon the player clicked
// Set its color to black
secondClicked = clickedLabel;
secondClicked.ForeColor = Color.Black;

// Check to see if the player won


CheckForWinner();

// If the player clicked two matching icons, keep them


// black and reset firstClicked and secondClicked
// so the player can click another icon
if (firstClicked.Text == secondClicked.Text)
{
firstClicked = null;
secondClicked = null;
return;
}
' If the player gets this far, the timer isn't
' running and firstClicked isn't Nothing,
' so this must be the second icon the player clicked
' Set its color to black
secondClicked = clickedLabel
secondClicked.ForeColor = Color.Black

' Check to see if the player won


CheckForWinner()

' If the player clicked two matching icons, keep them


' black and reset firstClicked and secondClicked
' so the player can click another icon
If firstClicked.Text = secondClicked.Text Then
firstClicked = Nothing
secondClicked = Nothing
Exit Sub
End If

3. Save and run the program. Play the game and match all of the icons. When you win, the program displays a
congratulatory MessageBox (as shown in the following picture), and then closes the box.

Matching game with MessageBox


To continue or review
To go to the next tutorial step, see Step 9: Try Other Features.
To return to the previous tutorial step, see Step 7: Keep Pairs Visible.
Step 9: Try Other Features
11/21/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

To learn more, try changing icons and colors, adding a game timer, and adding sounds. To make the game more
challenging, try making the board bigger and adjusting the timer.
To try other features
Replace the icons and colors with ones you choose.

TIP
Try looking at the label's Forecolor property.

Add a game timer that tracks how long it takes for the player to win.

TIP
To do this, you can add a label to display the elapsed time on the form above the TableLayoutPanel, and add another
timer to the form to track the time. Use code to start the timer when the player starts the game, and stop the timer
after they match the last two icons.

Add a sound when the player finds a match, another sound when the player uncovers two icons that don't
match, and a third sound when the program hides the icons again.

TIP
To play sounds, you can use the System.media namespace. See Play Sounds in Windows Forms App (C# .NET) or How
To Play Audio In Visual Basic for more information.

Make the game more difficult by making the board bigger.

TIP
You'll need to do more than just add rows and columns to the TableLayoutPanel – you'll also need to consider the
number of icons you create.

Make the game more challenging by hiding the first icon if the player is too slow to respond and doesn't
choose the second icon before a certain amount of time.
To continue or review
If you get stuck or have programming questions, try posting your question on one of the MSDN forums.
See Visual Basic Forum and Visual C# Forum.
There are great, free video learning resources available to you. To learn more about programming in Visual
Basic, see Visual Basic Fundamentals: Development for Absolute Beginners. To learn more about
programming in Visual C#, see C# Fundamentals: Development for Absolute Beginners.
To return to the previous tutorial step, see Step 8: Add a Method to Verify Whether the Player Won.
Getting Started with C++ in Visual Studio
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

By completing this walkthrough, you’ll become familiar with many of the tools and dialog boxes that you can use
when you develop applications with Visual Studio. You’ll create a simple "Hello, World"-style application while you
learn more about working in the integrated development environment (IDE).
This topic contains the following sections:
Sign In to Visual Studio
Create a simple application
Add Code to the Application
Debug and Test the application
Build a release version of the app

Sign In to Visual Studio


When you start Visual Studio for the first time, you are given the chance to sign in using a Microsoft account such
as Live or Outlook. Signing in allows your settings to be synchronized across all your devices. For more
information, see Signing in to Visual Studio
Figure 1: Visual Studio IDE
After you open Visual Studio, you can see the three basic parts of the IDE: tool windows, menus and toolbars, and
the main window space. Tool windows are docked on the left and right sides of the app window, with Quick
Launch , the menu bar, and the standard toolbar at the top. The center of the application window contains the Star t
Page . When you open a solution or project, editors and designers appear in this space. When you develop an
application, you’ll spend most of your time in this central area.

Create a simple application


When you create an app in Visual Studio, you first create a project and a solution. For this example, you’ll create a
Windows console application.
To create a console app
1. On the menu bar, choose File , New , Project .

2. In the Visual C++ category, choose the Win32 Console Application template, and then name the project
GreetingsConsoleApp .
3. When the Win32 Application Wizard appears, choose the Finish button.

The GreetingsConsoleApp project and solution, with the basic files for a Win32 console app, are created and
automatically loaded into Solution Explorer . The GreetingsConsoleApp.cpp file is opened in the code
editor. The following items appear in Solution Explorer :
Figure 4: Project items
Add Code to the Application
Next, you'll add code to display the word "Hello" in the console window.
To display “Hello” in the console window
1. In the GreetingsConsoleApp.cpp file, enter a blank line before the line return 0; and then enter the
following code:

cout << "Hello\n";

A red squiggly line appears under cout . An error message appears if you point to it.

The error message also appears in the Error List window. You can display the window by, on the menu bar,
choosing View , Error List .
cout is included in the <iostream> header file.
2. To include the iostream header, enter the following code after #include "stdafx.h" :

#include \<iostream\>
using namespace std;

You probably noticed that a box appeared as you entered code, providing suggestions for the characters that
you entered. This box is part of C++ IntelliSense, which provides coding prompts, including listing class or
interface members and parameter information. You can also use code snippets, which are pre-defined blocks
of code. For more information, see Using IntelliSense and Code Snippets.
The red squiggly line under cout disappears when you fix the error.
3. Save the changes to the file.

Debug and Test the application


You can debug GreetingsConsoleApp to see whether the word "Hello" appears in the console window.
To debug the application
Start the debugger.

The debugger starts and runs the code. The console window (a separate window that looks like a command
prompt) appears for a few seconds but closes quickly when the debugger stops running. To see the text, you
need to set a breakpoint to stop program execution.
To add a breakpoint
1. Add a breakpoint from the menu bar at the line return 0; . You can also just click in the left margin to set a
breakpoint.
A red circle appears next to the line of code in the far left margin of the editor window.
2. Choose the F5 key to start debugging.
The debugger starts, and a console window appears showing the word Hello .

3. Press SHIFT + F5 to stop debugging.


For more information, see Console Projects.

Build a release version of the app


Now that you’ve verified that everything works, you can prepare a release build of the application.
To clean the solution files and build a release version
1. From the menu bar, delete intermediate files and output files that were created during previous builds.

2. Change the build configuration for GreetingsConsoleApp from Debug to Release .


3. Build the solution.

Congratulations on completing this walkthrough! If you want to explore more examples, see Visual Studio
Samples.

See Also
Walkthrough: Create a Simple Application Productivity Tips Visual Studio Samples Get Started Developing with
Visual Studio
Getting Started with Debugging in Visual Studio 2015
10/16/2020 • 11 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Visual Studio 2015 provides a powerful integrated set of project build and debugging tools. In this topic, find out
how to start using the most basic set of debugging UI features.
Note: Links to more advanced features and platform- or feature-specific topics are at the bottom of this page.

My code doesn’t work. Help me, Visual Studio 2015!


So you’ve figured out the editor and you’ve created some code. Now, you want to start debugging that code. In
Visual Studio 2015, as with most IDEs, there are two phases to debugging: building the code to catch and resolve
project and compiler errors; and running that code in the environment to catch and resolve run-time and dynamic
errors.
Configuring a Build
There are two basic types of build configuration: Debug and Release . The first configuration produces a slower,
larger executable that allows for a richer interactive run-time debugging experience, but should never be shipped.
The second builds a faster, more optimized executable that’s appropriate to ship (at least from the perspective of
the compiler).
The default build configuration is Debug .

You can also specify a specific build platform to target, such as x86 (32-bit Intel CPUs), x64 (64-bit Intel CPUs), and
ARM (ARM CPUs, only supported for certain app types). The default is x86 for managed and native projects. To
change it, click on build platform dropdown and select a different platform or Configuration Manager…
You can specify a targeted build configuration using the Configuration Manager . Launch it, click the
Configuration or the CPU dropdown, and select New… to create a new build or platform.

Starting out, just use Debug and x86 as your build configuration and platform, respectively. When you’re done
coding and debugging, change the configuration to Release and target a specific platform. (Older versions of
Visual Studio provided an AnyCPU default platform for .Net code projects.)
Note: When you build your project, the configuration and platform values are also used to determine what project
directory path is created to store the executable. Typically, this is <path-to-project>\<project-name>\
<configuration>\<platform> . For example, a project with a configuration of Debug and a platform of x86
would be found under Projects\MyProjectNameHere\MyProjectNameHere\bin\Debug\x86 . This can be useful if you have
your own tools or scripts that manage these built executables.
Building your Code
With your build configured, it’s time to actually build your project. The easiest way to do it to press F7, but you can
also start the build by selecting Build->Build Solution from the main menu.

You can observe the build process in the Output status window at the bottom of the Visual Studio UI. Errors,
warnings, and build operations are displayed here. If you have errors (or if you have a warnings above a configured
level), your build will fail. You can click on the errors and warnings to go to the line where they occurred. Rebuild
your project by pressing either F7 again (to recompile only the files with errors) or Ctrl+Alt+F7 (for a clean and
complete rebuild).
There are two build tabbed windows in the results window below the editor: the Output window, which contains
the raw compiler output (including error messages); and the Error List window, which provides a sortable and
filterable list of all errors and warnings.
When successful, you will see results like this in the Output window.

Reviewing the Error List


Unless you’ve made no modifications to code you’ve previously and successfully compiled, you probably have an
error. If you’re new to coding, you probably have lots of them. Errors are sometimes obvious, such a simple syntax
error or incorrect variable name, and sometimes they are difficult to understand, with only a cryptic code to guide
you. For a cleaner view of the issues, navigate to the bottom of the build Output window, and click the Error List
tab. This takes you to a more organized view of the errors and warnings for your project, and gives you some extra
options as well.

Click on the error line in the Error List window and jump to the line the error occurs in. (Or turn on line numbers
by clicking in the Quick Launch bar in the upper-right, typing “line numbers” into it, and pressing Enter. This is the
fastest way to get to Options window entry where you can turn on line numbers. Learn to use the Quick Launch
bar and save yourself a lot of UI clicks!)

Use Ctrl+G to quickly jump to the line number where the error occurred.
The error is identified by a red “squiggle” underscore. Hover over it for additional details. Make the fix and it will go
away, although you may introduce a new error with the correction. (This is called a “regression”.)
Walk through the error list and address all the errors in your code.

Reviewing Errors in Detail


Many errors may make no sense to you, phrased as they are in the terms of the compiler. In those cases, you will
need additional information. From the Error List window, you can do an automatic Bing search for more
information on the error (or warning) by right-clicking on the corresponding entry line and selecting Show Error
Help from the context menu.

This launches a tab inside Visual Studio 2015 that hosts the results of a Bing search for the error code and text. The
results are from many different sources on the Internet, and not all may be helpful.
Alternatively, you can click on the hyperlinked error code value in the Code column of the Error List . This will
launch a Bing search for just the error code.
Performing Static Code Analysis
“Static code analysis” is a fancy way of saying “automatically check my code for common problems that can lead to
run-time errors or problems in code management”. Get in the habit of running it once you’ve cleaned up the
obvious errors preventing build, and take some time to address the warnings it may produce. You’ll save yourself
some headaches down the road, as well as learn a few code style techniques.
Press Alt+F11 (or select Analyze->Run Code Analysis on Solution from the top menu) to start static code
analysis. This may take some time if you have a lot of code.

Any new or updated warnings will appear in the Error List tab at the bottom of the IDE. Click on the warnings to
jump to them.
The warnings will be identified with a bright yellow-green squiggle instead of a red one. Hover over them for more
detail, and right-click on them to get a context menu to assist in fixes or refactoring options.

Using Light Bulbs to Fix or Refactor Code


Light Bulbs are a new feature for Visual Studio 2015 that let you refactor code inline. They are an easy way to fix
common warnings quickly and effectively. To access them, right-click on a warning squiggle (or press Ctrl+. while
hovering over the squiggle), and then select Quick Actions .

You will see a list of possible fixes or refactors you can apply to that line of code.

Light Bulbs can be used wherever the code analyzers determine there is an opportunity to fix, refactor, or improve
your code. Click on any line of code, right-click to open the context menu, and select Quick Options (or, again, if
you prefer efficiency, press Ctrl+.). If there is area refactoring or improvement options available, they will be
displayed; otherwise, the message No quick options available here will be displayed in the lower-left corner bezel
of the IDE.

With experience, you can quickly use the arrow keys and Ctrl+. to check for Quick Option refactoring opportunities
and clean up your code!
For more information on Light Bulbs, read Perform quick actions with light bulbs.
Debugging Your Running Code
Now that you’ve successfully built your code and performed a little clean up, run it by pressing F5 or selecting
Debug->Star t Debugging . This will start your app in a debug environment so you can observe its behavior in
detail. The Visual Studio 2015 IDE changes while your app is running: the Output window is replaced by two new
ones (in the default window configuration), the Autos/Locals/Modules/Watch tabbed window and the Call
Stack/Breakpoints/Exception Settings/Output tabbed window. These windows have multiple tabs which allow
you to inspect and evaluate your app’s variables, threads, call stacks, and various other behaviors as it runs.

Try various actions with your app and observe the changes. If something appears abnormal, pause the app by
pressing Ctrl+Alt+Break (or click on the Pause button).

Press F5 to continue running the app (or click the Continue button).

You can stop your app by pressing Shift+F5 or by clicking the Stop button. Or, you can simply close the app’s main
window (or command line dialog).
If your code ran perfectly and exactly as expected, congratulations! Change the build configuration to Release and
rebuild it for deployment! (Professionals may want to jump to the bit on Unit Testing at the end, though.) However,
if it stops responding, or crashed, or gave you some strange results, you’ll need to find the source of those
problems and fix the bugs.
Setting Simple Breakpoints
Breakpoints are the most basic and essential feature of reliable debugging. A breakpoint indicates where Visual
Studio should suspend your running code so you can take a look at the values of variables, or the behavior of
memory, or whether or not a branch of code is getting run. You do NOT need to rebuild a project after setting and
removing breakpoints.
Set a breakpoint by clicking in the far margin of the line where you want the break to occur, or select the line of
code and press F9. When you run your code, it will stop before the instructions for this line of code are executed.

When the code breaks, the marked line of code has not executed yet. At this point, you may want to execute the
instructions for the line of code marked by the breakpoint and inspect the changed values. This is called “stepping
into” the code. If the marked code is a method call, you can step into it by pressing F11. You can also “step over” the
line of code by pressing F10. For more details on breakpoint step actions, read Navigating through Code with the
Debugger.
Common uses for breakpoints include:
1. To narrow down the source of a crash or program not responding, scatter them throughout and around the
code of the method call you think is causing the failure. As you step through the code, remove and then
reset the breakpoints closer together until you find the offending line of code.
2. When you introduce new code, set a breakpoint at the beginning of it and step through the code to make
sure it is behaving as expected.
3. If you have implemented a complicated behavior, set breakpoint(s) for the algorithmic code so you can
inspect the values of the variables and data when the program breaks.
4. If you are writing C or C++ code, use breakpoints to stop the code so you can inspect address values (look
for NULL) and reference counts when debugging for memory-related failures.
For more information on using breakpoints, read Using Breakpoints
Setting Conditional Breakpoints
If you have a breakpoint in a loop or recursion, or if you have a lot of breakpoints which you frequently step
through, use a conditional breakpoint to ensure that your code is suspended ONLY when specific conditions are
met. Otherwise, you’ll be pressing F11 an awful lot.
To set a conditional breakpoint and suspend your code when a variable is set to a certain value or passes a certain
threshold, click in the margin to set a breakpoint, and then select the “cog” from the hover menu that appears.

You will see a dialog that looks like this where you can set specific conditions for the break to occur.
For more detail on how to declare the expressions used to evaluate conditional breakpoints, check out the
Channel9 video Breakpoint Configuration Experience in Visual Studio 2015.
Inspecting Your Code at Run-time
When your running code hits a breakpoint and halts, you can inspect your variables and call stacks to determine
what is going on. Are the values in the ranges you expect to see? Are calls being made in the right order?

Hover over a variable to see the value(s) and reference(s) it currently contains. If you see a value you didn’t expect,
you probably have a bug in the preceding or calling lines of code. Move breakpoints up or add conditions to the
existing breakpoints to narrow your search further.
Additionally, Visual Studio 2015 displays the Diagnostic Tools window, where you can observe your app’s CPU and
memory usage over time. Use them to look for unanticipated heavy CPU usage or memory allocation. Use it in
conjunction with the Watch window and breakpoints to determine what’s causing unexpected heavy usage or
unreleased resources.
Running Unit Tests
Unit tests are programs that exercise code paths in your app or service. Visual Studio 2015 installs the Microsoft
unit testing frameworks for both managed and native code. Use a unit testing framework to create unit tests, run
them, and report the results of these tests. Rerun unit tests when you make changes to test that your code is still
working correctly. When you use Visual Studio 2015 Enterprise, you can run tests automatically after every build.
To get started, read Generate unit tests for your code with IntelliTest.
To learn more about unit tests in Visual Studio 2015 and how they can help you create better quality code, read
Unit Test Basics.

See Also
Debugging in Visual Studio Debugger Settings and Preparation Debug 64-Bit Applications Debugger Basics
Solutions and Projects in Visual Studio
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

When you create an app, application, website, Web App, script, plug-in, etc in Visual Studio, you start with a
project. In a logical sense, a project contains of all the source code files, icons, images, data files and anything else
that will be compiled into an executable program or web site, or else is needed in order to perform the
compilation. A project also contains all the compiler settings and other configuration files that might be needed
by various services or components that your program will communicate with.
In a literal sense, a project is an XML file (*.vbproj, *.csproj, *.vcxproj) that defines a virtual folder hierarchy along
with paths to all the items it "contains" and all the build settings. In Visual Studio, the project file is used by
Solution Explorer to display the project contents and settings. When you compile your project, the MSBuild
engine consumes the project file to create the executable. You can also customize projects to product other kinds
of output.
A project is contained, in a logical sense and in the file system, within a solution, which may contain one or more
projects, along with build information, Visual Studio window settings, and any miscellaneous files that aren't
associated with any project. In a literal sense, the solution is a text file with its own unique format; it is generally
not intended to be edited by hand.
A solution has an associated *.suo file that stores settings, preferences and configuration information for each
user that has worked on the project.
The following diagram shows the relationship between projects and solutions, and the items they logically
contain.

You can also create custom project and item templates. For more information, see Creating Project and Item
Templates.

Creating new projects


The easiest way to create a new project is to start with a pre-defined project template, which consists of a basic
set of pre-generated code files, config files, assets, and settings that get you started creating a particular type of
application or website in a particular programming language. These templates are what you see in the New
Project Dialog when you choose File | New | Project or File | New | Web Site from the main menu, and
then navigate. For more information, see Creating Solutions and Projects and NIB Creating Projects from
Templates.

Managing projects in Solution Explorer


After you create a new project, you use Solution Explorer to view and manage projects and solutions and their
associated items. The following illustration shows Server Explorer with a C# solution that contains two projects.

In This Section
Creating Solutions and Projects
Adding and Removing Project Items
Managing Project and Solution Properties
Managing references in a project
Application Properties
Managing Assembly and Manifest Signing
How to: Specify an Application Icon (Visual Basic, C#)
Targeting a Specific .NET Framework Version
Creating Project and Item Templates
See Also
Visual Studio IDE
Creating Solutions and Projects
1/10/2020 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Projects are the logical containers for everything that's needed to build your application. When you create a
project by choosing File | New | Project from the main menu, Visual Studio creates a solution to contain it. You
can then add more new or existing projects to the solution if necessary. You can create projects from existing code
files and you can create temporary projects (.NET only) that will be deleted when you are done with them.

NOTE
The descriptions in this topic are based on the Visual Studio Community edition. The dialog boxes and menu commands you
see might differ from those described here, depending on your settings or Visual Studio edition. To change your settings,
choose Impor t and Expor t Settings on the Tools menu. For more information, see Customizing Development Settings in
Visual Studio.

Create a project from an installed project template


File | New | Project from the main menu to bring up the New Project dialog. In the left pane under Intalled |
Templates chose the programming language and platform or technology, then choose from the available
templates in the middle pane.
In the New Project dialog, the Solution drop-down gives you the option to create the new project in a new or
existing solution, or in a new instance of Visual Studio.

Create a project from existing code files


If you have a collection of loose source files, you can easily create a project that contains them. Choose File | New
|Project From Existing Code to start the Create Project from Existing Code Files Wizard and follow the
prompts.

TIP
This option works best for relatively simple collections of files.

Create a temporary project (C# and Visual Basic)


By working with temporary projects, you can create and experiment with a .NET project without specifying a disk
location. When you create a project, you just select a project type and template and specify a name in the New
Project dialog box. At any time while you are working with the temporary project, you can save it, or you can
discard it.

Create a .NET project that targets a specific version of the .NET


Framework
You can create a project to target earlier versions of the .NET Framework by using the .NET Framework version
drop-down menu at the top of the New Project dialog box. Set this value before selecting a project template, as
only templates compatible with that .NET Framework version will appear in the list.
You must have .NET Framework 3.5 installed on your system to access framework versions earlier than 4.0.

Downloading Sample Solutions


You can use Visual Studio to download and install sample solutions from the MSDN Code Gallery.
You can download the samples individually, or you can download a Sample Pack, which contains related samples
that share a technology or topic. You'll receive a notification when source code changes are published for any
sample that you download.
For more information, see Visual Studio Samples.

Adding single files at the solution level


Sometimes you might have a file that multiple projects refer to, or that contains text or miscellaneous data that
logically belongs at the solution level rather than under a specific project. To add a single item to a solution:
1. Right-click on the solution node in Solution Explorer and choose Add | New Item or Add | Existing Item .

Creating Empty Solutions


Although a project must reside in a solution, you can create a solution that has no projects.
To create an empty solution
1. On the File menu, click New and then click New Project .
2. In the left pane, select Installed , select Other Project Types , and then select Visual Studio Solutions
from the expanded list.
3. In the middle pane, select Blank Solution .
4. Set the Name and Location values for your solution, then click OK .
After you create an empty solution, you can add new or existing projects or items to it by clicking Add New
Item or Add Existing Item on the Project menu.
Deleting Solutions
You can delete a solution permanently, but not by using Visual Studio. Before you delete a solution, move any
projects that you might want to use again in another solution. Then use File Explorer to delete the directory that
contains the .sln and .suo solution files.

NOTE
The .suo file is a hidden file that is not displayed under default File Explorer settings.

To d e l e t e a so l u t i o n

1. In Solution Explorer , right-click the solution to delete, and select Open folder in File Explorer .
2. In File Explorer, navigate up one level.
3. Select the directory containing the solution and press Delete.
See Also
Solutions and Projects NIB How to: Create Multi-Project Solutions
Adding and Removing Project Items
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can add or remove projects and project items by right-clicking on the project or solution node in Solution
Explorer , and choosing Add or Remove . Removing a project from a solution, or an item from a project, does not
delete it from disk or source control unless you select the option to delete it permanently.

See Also
Solutions and Projects Managing Project and Solution Properties
Managing Project and Solution Properties
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Projects have properties that govern many aspects of compilation, debugging, testing and deploying. Some
properties are common among all project types, and some are unique to specific languages or platforms. You
access project properties by right-clicking the project node in Solution Explorer and choosing Properties, or by
typing properties into the QuickLaunch search box in the menu bar.

.NET projects also have a properties node in the project tree itself.

TIP
Solutions have a few properties, and so do project items; these properties are accessed in the Properties Window, not
Project Designer .

Project Properties
Project Properties are organized into groups and each group has its own property page, and the pages might be
different for different languages and project types.
C# and Visual Basic projects
In C# and Visual Basic projects, properties are exposed in the Project Designer . The following illustration shows
the Build property page for a WPF project in C#:

For information about each of the property pages in Project Designer, see Project Properties Reference.
C++ and JavaScript projects
C++ and JavaScript projects have a different user interface for managing project properties. This illustration shows
a C++ project property page (JavaScript pages are similar):

For information about C++ project properties, see Working with Project Properties. For more information about
JavaScript properties, see Property Pages, JavaScript.

Solution Properties
To access properties on the solution, right click the solution node in Solution Explorer and choose Proper ties . In
the dialog, you can set project configurations for Debug or Release builds, choose which projects(s) should be the
startup project when F5 is pressed, and set code analysis options.

See Also
Solutions and Projects in Visual Studio
Managing references in a project
10/18/2019 • 6 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Before you write code against an external component or connected service, your project must first contain a
reference to it. A reference is essentially an entry in a project file that contains the information that Visual Studio
needs to locate the component or the service.
To add a reference, right click on the References node in Solution Explorer and choose Add Reference . For more
information, see How to: Add or Remove References By Using the Reference Manager.

You can make a reference to the following types of components/services:


Windows Store app references
.NET Framework class libraries or assemblies
COM components
Other assemblies or class libraries of projects in the same solution
XML Web services

Windows Store App References


Project References
Universal Windows Platform (UWP) projects that target Windows 10 can create references to other UWP projects
in the solution, or to Windows Store projects or binaries that target Windows 8.1, provided that these projects do
not use APIs that have been deprecated in Windows 10. For more information, see Move from Windows Runtime
8 to UWP.
If you choose to retarget Windows 8.1 projects to Windows 10, see Porting, Migrating, and Upgrading Visual
Studio Projects
Extension SDK References
Visual Basic, C#, C++ and JavaScript Windows Store projects that target the Universal Windows Platform (UWP)
can reference Extension SDKs that target Windows 8.1, as long as these Extension SDKs do not use APIs that have
been deprecated in Windows 10. Please check the Extension SDK vendor site to find out whether it can be
referenced by Windows Store projects that target UWP.
If you determine that the Extension SDK being referenced by your app is not supported, then you need to perform
the following steps:
1. Look at the name of the project that is causing the error. The platform your project is targeting is noted in
parentheses next to the project name. For example, MyProjectName (Windows 8.1) means that your
project MyProjectName is targeting platform version Windows 8.1.
2. Go to the site of the vendor who owns the unsupported Extension SDK and install the version of the
Extension SDK with dependencies that are compatible with the version of the platform your project is
targeting.

NOTE
One way to find out whether an Extension SDK has dependencies on other Extension SDKs is to restart Visual Studio,
create a new C# Windows Store project, right-click on the project and choose Add Reference , go to the Windows
tab, go to the Extensions sub-tab, select the Extension SDK and look at the right pane in the Reference Manager .
If it has dependencies, they will be listed there.

IMPORTANT
If your project is targeting Windows 10, and the Extension SDK installed in the previous step has a dependency on
the Microsoft Visual C++ Runtime Package, the version of Microsoft Visual C++ Runtime Package that is compatible
with Windows 10 is v14.0 and is installed with Visual Studio 2015.

3. If the Extension SDK you installed in the previous step has dependencies on other Extension SDKs, go to the
site(s) of the vendor(s) who own the dependencies and install the versions of these dependencies that are
compatible with the version of the platform your project is targeting.
4. Restart Visual Studio and open your app.
5. Right-click on the References node in the project that caused the error and choose Add Reference
6. Click the Windows tab and then the Extensions sub-tab, then uncheck the checkboxes for the old
Extension SDKs and check the checkboxes for the new Extension SDKs. Click OK .

Adding a Reference at Design Time


When you make a reference to an assembly in your project, Visual Studio searches for the assembly in the
following locations:
The current project directory. (You can find these assemblies by using the Browse tab.)
Other project directories in the same solution. (You can find these assemblies on the Projects tab.)
NOTE
All projects contain an implied reference to mscorlib. Visual Basic projects contain an implied reference to
Microsoft.VisualBasic .

All projects in Visual Studio contain an implied reference to System.Core , even if System.Core is removed from the list of
references.

References to Shared Components at Run Time


At run time, components must be either in the output path of the project or in the Global Assembly Cache (GAC). If
the project contains a reference to an object that is not in one of these locations, you must copy the reference to
the output path of the project when you build the project. The CopyLocal property indicates whether this copy has
to be made. If the value is True , the reference is copied to the project directory when you build the project. If the
value is False , the reference is not copied.
If you deploy an application that contains a reference to a custom component that is registered in the GAC, the
component will not be deployed with the application, regardless of the CopyLocal setting. In earlier versions of
Visual Studio, you could set the CopyLocal property on a reference to ensure that the assembly was deployed.
Now, you must manually add the assembly to the \Bin folder. This puts all custom code under scrutiny, reducing
the risk of publishing custom code with which you are not familiar.
By default, the CopyLocal property is set to False if the assembly or component is in the global assembly cache or
is a framework component. Otherwise, the value is set to True . Project-to-project references are always set to
True .

Referencing a Project or Assembly That Targets a Different Version of


the .NET Framework
You can create applications that reference projects or assemblies that target a different version of the .NET
Framework. For example, you could create an application that targets the .NET Framework 4 Client Profile that
references an assembly that targets .NET Framework 2.0. If you create a project that targets an earlier version of
the .NET Framework, you cannot set a reference in that project to a project or assembly that targets the .NET
Framework 4 Client Profile or .NET Framework version 4.
For more information, see Targeting a Specific .NET Framework Version.

Project-to-Project References
Project-to-project references are references to projects that contain assemblies; you create them by using the
Project tab. Visual Studio can find an assembly when given a path to the project.
When you have a project that produces an assembly, you should reference the project and not use a file reference
(see below). The advantage of a project-to-project reference is that it creates a dependency between the projects in
the build system. The dependent project will be built if it has changed since the last time the referencing project
was built. A file reference does not create a build dependency, so it is possible to build the referencing project
without building the dependent project, and the reference can become obsolete. (That is, the project can reference
a previously built version of the project.) This can result in several versions of a single DLL being required in the
bin directory, which is not possible. When this conflict occurs, you will see a message such as Warning: the
dependency 'file' in project 'project' cannot be copied to the run directory because it would overwrite the
reference 'file.'. For more information, see Troubleshooting Broken References and How to: Create and Remove
Project Dependencies.
NOTE
A file reference instead of a project-to-project reference is created if the target version of the .NET Framework of one project
is version 4.5, and the target version of the other project is version 2, 3, 3.5, or 4.0.

File References
File references are direct references to assemblies outside the context of a Visual Studio project; you create them
by using the Browse tab of the Reference Manager . Use a file reference when you just have an assembly or
component and don't have the project that creates it as output.

See Also
Troubleshooting Broken References Programming with Assemblies How to: Add or Remove References By Using
the Reference Manager
How to: Add or Remove References By Using the
Reference Manager
1/10/2020 • 13 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can use the Reference Manager dialog box to add and manage references to components that you,
Microsoft, or another company developed. If you're developing a Universal Windows app, your project
automatically references all of the correct Windows SDK DLLs. If you are developing a .NET application, your
project automatically references mscorlib.dll. Some .NET APIs are exposed in components that you have to add
manually. References to COM components or custom components have to be added manually.

Adding and Removing a Reference


To Add a Reference
1. In Solution Explorer , right-click on the References node and choose Add Reference .
2. Specify the references to add, and then choose the OK button.
Reference Manager opens and lists the available references by group. The project type determines which
of the following groups appear:
Assemblies, with the Framework and Extensions subgroups.
Solution, with the Projects subgroup.
Windows, with the Core and Extensions subgroups. You can explore the references in the Windows SDK or
extension SDKs by using the Object Browser .
Browse, with the Recent subgroup.

Assemblies tab
The Assemblies tab lists all .NET Framework assemblies that are available for referencing. The Assemblies tab
doesn’t list any assemblies from the global assembly cache (GAC) because assemblies in the GAC are part of the
run-time environment. If you deploy or copy an application that contains a reference to an assembly that’s
registered in the GAC, the assembly won’t be deployed or copied with the application, regardless of the Copy Local
setting. For more information, see Project References.
When you manually add a reference to any of the EnvDTE namespaces (EnvDTE, EnvDTE80, EnvDTE90, EnvDTE90a,
or EnvDTE100), set the Embed Interop Types property of the reference to False in the Properties window. Setting
this property to True can cause build issues because of certain EnvDTE properties that can’t be embedded.
All desktop projects contain an implicit reference to mscorlib. Visual Basic projects contain an implicit reference to
Microsoft.VisualBasic. In Visual Studio 2012, all projects contain an implicit reference to System.Core, even if it’s
removed from the list of references.
If a project type doesn’t support Assemblies, the tab won’t appear in the Reference Manager dialog box.
The Assemblies tab consists of two sub-tabs:
1. Framework lists all assemblies that constitute the targeted Framework.
Advertised assemblies are in the Full Framework and enumerated in the Framework list when your
project targets a Profile of the targeted Framework. Advertised assemblies are grey to differentiate
them from the assemblies that exist in the targeted Framework profile of the project. For example, if a
project targets .NET Framework 4 Client, the Framework list shows advertised assemblies from .NET
Framework 4. When a user adds an advertised assembly, the user is notified that, after the
Reference Manager dialog box is closed, the project will be retargeted to the .NET Framework 4
and the advertised assembly will be added.
Projects for Windows 8.x Store apps contain references to all of the assemblies in the targeted .NET
for Windows 8.x Store apps by default on project creation. In managed projects, a read-only node
under the References folder in Solution Explorer indicates the reference to the entire Framework.
Accordingly, the Framework tab won’t enumerate any of the assemblies from the Framework and
instead display the following message: “All of the Framework assemblies are already referenced.
Please use the Object Browser to explore the references in the Framework.” For desktop projects, the
Framework tab enumerates assemblies from the targeted Framework, and the user must add the
references that the application requires.
2. Extensions lists all assemblies that external vendors of components and controls have developed to extend
the targeted Framework. Depending on the purpose of the user application, it might need these assemblies.
Extensions is populated by enumerating the assemblies that are registered in the following locations:

32-bit machine:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\[Target Framework Identifier]\v[Target Framework
Version]\AssemblyFoldersEx\[UserComponentName]\@default=[Disk location of assemblies]
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\[Target Framework Identifier]\v[Target Framework
Version]\AssemblyFoldersEx\[UserComponentName]\@default=[Disk location of assemblies]
64-bit machine:
HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\[Target Framework Identifier]\v[Target Framework
Version]\AssemblyFoldersEx\[UserComponentName]\@default=[Disk location of assemblies]
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\[Target Framework Identifier]\v[Target
Framework Version]\AssemblyFoldersEx\[UserComponentName]\@default=[Disk location of assemblies]
And older versions of the [Target Framework Identifier]

For example, if a project targets the .NET Framework 4 on a 32-bit machine, Extensions will
enumerate assemblies that are registered under
\Microsoft\.NETFramework\v4.0\AssemblyFoldersEx\,
\Microsoft\.NETFramework\v3.5\AssemblyFoldersEx\,
\Microsoft\.NETFramework\v3.0\AssemblyFoldersEx\, and
\Microsoft\.NETFramework\v2.0\AssemblyFoldersEx\.
Some components in the list may not be shown, depending on the .NET Framework version of your project.
This can occur under the following conditions:
A component that uses a recent version of the .NET Framework is incompatible with a project that targets an
earlier version of the .NET Framework.
For information about how to change the target .NET Framework version for a project, see How to: Target a
Version of the .NET Framework.
A component that uses .NET Framework 4 is incompatible with a project that targets the .NET Framework
4.5.
When you create a new application, some projects target the .NET Framework 4.5 by default. For more
information, see .NET Framework Client Profile.
You should avoid adding file references to outputs of another project in the same solution, because doing
this may cause compilation errors. Instead, use the Projects tab of the Add Reference dialog box to create
project-to-project references. This makes team development easier by enabling better management of the
class libraries you create in your projects. For more information, see Troubleshooting Broken References.

NOTE
In Visual Studio 2015, a file reference instead of a project reference is created if the target version of the .NET
Framework of one project is version 4.5, and the target version of the other project is version 2, 3, 3.5, or 4.0.

To display an assembly in the Add Reference dialog box


Move or copy the assembly to one of the following locations:
The current project directory. (You can find these assemblies by using the Browse tab.)
Other project directories in the same solution. (You can find these assemblies by using the Projects
tab.)
- or -
Set a registry key that specifies the location of assemblies to display:
For a 32-bit operating system, add one of the following registry keys.
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\.NETFramework\VersionMinimum\AssemblyFoldersE
x\MyAssemblies]@="AssemblyLocation"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\VersionMinimum\AssemblyFolders
Ex\MyAssemblies]@="AssemblyLocation"
For a 64-bit operating system, add one of the following registry keys in a 32-bit registry hive.
[HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\VersionMinimum\A
ssemblyFoldersEx\MyAssemblies]@="AssemblyLocation"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\VersionMinimum\
AssemblyFoldersEx\MyAssemblies]@="AssemblyLocation"
VersionMinimum is the lowest .NET Framework version that applies. If VersionMinimum is v3.0,
folders specified in AssemblyFoldersEx apply to projects that target .NET Framework 3.0 and later.
AssemblyLocation is the directory of the assemblies that you want to appear in the Add Reference
dialog box, for example, C:\MyAssemblies\.
Creating the registry key under the HKEY_LOCAL_MACHINE node allows all users to see the
assemblies in the specified location in the Add Reference dialog box. Creating the registry key
under the HKEY_CURRENT_USER node affects only the setting for the current user.
Open the Add Reference dialog box again. The assemblies should appear on the .NET tab. If they do
not, make sure that the assemblies are located in the specified AssemblyLocation directory, restart
Visual Studio, and try again.

COM tab
The COM tab lists all COM components that are available for referencing. If you want to add a reference to a
registered COM DLL that contains an internal manifest, unregister the DLL first. Otherwise, Visual Studio adds the
assembly reference as an ActiveX Control instead of as a native DLL.
If a project type doesn’t support COM, the tab won’t appear in the Reference Manager dialog box.

Solution tab
The Solution tab lists all compatible projects within the current solution, in the Projects sub-tab.
A project can reference another project that targets a different version of the .NET Framework. For example, you
could create a project that targets the .NET Framework 4 but that references an assembly that’s been built for the
.NET Framework 2. However, the .NET Framework 2 project can’t reference a .NET Framework 4 project. For more
information, see Targeting a Specific .NET Framework Version.
A project that targets the .NET Framework 4 is incompatible with a project that targets the .NET Framework 4 Client
Profile.
In Visual Studio 2012, a file reference instead of a project reference is created if one project targets the .NET
Framework 4 and another project targets an earlier version.
A project that targets the .NET for Windows 8.x Store apps can’t add a project reference to a project that targets the
.NET Framework and vice versa.

Windows tab
The Windows tab lists all SDKs that are specific to platforms on which Windows operating systems run.
You can generate a WinMD file in Visual Studio in two ways:
Windows 8.x Store app managed projects : Windows 8.x Store app projects can output WinMD binaries
by setting Project Properties | Output Type = WinMD File. The WinMD filename must be the superset
namespace of all the namespaces that exist within it. For example, if a project consists of namespaces A.B
and A.B.C, the possible names for its outputted WinMD are A.winmd and A.B.winmd. If a user enters a
Project Properties | Assembly Name or Project Properties | Namespace value that’s disjoint from the set of
namespaces in the project or there is no superset namespace within a project, a build warning is generated:
'A.winmd' isn’t a valid .winmd file name for this assembly. All types within a Windows Metadata file must
exist in a sub namespace of the file name. Types that don’t exist in a sub namespace of the file name won’t
be able to be located at runtime. In this assembly, the smallest common namespace is 'CSWSClassLibrary1'.
A desktop Visual Basic or Visual C# project can only consume WinMDs that are generated by using the
Windows 8 SDKs, which are known as first-party WinMDs, and can’t generate WinMDs.
Windows 8.x Store app native projects : A native WinMD file consists of only metadata. Its
implementation exists in a separate DLL file. One can produce native binaries by choosing the Windows
Runtime Component project template in the New Project dialog box or by starting from a blank project
and modifying the project properties to generate a WinMD file. If the project consists of disjoint
namespaces, a build error will tell the user to combine their namespaces or run the MSMerge tool.
The Windows tab consists of two subgroups.
Core Subgroup
The Core subgroup lists all of the WinMDs (for Windows Runtime elements) in the SDK for the targeted version of
Windows.
Windows 8.x Store app projects contain references to all of the WinMDs in the Windows 8 SDK by default on
project creation. In managed projects, a read-only node under the References folder in Solution Explorer
indicates the reference to the entire Windows 8 SDK. Accordingly, the Core subgroup in the Reference Manager
won’t enumerate any of the assemblies from the Windows 8 SDK and instead displays a message: “The Windows
SDK is already referenced. Please use the Object Browser to explore the references in the Windows SDK.”
In the desktop projects, the Core subgroup doesn’t appear by default. You can add the Windows Runtime by
opening the shortcut menu for the project node, choosing Unload Project , adding the following snippet, and re-
opening the project (on the project node, choose Reload Project ). When you invoke the Reference Manager
dialog box, the Core subgroup appears.

<PropertyGroup>
<TargetPlatformVersion>8.0</TargetPlatformVersion>
</PropertyGroup>

Make sure to select the Windows check box on this subgroup. You should then be able to use Windows Runtime
elements. However, you'll also want to add System.Runtime, in which the Windows Runtime defines some standard
classes and interfaces, such as IEnumerable, that are used throughout the Windows Runtime libraries. For
information about how to add System.Runtime, see Managed desktop apps and Windows Runtime.
Extensions Subgroup
Extensions lists the user SDKs that extend the targeted Windows platform. This tab appears for Windows 8.x Store
app projects only. Desktop projects won’t show this tab because they can consume only first-party .winmd files.
An SDK is a collection of files that Visual Studio treats as a single component. In the Extensions tab, SDKs that apply
to the project from which the Reference Manager dialog box was invoked are listed as single entries. When
added to a project, all of the SDK content is consumed by Visual Studio such that the user doesn’t need to take any
further actions to leverage the SDK contents in IntelliSense, toolbox, designers, Object Browser, build, deployment,
debugging, and packaging. For information about how to display your SDK in the Extensions tab, see Creating a
Software Development Kit.

NOTE
If a project references an SDK that depends on another SDK, Visual Studio won’t consume the second SDK unless the user
manually adds a reference to the second SDK. When a user chooses an SDK on the Extensions tab, the Reference
Manager dialog box helps the user identify SDK dependencies by listing not only the name and version of the SDK but also
the name of any SDK dependencies in the details pane. If a user doesn’t notice the dependencies and only adds that SDK,
MSBuild will prompt the user to add the dependencies.

If a project type doesn’t support Extensions , the tab doesn’t appear in the Reference Manager dialog box.

Browse button
You can use the Browse button to browse for a component in the file system.
A project can reference a component that targets a different version of the .NET Framework. For example, you
could create an application that targets the .NET Framework 4 Client Profile, which references a component that
targets the .NET Framework 2. For more information, see Targeting a Specific .NET Framework Version.
You should avoid adding file references to outputs of another project in the same solution, because this tactic may
cause compilation errors. Instead, use the Solution tab of the Reference Manager dialog box to create project-
to-project references. This tactic makes team development easier by enabling better management of the class
libraries that you create in your projects. For more information, see Troubleshooting Broken References.
You can’t browse to an SDK and add it to your project. You can only browse to a file (for example, an assembly or
.winmd) and add it to your project.
When doing a file reference to a WinMD, the expected layout is that the FileName.winmd, FileName.dll, and
FileName.pri files are all placed alongside each other. If you reference a WinMD in the following scenarios, an
incomplete set of files will be copied into the project output directory and, consequently, build and runtime failures
will occur.
Native component : a native project will create one WinMD for each disjoint set of namespaces and one
DLL that consists of the implementation. The WinMDs will have disparate names. When referencing this
native component file, MSBuild won’t recognize that the dissimilarly named WinMDs make one component.
Consequently, only the identically named FileName.dll and FileName.winmd will be copied, and runtime
errors will occur. To work around this issue, create an Extension SDK. For more information, see Creating a
Software Development Kit.
Consuming controls : at a minimum, a XAML control consists of a FileName.winmd, FileName.dll,
FileName.pri, XamlName.xaml, and an ImageName.jpg. When the project is built, the resource files that are
associated with the file reference won’t get copied into the project’s output directory, and only
FileName.winmd, FileName.dll and FileName.pri will be copied. A build error is logged to inform the user
that the resources XamlName.xaml and ImageName.jpg are missing. To succeed, the user will have to
manually copy these resource files into the project output directory for build and debugging/runtime. To
work around this issue, either create an Extension SDK by following the steps in Creating a Software
Development Kit or edit the project file to add the following property:

<PropertyGroup>
<GenerateLibraryOutput>True</GenerateLibraryOutput>
</PropertyGroup>

NOTE
If you add the property, the build might run slower.

Recent
Assemblies, COM, Windows, and Browse each support a Recent tab, which enumerates the list of components that
were recently added to projects.

Search
The search bar in the Reference Manager dialog box operates over the tab that’s in focus. For example, if a user
types “System” in the search bar while the Solution tab is in focus, the search won’t return any results unless the
solution consists of a project name that contains “System”.

See Also
NIB How to: Add or Remove References By Using the Add Reference Dialog Box Managing references in a project
Adding References Using NuGet Versus an Extension
SDK
1/13/2020 • 7 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can provide a package for consumption within Visual Studio projects by using either the NuGet extension to
Visual Studio or a software development kit (SDK). By describing the similarities and differences between the two
mechanisms, this topic can help you choose the best one for your task.
NuGet is an open-source, package-management system that simplifies the process of incorporating libraries
into a project solution. For more information, see NuGet Overview.
An SDK is a collection of files that Visual Studio treats as a single reference item. The Reference Manager
dialog box lists all SDKs that are relevant to the project that’s open when you display that dialog box. When
you add an SDK to a project, you can access all of the contents of that SDK through IntelliSense, the Toolbox ,
designers, the Object Browser , MSBuild, deployment, debugging, and packaging. For more information
about SDKs, see Creating a Software Development Kit.

Which Mechanism Should I Use?


The following table helps you compare the referencing features of an SDK with the referencing features of NuGet.

F EAT URE SDK SUP P O RT SDK N OT ES N UGET SUP P O RT N UGET N OT ES

The mechanism Y You add an SDK by Y


references one entity using the Reference
and then all the files Manager dialog box,
and functionality are and all the files and
available. functionality are
available during the
development
workflow.

MSBuild automatically Y References in the SDK Y


consumes assemblies are automatically
and Windows passed to the
metadata (.winmd) compiler.
files.

MSBuild automatically Y The SDKName.props N


consumes the .h or file tells Visual Studio
.lib files. how to set up the
Visual C++ directory,
and so forth, for
automatic .h or .lib file
consumption.
F EAT URE SDK SUP P O RT SDK N OT ES N UGET SUP P O RT N UGET N OT ES

MSBuild automatically Y In Solution Y


consumes the .js or Explorer , you can
.css files. expand the JavaScript
SDK reference node
to show individual .js
or .css files and then
generate
<source include/>
tags by dragging
those files to their
source files. The SDK
supports F5 and
automatic package
setup.

MSBuild automatically Y The Toolbox can N


adds the control in consume SDKs and
the Toolbox. show controls in the
tabs that you specify.

The mechanism Y VSIX has a special Y The VSIX can be


supports Visual manifest and logic to embedded in another
Studio Installer for create SDK packages setup program.
extensions (VSIX).

The Object Browser Y The Object Browser N


enumerates automatically gets the
references. list of references in
SDKs and enumerates
them.

Files and links Y The Reference N NuGet provides its


automatically get Manager dialog box own Manage NuGet
added to the automatically Packages dialog box.
Reference Manager enumerates SDKs,
dialog box (help links, along with help links
and so forth auto and the list of SDK
populate) dependencies.

The mechanism Y SDKs can ship N


supports multiple multiple
architectures. configurations.
MSBuild consumes
the appropriate files
for each project
configuration.

The mechanism Y SDKs can ship N


supports multiple multiple
configurations. configurations.
Depending on project
architecture, MSBuild
consumes the
appropriate files for
each project
architecture.
F EAT URE SDK SUP P O RT SDK N OT ES N UGET SUP P O RT N UGET N OT ES

The mechanism can Y Depending on N You declare which files


specify “not to copy.” whether files are to copy in the
dropped in the \redist package manifest.
or \designtime folder,
you can control which
files to copy into the
consuming
application's package.

Content appears in Y Localized XML N


localized files. documents in SDKs
are automatically
included for a better
design-time
experience.

MSBuild supports Y The SDK supports N This isn't referencing.


consuming multiple consuming multiple You can’t have more
versions of an SDK versions than one version of
simultaneously. simultaneously. NuGet files in your
project at a time.

The mechanism Y The Reference Y (partial) Pivot is the Target


supports specifying Manager dialog box Framework. There is
applicable target and the Toolbox no filtering on user
frameworks, Visual show only the SDKs interface. At
Studio versions, and that apply to a installation time, it
project types. project, so that users might return an error.
can more easily
choose the
appropriate SDKs.

The mechanism Y You can specify the N


supports specifying correlation between
registration info for the .winmd file and
native WinMDs. the .dll file in
SDKManifest.xml.

The mechanism Y The SDK only notifies Y NuGet pulls them


supports specifying the user; the user automatically; the
dependencies on must still install them user isn't notified.
other SDKs. and reference them
manually.

The mechanism Y The SDK must pass N


integrates with concepts that are
Windows Store specific to the Store
concepts such as app so that packaging and
manifest and F5 work correctly with
Framework ID. SDKs that are
available in theStore.
F EAT URE SDK SUP P O RT SDK N OT ES N UGET SUP P O RT N UGET N OT ES

The mechanism Y The SDK must pass Y NuGet content


integrates with the Store-specific becomes part of the
app debugging concepts so that project. No special F5
pipeline for Windows packaging and F5 consideration is
8.x Store apps. work correctly with needed.
SDKs available in the
Store.

The mechanism Y The SDK must pass Y NuGet content


integrates with app Store-specific becomes part of the
manifests. concepts so that project. No special F5
packaging and F5 consideration is
work correctly with needed.
SDKs available in the
Store.

The mechanism Y If you drop the files in Y


deploys non- the \redist folder, the
reference files (for files are automatically
example, deploy test deployed.
framework upon
which to run tests of
Windows 8.x Store
apps).

The mechanism Y If you drop the N


automatically adds Windows 8 SDK or
the platform SDKs in the Windows Phone
Visual Studio IDE. SDK in a specific
location with a specific
layout, the SDK is
automatically
integrated with all the
Visual Studio features.
F EAT URE SDK SUP P O RT SDK N OT ES N UGET SUP P O RT N UGET N OT ES

The mechanism N Because you reference Y You can check out the
supports a clean an SDK, you must solution, and Visual
developer machine. check in your solution Studio immediately
(That is, no and the SDK recognizes and acts
installation is separately. You can on the files.
required, and simple check in the SDK from
retrieval from source the two non-registry
code control will default locations from
work.) which MSBuild
iterates SDKs (for
details, see Creating a
Software
Development Kit). As
an alternative, if a
custom location
consists of the SDKs,
you can specify the
following code in the
project file:

<PropertyGroup>
<SDKReferenceDirectoryRoot>C:\MySDKs</SDKReferenceDirectoryRoot>
</PropertyGroup>

Then check the SDKs


into that location.

You can join a large N/A The community is Y


existing community of new.
package authors.

You can join a large N/A The community is Y


existing community of new.
package consumers.

You can join an N/A The available Y


ecosystem of partners repositories include
(custom galleries, Visual Studio Gallery,
repositories, and so Microsoft Download
forth). Center, and Windows
Store.

The mechanism Y The SDK must pass Y


integrates with the checked-in
continuous- location
integration build (SDKReferenceDirector
servers for both yRoot property) on
package creation and command line to
consumption. MSBuild.

The mechanism Y The SDK supports Y


supports both stable adding references to
and pre-release multiple versions.
package versions.
F EAT URE SDK SUP P O RT SDK N OT ES N UGET SUP P O RT N UGET N OT ES

The mechanism Y If shipped as VSIX or Y


supports auto-update part of Visual Studio
for installed packages. automatic updates,
SDK provides
automatic
notifications.

The mechanism Y The SDK contains Y


contains a stand- MSBuild.exe.
alone .exe file for
creating and
consuming packages.

Packages can be Y You can’t check in Y


checked into version anything outside the
control. Documents node,
which means that the
Extension SDKs might
not be checked in.The
size of Extension SDK
might be large.

You can use a Y (consumption), N No tooling for Y


PowerShell interface (creation) creating an SDK.
to create and Consumption is
consume packages. executing MSBuild on
the command line.

You can use a Symbol Y If you drop .pdb files Y


package for in the SDK, the files
debugging support. get picked up
automatically.

The mechanism N/A The SDK gets revised Y


supports package with MSBuild.
manager auto-
updates.

The mechanism Y SDKManifest.xml Y


supports a supports many
lightweight manifest attributes, but a small
format. subset is usually
necessary.

The mechanism is Y The SDK supports all Y NuGet supports all


available for all Visual Visual Studio editions, Visual Studio editions,
Studio editions. from Visual Studio Express up through
Express through Visual Studio Ultimate.
Visual Studio
Ultimate.

The mechanism is N The SDK supports N You can review a list


available for all project Windows 8.x Store of allowed projects.
types. apps starting in Visual
Studio 2012.

See Also
Managing references in a project
How to: Add or Remove Imported Namespaces
(Visual Basic)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Importing a namespace allows you to use elements from that namespace in your code without fully qualifying the
element. For example, if you want to access the Create method in the System.Messaging.MessageQueue class, you
can import the System.Messaging namespace and just refer to the element you need in code as
MessageQueue.Create .

Imported namespaces are managed on the References page of the Project Designer . The imports you specify in
this dialog box are passed directly to the compiler ( /imports ) and apply to all files in your project. Use the Imports
statement to use a namespace in a single source code file.
To add an imported namespace
1. In Solution Explorer , double-click the My Project node for the project.
2. In the Project Designer , click the References tab.
3. In the Impor ted Namespaces list, select the check box for the namespace that you wish to add.

NOTE
In order to be imported, the namespace must be in a referenced component. If the namespace does not appear in
the list, you will need to add a reference to the component that contains it. For more information, see NIB How to:
Add or Remove References By Using the Add Reference Dialog Box.

To remove an imported namespace


1. In Solution Explorer , double-click the My Project node for the project.
2. In the Project Designer , click the References tab.
3. In the Impor ted Namespaces list, clear the check box for the namespace that you wish to remove.

User Imports
User imports allow you to import a specific class within a namespace rather than the entire namespace. For
example, your application might have an import for the Systems.Diagnostics namespace, but the only class within
that namespace that you are interested in is the Debug class. You can define System.Diagnostics.Debug as a user
import, and then remove the import for System.Diagnostics .
If you later change you mind and decide that was really the EventLog class that you needed, you could enter
System.Diagnostics.EventLog as a user import and overwrite System.Diagnostics.Debug using the update
functionality.
To add a user import
1. In Solution Explorer , double-click the My Project node for the project.
2. In the Project Designer , click the References tab.
3. In the text box below the Impor ted Namespaces list, enter the full name for the namespace you wish to
import, including the root namespace.
4. Click the Add user impor t button to add the namespace to the Impor ted Namespaces list.

NOTE
The Add user impor t button will be disabled if the namespace matches one already in the list; you cannot add an
import twice.

To update a user import


1. In Solution Explorer , double-click the My Project node for the project.
2. In the Project Designer , click the References tab.
3. In the Impor ted Namespaces list, select the namespace you wish to change.
4. In the text box below the Impor ted Namespaces list, enter the name for the new namespace.
5. Click the Update user impor t button to update the namespace in the Impor ted Namespaces list.

See Also
Managing references in a project
Troubleshooting Broken References
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

If your application attempts to use a broken reference, an exception error is generated. The inability to find the
referenced component is the primary trigger for the error, but there are several situations in which a reference can
be considered broken. These instances are shown in the following list:
The project's reference path is incorrect or incomplete.
The file being referenced has been deleted.
The file being referenced has been renamed.
The network connection or authentication has failed.
The reference is to a COM component that is not installed on the computer.
The following are remedies to these problems.

NOTE
Files in assemblies are referenced with absolute paths in the project file. Therefore, it is possible for users who work in a
multideveloper environment to be missing a referenced assembly in their local environment. To avoid these errors, it is
better in these cases to add project-to-project references. For more information, see NIB How to: Add or Remove References
By Using the Add Reference Dialog Box and Programming with Assemblies.

Reference Path Is Incorrect


If projects are shared on different computers, some references might not be found when a component is located in
a different directory on each computer. References are stored under the name of the component file (for example,
MyComponent). When a reference is added to a project, the folder location of the component file (for example,
C:\MyComponents\) is appended to the ReferencePath project property.
When the project is opened, it attempts to locate these referenced component files by looking in the directories on
the reference path. If the project is opened on a computer that stores the component in a different directory, such
as D:\MyComponents\, the reference cannot be found and an error appears in the Task List.
To fix this problem, you can delete the broken reference and then replace it using the Add Reference dialog box.
Another solution is to use the Reference Path item in the project's property pages and modify the folders in the
list to point to the correct locations. The Reference Path property is persisted for each user on each computer.
Therefore, modifying your reference path does not affect other users of the project.

TIP
Project-to-project references do not have these problems. For this reason, use them instead of file references, if you can.
To fix a broken project reference by correcting the reference path
1. In Solution Explorer , right-click your project node and click Proper ties .
2. The Project Designer appears.
3. If you are using Visual Basic, select the References page and click the Reference Paths button. In the
Reference Paths dialog box, type the path of the folder that contains the item you want to reference in the
Folder field, and then click the Add Folder button.
-or-
If you are using Visual C#, select the Reference Paths page. In the Folder field, type the path of the folder
that contains the item you want to reference, and then click the Add Folder button.

Referenced File Has Been Deleted


It is possible that the file being referenced has been deleted and no longer exists on the drive.
To fix a broken project reference for a file that no longer exists on your drive
Delete the reference.
If the reference exists in another location on your computer, read it from that location.
For more information, see NIB How to: Add or Remove References By Using the Add Reference Dialog Box.

Referenced File Has Been Renamed


It is possible that the file being referenced has been renamed.
To fix a broken reference for a file that has been renamed
Delete the reference, and then add a reference to the renamed file.
If the reference exists in another location on your computer, you have to read it in from that location. For
more information, see NIB How to: Add or Remove References By Using the Add Reference Dialog Box.

Network Connection or Authentication Has Failed


There can be many possible causes for inaccessible files: a failed network connection or a failed authentication, for
example. Each cause might have a unique means of recovery; for example, you might have to contact the local
administrator for access to the required resources. However, deleting the reference and fixing the code which used
it is always an option. For more information, see NIB How to: Add or Remove References By Using the Add
Reference Dialog Box.

COM Component Is Not Installed on Computer


If a user has added a reference to a COM component and a second user tries to run the code on a computer that
does not have this component installed, the second user will receive an error that the reference is broken.
Installing the component on the second computer will correct the error. For more information about how to use
references to COM components in your projects, see COM Interoperability in .NET Framework Applications.

See Also
Introduction to the Project Designer References Page, Project Designer (Visual Basic) NIB How to: Add or Remove
References By Using the Add Reference Dialog Box
Application Properties
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can set general application properties for Visual Basic, C#, and F# applications, such as application type,
startup object, and assembly information, in the Application pane of the Project Designer .
The following tasks can be accomplished in the Application pane:
Specify assembly information
Specify a splash screen for an application
Specify application-level events
Change an assembly name
Change the namespace for an application
Change the application type
Change the Startup object for an application
Specify an application icon
Enable Windows XP visual styles
Specify instancing behavior for an application
Enable custom user authentication
Specify shutdown behavior for an application
The tasks available for your application depend on the development language being used.

In This Section
How to: Specify an Application Icon (Visual Basic, C#)

See Also
Application Page, Project Designer (Visual Basic) Application Page, Project Designer (C#) Introduction to the Project
Designer Publishing ClickOnce Applications Securing ClickOnce Applications Managing Debugging Properties
Managing Compilation Properties Managing Application Resources (.NET) Managing Application Settings (.NET)
Managing Application Resources (.NET)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Resource files are files that are part of an application but are not compiled, for example icon files or audio files.
Since these files are not part of the compilation process, you can change them without having to recompile your
binaries. If you are planning to localize your application, you should use resource files for all the strings and other
resources that need to be changed when you localize your application.
For more information about resources in .NET desktop apps, see Resources in Desktop Apps. For more information
about resources in C++ desktop apps, see Working with Resource Files.
Windows Store apps use a different resource model from desktop apps. For information about resources in
Windows Store apps, see Defining Application Resources on the Windows Dev Center website.

Working with Resources


In a managed code project, open the project properties window (right-click the project node in Solution Explorer
and select Proper ties , or type project proper ties in the Quick Launch window, or type ALT + ENTER in the
Solution Explorer window). Select the Resources tab. You can add a .resx file if your project does not contain
one already, add and delete different kinds of resources, and modify existing resources.
To find out how to work with resources in C++ projects, see How to: Create a Resource.
Managing Application Settings (.NET)
11/21/2019 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Application settings enable you to store application information dynamically. Settings allow you to store
information on the client computer that should not be included in the application code (for example a connection
string), user preferences and other information you need at runtime.
Application settings replace the dynamic properties used in earlier versions of Visual Studio.
Each application setting must have a unique name. The name can be any combination of letters, numbers, or an
underscore that does not start with a number, and it cannot contain spaces. The name can be changed through the
Name property.

Application settings can be stored as any data type that can be serialized to XML or has a TypeConverter that
implements ToString / FromString . The most common types are String , Integer , and Boolean , but you can also
store values as Color, Object, or as a connection string.
Application settings also contain a value. The value is set with the Value property and must match the data type of
the setting.
In addition, application settings can be bound to a property of a form or control at design time.
There are two types of application settings, based on scope:
Application-scoped settings can be used for information such as a URL for a Web service or a database
connection string. These values are associated with the application. Therefore, users cannot change them at
run time.
User-scoped settings can be used for information such as persisting the last position of a form or a font
preference. Users can change these values at run time.
You can change the type of a setting by using the Scope property.
The project system stores application settings in two XML files: an app.config file, which is created at design
time when you create the first application setting; and a user.config file, which is created at run time when
the user who runs the application changes the value of any user setting. Notice that changes in user settings
are not written to disk unless the application specifically calls a method to do this.

Creating Application Settings at Design Time


At design time, you can create application settings in two ways: by using the Settings page of the Project
Designer , or by using the Proper ties window for a form or control, which allows you to bind a setting to a
property.
When you create an application-scoped setting (for example, a database connection string, or a reference to server
resources), Visual Studio saves it in app.config with the <applicationSettings> tag. (Connection strings are saved
under the <connectionStrings> tag.)
When you create a user-scoped setting (for example, default font, home page, or window size), Visual Studio saves
it in app.config with the <userSettings> tag.

IMPORTANT
When you store connection strings in app.config, you should take precautions to avoid revealing sensitive information, such
as passwords or server paths, in the connection string.
If you take connection string information from an external source, such as a user supplying a user ID and password, you
must be careful to ensure that the values that you use to construct your connection string do not contain additional
connection string parameters that change the behavior of your connection.
Consider using the Protected Configuration feature to encrypt sensitive information in the configuration file. See Protecting
Connection Information for more information.

NOTE
Because there is no configuration file model for class libraries, application settings do not apply for Class Library projects. The
exception is a Visual Studio Tools for Office DLL project, which can have a configuration file.

Using Customized Settings Files


You can add customized settings files to your project for convenient management of groups of settings. Settings
that are contained in a single file are loaded and saved as a unit. Therefore, being able to store settings in separate
files for frequently-used and infrequently-used groups can save time in loading and saving settings.
For example, you can add a file such as SpecialSettings.settings to your project. While your SpecialSettings class
is not exposed in the My namespace, View Code can read the custom settings file that contains
Partial Class SpecialSettings .

The Settings Designer first searches for the Settings.settings file that the project system creates; this is the default
file that the Project Designer displays in the Settings tab. Settings.settings is located in the My Project folder for
Visual Basic projects and in the Properties folder for Visual C# projects. The Project Designer then searches for
other settings files in the project's root folder. Therefore, you should put your custom settings file there. If you add
a .settings file elsewhere in your project, the Project Designer will not be able to locate it.

Accessing or Changing Application Settings at Run Time in Visual Basic


In Visual Basic projects, you can access application settings at run time by using the My.Settings object. On the
Settings page, click the View code button to view the Settings.vb file. Settings.vb defines the Settings class,
which enables you to handle these events on the settings class: SettingChanging, PropertyChanged,
SettingsLoaded, and SettingsSaving. Notice that the Settings class in Settings.vb is a partial class that displays
only the user-owned code, not the whole generated class. For more information about accessing application
settings by using the My.Settings object, see Accessing Application Settings.
The values of any user-scoped settings that the user changes at run time (for example, the position of a form) are
stored in a user.config file. Notice that the default values are still saved in app.config.
If you have changed any user-scoped settings during run time, for example in testing the application, and want to
reset these settings to their default values, click the Synchronize button.
We strongly recommend that you use the My.Settings object and the default .settings file to access settings. This is
because you can use the Settings Designer to assign properties to settings, and, additionally, user settings are
automatically saved before application shutdown. However, your Visual Basic application can access settings
directly. In that case you have to access the MySettings class and use a custom .settings file in the root of the
project. You must also save the user settings before ending the application, as you would do for a C# application;
this is described in the following section.

Accessing or Changing Application Settings at Run Time in Visual C#


In languages other than Visual Basic, such as Visual C#, you must access the Settings class directly, as shown in
the following Visual C# example.

Properties.Settings.Default.FirstUserSetting = "abc";

You must also explicitly call the Save method of this wrapper class in order to persist the user settings. You usually
do this in the Closing event handler of the main form. The following Visual C# example shows a call to the Save
method.

Properties.Settings.Default.Save();

For general information about accessing application settings through the Settings class, see Application Settings
Overview. For information about iterating through the settings, see this forum post.

See Also
Accessing Application Settings
Managing Assembly and Manifest Signing
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Strong-name signing gives a software component a globally unique identity. Strong names are used to guarantee
that the assembly cannot be spoofed by someone else, and to ensure that component dependencies and
configuration statements map to the correct component and component version.
A strong name consists of the assembly's identity (simple text name, version number, and culture information), plus
a public key token and a digital signature.
For information about signing assemblies in Visual Basic and C# projects, see Creating and Using Strong-Named
Assemblies.
For information about signing assemblies in Visual C++ projects, see Strong Name Assemblies (Assembly Signing)
(C++/CLI).

Asset Types and Signing


You can sign .NET assemblies and application manifests. These include the following:
executables (.exe)
application manifests (.exe.manifest)
deployment manifests (.application)
shared component assemblies (.dll)
You must sign the following types of asset:
1. assemblies, if you want to deploy them to the global assembly cache (GAC).
2. ClickOnce application and deployment manifests. Visual Studio enables signing by default for these
applications.
3. Primary interop assemblies, which are used for COM interoperability. The TLBIMP utility enforces strong-
naming when creating a primary interop assembly from a COM type library.
In general you should not sign executables. A strongly-named component cannot reference a non-strongly-
named component that is deployed with the application. Visual Studio does not sign application executables,
but instead signs the application manifest, which points to the weak-named executable. You should generally
avoid signing components that are private to your application, because signing can make it more difficult to
manage dependencies.

How to Sign an Assembly in Visual Studio


You sign an application or component by using the Signing tab of the project properties window (right-click the
project node in the Solution Explorer and select Proper ties , or type project proper ties in the Quick Launch
window, or press ALT+ ENTER inside the Solution Explorer window). Select the Signing tab, then select the Sign
the assembly check box.
Specify a key file. If you choose to create a new key file, note that new key files are always created in the .pfx
format. You need a name and password for the new file.

WARNING
You should always protect your key file with a password to prevent someone else from using it. You can also secure your
keys by using providers or certificate stores.

You can also point to a key you have already created. For more information about creating keys, see How to: Create
a Public-Private Key Pair.
If you have access only to a public key, you can use delay signing to defer assigning the key. You enable delay
signing by selecting the Delay sign only check box. A delay-signed project won’t run, and you can’t debug it.
However, you can skip verification during development by using the Sn.exe (Strong Name Tool) with the -Vr
option.
For information about signing manifests, see How to: Sign Application and Deployment Manifests.

See Also
Strong-Named Assemblies Strong Name Assemblies (Assembly Signing) (C++/CLI)
How to: Sign Application and Deployment Manifests
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

If you want to publish an application by using ClickOnce deployment, the application and deployment manifests
must be signed with a public/private key pair and signed using Authenticode technology. You can sign the
manifests by using a certificate from the Windows certificate store or a key file.
For more information about ClickOnce deployment, see ClickOnce Security and Deployment.
Signing the ClickOnce manifests is optional for .exe-based applications. For more information, see the "Generating
Unsigned Manifests" section of this document.
For information about creating key files, see How to: Create a Public-Private Key Pair.

NOTE
Visual Studio supports only Personal Information Exchange (PFX) key files that have the .pfx extension. However, you can
select other types of certificates from the current user's Windows certificate store by clicking Select from Store on the
Signing page of project properties.

To sign application and deployment manifests using a certificate


1. Go to the project properties window (right-click the project node in the Solution Explorer and select
Proper ties , or type project proper ties in the Quick Launch window, or press ALT+ ENTER inside the
Solution Explorer window). On the Signing tab, select the Sign the ClickOnce manifests check box.
2. Click the Select from Store button.
The Select a Cer tificate dialog box appears and displays the contents of the Windows certificate store.

TIP
If you click Click here to view cer tificate proper ties , the Cer tificate Details dialog box appears. This dialog
box includes detailed information about the certificate, and includes additional options. You can click cer tificates to
view additional Help information.

3. Select the certificate that you want to use to sign the manifests.
4. Additionally, you can specify the address of a timestamp server in the Timestamp ser ver URL text box.
This is a server that provides a timestamp specifying when the manifest was signed.
To sign application and deployment manifests using an existing key file
1. On the Signing page, select the Sign the ClickOnce manifests check box.
2. Click the Select from File button.
The Select File dialog box appears.
3. In the Select File dialog box, browse to the location of the key file (.pfx) that you want to use, and then
click Open .

NOTE
This option supports only files that have the .pfx extension. If you have a key file or certificate in another format,
store it in the Windows certificate store and select the certificate is described in the previous procedure. The selected
certificate's purpose should include code signing.

The Enter password to open file dialog box appears. (If the .pfx file is already stored in your Windows
certificate store, or is not password protected, you will not be prompted to enter a password.)
4. Enter the password to access the key file, and press ENTER.
To sign application and deployment manifests using a test certificate
1. On the Signing page, select the Sign the ClickOnce manifests check box.
2. To create a new certificate for testing, click the Create Test Cer tificate button.
3. In the Create Test Cer tificate dialog box, enter a password to help secure your test certificate.

Generating Unsigned Manifests


Signing the ClickOnce manifests is optional for .exe-based applications. The following procedures show how to
generate unsigned ClickOnce manifests.

IMPORTANT
Unsigned manifests can simplify development and testing of your application. However, unsigned manifests introduce
substantial security risks in a production environment. Only consider using unsigned manifests if your ClickOnce application
runs on computers within an intranet that is completely isolated from the internet or other sources of malicious code.

By default, ClickOnce automatically generates signed manifests unless one or more files are specifically excluded
from the generated hash. In other words, publishing the application results in signed manifests if all files are
included in the hash, even when the Sign the ClickOnce manifests check box is cleared.
To generate unsigned manifests and include all files in the generated hash
1. To generate unsigned manifests that include all files in the hash, you must first publish the application
together with signed manifests. Therefore, first sign the ClickOnce manifests by following one of the
previous procedures, and then publish the application.
2. On the Signing page, clear the Sign the ClickOnce manifests check box.
3. Reset the publish version so that only one version of your application is available. By default, Visual Studio
automatically increments the revision number of the publish version every time that you publish an
application. For more information, see How to: Set the ClickOnce Publish Version.
4. Publish the application.
To generate unsigned manifests and exclude one or more files from the generated hash
1. On the Signing page, clear the Sign the ClickOnce manifests check box.
2. Open the Application Files dialog box and set the Hash to Exclude for the files that you want to exclude
from the generated hash.
NOTE
Excluding a file from the hash configures ClickOnce to disable automatic signing of the manifests, so you do not need
to first publish with signed manifests as shown in the previous procedure.

3. Publish the application.

See Also
Strong-Named Assemblies How to: Create a Public-Private Key Pair Signing Page, Project Designer ClickOnce
Security and Deployment
How to: Specify an Application Icon (Visual Basic, C#)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Icon property for a project specifies the icon file (.ico) that will be displayed for the compiled application in
File Explorer and in the Windows taskbar.
The Icon property can be accessed in the Application pane of the Project Designer ; it contains a list of icons
that have been added to a project either as resources or as content files.

NOTE
After you set the icon property for an application, you might also set the Icon property of each Window or Form in the
application. For information about window icons for Windows Presentation Foundation (WPF) standalone applications, see
Icon property.

To specify an application icon


1. In Solution Explorer , choose a project node (not the Solution node).
2. On the menu bar, choose Project , Proper ties .
3. When the Project Designer appears, choose the Application tab.
4. (Visual Basic) In the Icon list, choose an icon (.ico) file.
C# Near the Icon list, choose the <Browse...> button, and then browse to the location of the icon file that
you want.

See Also
Application Page, Project Designer (Visual Basic) Application Page, Project Designer (C#) Managing Application
Properties How to: Add or Remove Resources
Targeting a Specific .NET Framework Version
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In Visual Studio, you can specify the version or profile of the .NET Framework that you want your project to target.
For an application to run on another computer, the Framework version that the application targets must be
compatible with the Framework version that is installed on the computer.
This section contains topics that describe how to target specific versions of the .NET Framework in your projects.

In This Section
Visual Studio Multi-Targeting Overview Provides an overview of the multi-targeting features in Visual Studio.
How to: Target a Version of the .NET Framework Details how to specify a particular .NET Framework for your
Visual Basic, Visual C# or Visual F# project.

Related Sections
.NET Framework Multi-Targeting for ASP.NET Web Projects Explains how to use this version of Visual Studio to
develop Web applications that run under earlier versions of the .NET Framework.
Application Page, Project Designer (C#) Describes the Target Framework control in the Project Designer for
Visual C# projects.
Application Page, Project Designer (Visual Basic) Describes the Target Framework control in the Project Designer
for Visual Basic projects.
How to: Modify the Target Framework and Platform Toolset Describes how to change settings for Visual C++
projects to target different versions of the .NET Framework and to use different platform toolsets.
Visual Studio Multi-Targeting Overview
1/10/2020 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In this version of Visual Studio, you can specify the version of the .NET Framework that is required for your
application. Therefore, if you want to use this version of Visual Studio to continue to develop a project that you
started in an earlier version, you do not have to change the framework target. You could also create a solution that
contains projects that target different versions of the framework. Framework targeting also helps guarantee that
the application uses only functionality that is available in the specified version of the framework.

TIP
You can also target applications for different platforms. For more information, see Multitargeting

Framework Targeting Features


Framework targeting includes the following features:
When you open a project that targets an earlier version of the .NET Framework, Visual Studio can
automatically upgrade it or leave the target as is.
When you create a project, you can specify the version of the .NET Framework that you want to target.
You can change the version of the .NET Framework that an existing project targets.
You can target a different version of the .NET Framework in each of several projects in the same solution.
When you change the version of the .NET Framework that a project targets, Visual Studio makes any
required changes to references and configuration files.
When you work on a project that targets an earlier version of the .NET Framework, Visual Studio
dynamically changes the development environment, as follows:
It filters items in the New Project dialog box, the Add New Item dialog box, the Add New Reference
dialog box, and the Add Ser vice Reference dialog box to omit choices that are not available in the
targeted version.
It filters custom controls in the Toolbox to remove those that are not available in the targeted version and
to show the only the most up-to-date controls when multiple controls are available.
It filters IntelliSense to omit language features that are not available in the targeted version.
It filters properties in the Proper ties window to omit those that are not available in the targeted version.
It filters menu options to omit options that are not available in the targeted version.
For builds, it uses the version of the compiler and the compiler options that are appropriate for the targeted
version.
NOTE
Framework targeting does not guarantee that your application will run correctly. You must test your application to make
sure it runs against the targeted version. You cannot target framework versions that are earlier than the .NET Framework
2.0.

Selecting a Target Framework Version


When you create a project, select the target .NET Framework version in the New Project dialog box. The list of
available project templates is filtered based on the selection. In an existing project, you can change the target .NET
Framework version in the project properties dialog box. For more information, see How to: Target a Version of the
.NET Framework.

NOTE
In Express editions of Visual Studio, you cannot set the target framework in the New Project dialog box.

Resolving System and User Assembly References


To target a .NET Framework version, you must first install the appropriate assembly references. Assembly
references for the .NET Framework versions 2.0, 3.0, and 3.5 are included in the .NET Framework 3.5 SP1, which
you can download from the Microsoft Download Center, Microsoft Visual Studio website. Assembly references for
the .NET Framework 3.5 Client Profile, the .NET Framework 4, the .NET Framework 4 Client Profile, and Silverlight
are also available from the Visual Studio Downloads website.

NOTE
A .NET Framework client profile is a subset of the .NET Framework that provides a limited set of libraries and features. For
more information about client profiles, see .NET Framework Client Profile.

The Add Reference dialog box disables system assemblies that do not pertain to the target .NET Framework
version so that they cannot be added to a project inadvertently. (System assemblies are .dll files that are included
in a .NET Framework version.) References that belong to a framework version that is later than the targeted
version will not resolve, and controls that depend on such a reference cannot be added. If you want to enable such
a reference, reset the .NET Framework target of the project to one that includes the reference. For more
information, see Introduction to the Project Designer.
For more information about assembly references, see Resolving Assemblies at Design Time.

Enabling LINQ
When you target the .NET Framework 3.5 or later, a reference to System.Core and a project-level import for
System.Linq (in Visual Basic only) are added automatically. If you want to use LINQ features, you must also turn
Option Infer on (in Visual Basic only). The reference and import are removed automatically if you change the
target to an earlier .NET Framework version. For more information, see How to: Create a LINQ Project.

See Also
Multitargeting .NET Framework Multi-Targeting for ASP.NET Web Projects Platform compatibility and system
requirements
How to: Target a Version of the .NET Framework
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This document describes how to target a version of the .NET Framework when you create a project and how to
change the targeted version in an existing Visual Basic, Visual C#, or Visual F# project.

IMPORTANT
For information about how to change the target version for C++ projects, see How to: Modify the Target Framework and
Platform Toolset.

In this topic
Targeting a version when you create a project
Changing the target version

Targeting a version when you create a project


When you create a project, the version of the .NET Framework that you target determines which templates you can
use.

NOTE
In Express editions of Visual Studio, you must create the project first, and then you can change the target, as Changing the
target version describes later in this topic.

To target a version when you create a project


1. On the menu bar, choose File , New , Project .
2. In the list at the top of the New Project dialog box, choose the version of the .NET Framework that you
want your project to target.

NOTE
Typically, only one version of the .NET Framework is installed with Visual Studio. If you want to target another
version, you must first make sure that it's installed. See Visual Studio Multi-Targeting Overview.

3. In the list of installed templates, choose the type of project that you want to create, name the project, and
then choose the OK button.
The list of templates shows only those projects that are supported by the version of the .NET Framework
that you chose.
Changing the target version
You can change the targeted version of the .NET Framework in a Visual Basic, Visual C#, or Visual F# project by
following this procedure.
To change the targeted version
1. In Solution Explorer , open the shortcut menu for the project that you want to change, and then choose
Proper ties .

IMPORTANT
For information about how to change the target version for C++ projects, see How to: Modify the Target Framework
and Platform Toolset.

2. In the left column of the properties window, choose the Application tab.
NOTE
After you create a Windows Store app, you can't change the targeted version of either Windows or the .NET
Framework.

3. In the Target Framework list, choose the version that you want.
4. In the verification dialog box that appears, choose the Yes button.
The project unloads. When it reloads, it targets the .NET Framework version that you just chose.

NOTE
If your code contains references to a different version of the .NET Framework than the one that you targeted, error
messages may appear when you compile or run the code. To resolve these errors, you must modify the references.
See Troubleshooting .NET Framework Targeting Errors.

See Also
Visual Studio Multi-Targeting Overview .NET Framework Multi-Targeting for ASP.NET Web Projects
Troubleshooting .NET Framework Targeting Errors Application Page, Project Designer (C#) Application Page,
Project Designer (Visual Basic) Configuring Projects How to: Modify the Target Framework and Platform Toolset
Creating Project and Item Templates
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Visual Studio project and item templates provide reusable stubs that give users some basic code and structure
that they can use for their own purposes.

Visual Studio Templates


A number of predefined project and item templates are installed when you install Visual Studio. The Visual Basic
and Visual C# Windows Forms Application and Class Library templates that are available in the New Project
dialog box are examples of project templates. Installed item templates are available in the Add New Item dialog
box, and include items such as code files, XML files, HTML pages, and Style Sheets.
These templates provide a starting point for users to begin creating projects or expanding current projects.
Project templates provide the files that are required for a particular project type, include standard assembly
references, and set default project properties and compiler options. Item templates can range in complexity from
just one empty file that has the correct file name extension to a multi-file item that contains, for example, source
code files that have stub code, designer information files, and embedded resources.
In addition to the installed templates in the New Project and Add New Item dialog boxes, you can author your
own templates or download and use templates created by the community. For more information, see How to:
Create Project Templates and How to: Create Item Templates.

Contents of a Template
All project and item templates, whether installed together with Visual Studio or created by you, function by using
the same principles and have similar contents. All templates contain the following items:
The files to be created when the template is used. This includes source code files, embedded resources,
project files, and so on.
One .vstemplate file. This file contains the metadata that provides Visual Studio the information it needs to
display the template in the New Project and Add New Item dialog boxes and create a project or item
from the template. For more information about .vstemplate files, see Template Parameters.
When these files are compressed into a .zip file and put in the correct folder, Visual Studio automatically
displays them. Project templates appear in the My Templates section of the New Project dialog boxes,
and item templates appear in the Add New Item dialog boxes. For more information about template
folders, see How to: Locate and Organize Templates.

Starter Kits
Starter Kits are enhanced templates that can be shared with other members of the community. A Starter Kit
includes code samples that compile, documentation, and other resources to help users learn new tools and
programming techniques while they build useful, real-world applications. The basic contents and procedures for
Starter Kits are identical to those for templates. For more information, see How to: Create Starter Kits.
See Also
How to: Create Project Templates How to: Create Item Templates Template Parameters Customizing Templates
How to: Create Starter Kits
How to: Create Project Templates
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This procedure enables you to create a template using the Expor t Template wizard, which packages your
template in a .zip file. You can also create templates in the VSIX file format for improved deployment by using the
Export Template Wizard extension, or with templates included in the Visual Studio SDK, or you can create
templates manually.
To create a custom project template with the standard Export Template wizard
1. Create a project.

NOTE
Use only valid identifier characters when naming a project that will be the source for a template. A template
exported from a project named with invalid characters can cause compilation errors in future projects based on the
template. For more information on valid identifier characters, see Declared Element Names.

2. Edit the project until it is ready to be exported as a template.


3. As appropriate, edit the code files to indicate where parameter replacement should take place. For more
information on parameter replacement, see How to: Substitute Parameters in a Template.
4. On the File menu, click Expor t Template . The Expor t Template wizard opens.
5. Click Project Template .
6. If you have more than one project in your current solution, select the projects you want to export to a
template.
7. Click Next .
8. Select an icon and a preview image for your template. These will appear in the New Project dialog box.
9. Enter a template name and description.
10. Click Finish . Your project is exported into a .zip file and placed in the specified output location, and, if
selected, imported into Visual Studio.
If you have the Visual Studio SDK installed, you can wrap the finished template in a .vsix file for deployment
by using the VSIX Project template. For more information, see Getting Started with the VSIX Project
Template.

See Also
Creating Project and Item Templates How to: Create Item Templates
How to: Create Multi-Project Templates
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Multi-project templates act as containers for two or more projects. When a project based on a multi-project
template is created from the New Project dialog box, every project in the template is added to the solution.
A multi-project template must include the following items, compressed into a .zip file:
A root .vstemplate file for the entire multi-project template. This root .vstemplate file contains the metadata
that the New Project dialog box displays, and specifies where to find the .vstemplate files for the projects in
this template. This file must be located at the root of the .zip file.
One or more folders that contain the files that are required for a complete project template. This includes all
code files for the project, and also a .vstemplate file for the project.
For example, a multi-project template .zip file that has two projects could have the following files and
directories:
MultiProjectTemplate.vstemplate
\Project1\Project1.vstemplate
\Project1\Project1.vbproj
\Project1\Class.vb
\Project2\Project2.vstemplate
\Project2\Project2.vbproj
\Project2\Class.vb
The root .vstemplate file for a multi-project template differs from a single-project template in the following
ways:
The Type attribute of the VSTemplate element contains the value ProjectGroup . For example:

<VSTemplate Version="2.0.0" Type="ProjectGroup"


xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">

The TemplateContent element contains a ProjectCollection element that has one or more
ProjectTemplateLink elements that define the paths to the .vstemplate files of the included projects. For
example:
<TemplateContent>
<ProjectCollection>
<ProjectTemplateLink>
Project1\Project1.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink>
Project2\Project2.vstemplate
</ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>

Multi-project templates also behave differently than normal templates. Multi-project templates have the
following unique characteristics:
Individual projects in a multi-project template cannot be assigned names by the New Project dialog box.
Instead, use the ProjectName attribute on the ProjectTemplateLink element to specify the name for each
project. For more information, see the first example in the following section.
Multi-project templates can contain projects written in different languages, but the entire template itself can
only be put in one category by using the ProjectType element.
To create a multi-project template
1. Create the projects to include in the multi-project template.
2. Create .vstemplate files for every project. For more information, see How to: Create Project Templates.
3. Create a root .vstemplate file that to contain the metadata for the multi-project template. For more
information, see the first example in the following section.
4. Select the files and folders to include in your template, right-click the selection, click Send To , and then click
Compressed (zipped) Folder . The files and folders are compressed into a .zip file.
5. Put the .zip template file in the Visual Studio project template directory. By default, this directory is \My
Documents\Visual Studio Version\Templates\ProjectTemplates\.

Example
This example shows a basic multi-project root .vstemplate file. In this example, the template contains two projects,
My Windows Application and My Class Library . The ProjectName attribute on the ProjectTemplateLink element
sets the name for Visual Studio to assign this project. If the ProjectName attribute does not exist, the name of the
.vstemplate file is used as the project name.
<VSTemplate Version="2.0.0" Type="ProjectGroup"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>Multi-Project Template Sample</Name>
<Description>An example of a multi-project template</Description>
<Icon>Icon.ico</Icon>
<ProjectType>VisualBasic</ProjectType>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<ProjectTemplateLink ProjectName="My Windows Application">
WindowsApp\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="My Class Library">
ClassLib\MyTemplate.vstemplate
</ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>
</VSTemplate>

Example
This example uses the SolutionFolder element to divide the projects into two groups, Math Classes and
Graphics Classes . The template contains four projects, two of which are placed in each solution folder.

<VSTemplate Version="2.0.0" Type="ProjectGroup"


xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>Multi-Project Template Sample</Name>
<Description>An example of a multi-project template</Description>
<Icon>Icon.ico</Icon>
<ProjectType>VisualBasic</ProjectType>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<SolutionFolder Name="Math Classes">
<ProjectTemplateLink ProjectName="MathClassLib1">
MathClassLib1\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="MathClassLib2">
MathClassLib2\MyTemplate.vstemplate
</ProjectTemplateLink>
</SolutionFolder>
<SolutionFolder Name="Graphics Classes">
<ProjectTemplateLink ProjectName="GraphicsClassLib1">
GraphicsClassLib1\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="GraphicsClassLib2">
GraphicsClassLib2\MyTemplate.vstemplate
</ProjectTemplateLink>
</SolutionFolder>
</ProjectCollection>
</TemplateContent>
</VSTemplate>

See Also
Creating Project and Item Templates Visual Studio Template Schema Reference How to: Create Project Templates
Visual Studio Template Schema Reference SolutionFolder Element (Visual Studio Templates) ProjectTemplateLink
Element (Visual Studio Templates)
How to: Create Item Templates
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The steps in the first procedure of this topic show you how to create an item template by using the Expor t
Template wizard. If your template will consist of multiple files, see How to: Create Multi-file Item Templates.
The wizard does a lot of work for you to create the basic template, but in many cases you will need to manually
modify the .vstemplate file after you have exported the template. For example, if you want the item to appear in
the Add New Item dialog for a Windows 8.x Store app project, you’ll have to perform a few extra steps. The
second procedure in this topic helps you accomplish that task.
In some cases you may want or need to create an item template manually from scratch. The third procedure
shows how to do that.
See the Visual Studio Template Schema Reference for information about the elements that can be used in the
.vstemplate file.
To add a custom project item template to the Add New Item dialog box
1. Create or open a project in Visual Studio.
2. Add an item to the project and modify it if you want to.
3. Modify the code file to indicate where parameter replacement should take place. For more information, see
How to: Substitute Parameters in a Template.
4. On the File menu, click Expor t Template .
5. Click Item Template , select the project that contains the item, and click Next .
6. Select the item for which you want to create a template, and click Next .
7. Select the assembly references to include in the template, and click Next .
8. Type the icon file name, preview image, template name, and template description, and click Finish .
The files for the template are added to a .zip file and copied whatever directory you specify in the dialog.
The default location is ..\Users\<username>\Documents\Visual Studio <Version>\My Expor ted
Templates\ folder.

WARNING
In earlier versions of Visual Studio, the default location is ..\Users\<username>\Documents\Visual Studio
<Version>\Templates\ItemTemplates .

To enable the item template to be used in a store project


1. Follow the steps in the procedure above to export an item template.
2. Extract the .vstemplate file from the .zip file that was copied to the ..\Users\username\Documents\Visual
Studio Version\Templates\ItemTemplates\ (or My Expor ted Templates ) folder.
3. Open the .vstemplate file in Visual Studio.
4. For a Windows 8.1 store C# project, in the .vstemplate file, add the following XML within the opening and
closing <TemplateData> tag: <TemplateGroupID>WinRT-Managed</TemplateGroupID> .
A C++ Windows 8.1 store project uses a value of WinRT-Native-6.3 . For Windows 10 and other project
types, see TemplateGroupID Element (Visual Studio Templates).
The following example shows the entire contents of a .vstemplate file after the line of XML
<TemplateGroupID>WinRT-Managed</TemplateGroupID> has been added to it. This example is specific to C#
projects. You can modify the <ProjectType> and < TemplateGroupID> elements to specify other language
and project types.

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">


<TemplateData>
<DefaultName>MyItemStoreTemplate.xaml</DefaultName>
<Name>MyItemStoreTemplate</Name>
<Description>This is an example itemtemplate</Description>
<ProjectType>CSharp</ProjectType>
<SortOrder>10</SortOrder>
<Icon>__TemplateIcon.ico</Icon>
<TemplateGroupID>WinRT-Managed</TemplateGroupID>
</TemplateData>
<TemplateContent>
<References />
<ProjectItem SubType="Designer" TargetFileName="$fileinputname$.xaml"
ReplaceParameters="true">MyItemTemplate.xaml</ProjectItem>
<ProjectItem SubType="Code" TargetFileName="$fileinputname$.xaml.cs"
ReplaceParameters="true">MyItemTemplate.xaml.cs</ProjectItem>
</TemplateContent>
</VSTemplate>

For other possible TemplateGroupID values, see TemplateGroupID Element (Visual Studio Templates)). For
the complete .vstemplate reference, see Visual Studio Template Schema Reference
5. In Visual Studio, save the .vstemplate file and close it.
6. Copy and paste the .vstemplate file back to the .zip file located in the ..\Users\username\Documents\Visual
Studio Version\Templates\ItemTemplates\ folder.
If the Copy File dialog box appears, choose the Copy and Replace option.
You can now add an item based on this template to a Windows 8.x Store project by using the Add New
Item dialog box.
For more information about parameter names, see Template Parameters.
To enable templates for specific project sub-types
1. The development environment enables you to make project items available from the Add Item dialog box
for certain projects. Use this procedure to make custom items available for Windows, Web, Office, or
database projects.
Locate the ProjectType element in the .vstemplate file for the item template.
Add a ProjectSubType element immediately after the ProjectType element.
2. Set the text value of the element to one of the following values:
a. Windows
b. Office
c. Database
d. Web
For example: <ProjectSubType>Database</ProjectSubType> .
The following example shows an item template available for Office projects.

<VSTemplate Version="2.0.0" Type="Item" Version="2.0.0">


<TemplateData>
<Name>Class</Name>
<Description>An empty class file</Description>
<Icon>Class.ico</Icon>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>Office</ProjectSubType>
<DefaultName>Class.cs</DefaultName>
</TemplateData>
<TemplateContent>
<ProjectItem>Class1.cs</ProjectItem>
</TemplateContent>
</VSTemplate>

To manually create an item template without using the Export Template wizard
1. Create a project and project item.
2. Modify the project item until it is ready to be saved as a template.
3. As appropriate, modify the code file to indicate where parameter replacement should occur. For more
information about parameter replacement, see How to: Substitute Parameters in a Template.
4. Create an XML file and save it by using a .vstemplate file name extension, in the same directory as your
new item template.
5. Author the .vstemplate XML file to provide item template metadata. For more information, see Visual
Studio Template Schema Reference and the example in the previous section.
6. Save the .vstemplate file and close it.
7. In Windows Explorer, select the files you want to include in your template, right-click the selection, click
Send To, and then click Compressed (zipped) Folder. The files that you selected are compressed into a .zip
file.
8. Copy the .zip file and paste it in the user item template location. In Visual Studio 2015, the default directory
is ..\Users\<username>\Documents\Visual Studio 2015\Templates\ItemTemplates\. For more information,
see How to: Locate and Organize Project and Item Templates.

See Also
Creating Project and Item Templates How to: Create Multi-file Item Templates Visual Studio Template Schema
Reference
How to: Create Multi-file Item Templates
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Item templates may only specify one item, but sometimes the item is made up of multiple files. For example, a
Windows Forms item template for Visual Basic requires the following three files:
A .vb file that contains the code for the form.
A .designer.vb file that contains the designer information for the form.
A .resx file that contains the embedded resources for the form.
Multi-file item templates require parameters to ensure the correct file name extensions are used when the
item is created in Visual Studio. If you create an item template by using the Expor t Template wizard, these
parameters are automatically generated, and no further editing is required. The following steps explain how
to use parameters to ensure that the correct file name extensions are created.
To manually create a multi-file item template
1. Create the item template as you would create a single-file item template. For more information, see How to:
Create Item Templates.
2. Add TargetFileName attributes to every ProjectItem element. Set the values of the TargetFileName
attributes to $fileinputname$.FileExtension, where FileExtension is the file name extension of the file that is
being included in the template. For example:

<ProjectItem TargetFileName="$fileinputname$.vb">
Form1.vb
</ProjectItem>
<ProjectItem TargetFileName="$fileinputname$.Designer.vb">
Form1.Designer.vb
</ProjectItem>
<ProjectItem TargetFileName="$fileinputname$.resx">
Form1.resx
</ProjectItem>

When an item derived from this template is added to a project, the file names will be based on the name
that the user typed in the Add New Item dialog box.
3. Select the files to be included in your template, right-click the selection, click Send To , and then click
Compressed (zipped) Folder . The files that you selected are compressed into a .zip file.
4. Put the .zip file in the user item template location. By default, the directory is \My Documents\Visual Studio
Version\Templates\ItemTemplates\. For more information, see How to: Locate and Organize Templates.

Example
The following example shows a Visual Studio Windows Forms template. When an item is created based on this
template, the names of the three files created will match the name entered in the Add New Item dialog box.
<VSTemplate Version="2.0.0" Type="Item"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>Multi-file Item Template</Name>
<Icon>Icon.ico</Icon>
<Description>An example of a multi-file item template</Description>
<ProjectType>VisualBasic</ProjectType>
</TemplateData>
<TemplateContent>
<ProjectItem TargetFileName="$fileinputname$.vb" SubType="Form">
Form1.vb
</ProjectItem>
<ProjectItem TargetFileName="$fileinputname$.Designer.vb">
Form1.Designer.vb
</ProjectItem>
<ProjectItem TargetFileName="$fileinputname$.resx">
Form1.resx
</ProjectItem>
</TemplateContent>
</VSTemplate>

See Also
Creating Project and Item Templates How to: Create Item Templates Template Parameters How to: Substitute
Parameters in a Template
How to: Manually Create Web Templates
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Creating a Web template is different than creating other kinds of templates. Because Web project templates appear
in the Add New Web Site dialog box, and Web project items are categorized by programming language, the
.vstemplate file must specify the template as a Web template and identify the programming language.

NOTE
Web templates must contain a empty .webproj file that is specified by using the File attribute of the Project element.
Although Web projects do not require project files, this file is required so that a Web template functions correctly.

To manually create a Web template


1. Create a Web project.
2. Modify or delete the files in the project, or add new files to the project.
3. Create an XML file and save it by using a .vstemplate file name extension, in the same directory as your
project. Do not add it to the project in Visual Studio.
4. Author the .vstemplate XML file to provide project template metadata. For more information, see the
example in the following section.
5. Locate the ProjectType element in the .vstemplate file, and set the text value to Web .
6. Following the ProjectType element, add a ProjectSubType element and set the text value to the
programming language of the template. The programming language can be one of the following values:
CSharp
VisualBasic
For example:

<TemplateData>
...
<ProjectType>Web</ProjectType>
<ProjectSubType>CSharp</ProjectSubType>
...
</TemplateData>

7. Select the files in your template (this includes the .vstemplate file), right-click the selection, click Send To ,
and then click Compressed (zipped) Folder . The files are compressed into a .zip file.
8. Put the .zip template file in the Visual Studio project template directory. By default, this directory is \My
Documents\Visual Studio Version\My Exported Templates\.
Example
The following example shows a basic .vstemplate file for a Web project template.

<VSTemplate Version="2.0.0" Type="Project"


xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">>
<TemplateData>
<Name>MyWebProjecStarterKit</Name>
<Description>A simple Web template</Description>
<Icon>icon.ico</Icon>
<ProjectType>Web</ProjectType>
<ProjectSubType>CSharp</ProjectSubType>
<DefaultName>WebSite</DefaultName>
</TemplateData>
<TemplateContent>
<Project File="WebApplication.webproj">
<ProjectItem>icon.ico</ProjectItem>
<ProjectItem OpenInEditor="true">Default.aspx</ProjectItem>
<ProjectItem>Default.aspx.cs</ProjectItem>
</Project>
</TemplateContent>
</VSTemplate>

See Also
Creating Project and Item Templates Visual Studio Template Schema Reference
How to: Create Starter Kits
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

A Starter Kit contains code for a complete application and documentation on how to modify or expand the
application. Creating a Starter Kit is fundamentally the same as creating a normal project template, the only
difference being that a Starter Kit contains documentation files that are set to open when a project based on the
Starter Kit is created.

Designing and Developing a Starter Kit


First, you must identify the type of Starter Kit that you want to develop and define your target audience. Next,
design the project and documentation to meet your objectives.
If you are creating a sample application or plug-in:
Create a project that builds without errors.
Add template code to implement additional tasks (optional).
Prepare the documentation.
If you are creating a learning tool:
Create a project that builds without errors.
Organize the resources, such as code snippets and item templates.
Prepare the documentation.

Creating a Template
After you have completed the project and the documentation, you are ready to create the project template for the
Starter Kit. This process is exactly the same as creating a project template.
The following topics contain information about creating templates.
How to: Create Project Templates Explains how to use the Expor t Template wizard to create a template.
How to: Update Existing Templates Describes how to edit an exported template. Use this procedure to modify the
.vstemplate file to customize your Starter Kit.

See Also
Creating Project and Item Templates Customizing Templates Visual Studio Template Schema Reference
How to: Locate and Organize Project and Item
Templates
10/18/2019 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Template files must be placed in a location that Visual Studio recognizes so that the templates will appear in the
New Project and Add New Item dialog boxes. You can create custom subcategories for templates so that the
subcategories will also appear in the user interface.

Locating Templates
By default, Visual Studio searches two locations for project and item templates. If a compressed file that includes a
.vstemplate file exists in these locations, a template will appear in the New Project or Add New Item dialog
boxes.
Installed Templates
By default, templates installed together with the product are located in:
\VisualStudioInstallationDirectory\Common7\IDE\ItemTemplates\Language\Locale\
\VisualStudioInstallationDirectory\Common7\IDE\ProjectTemplates\Language\Locale\
For example, the following directory contains the Visual Studio project templates for English:
C:\VisualStudioInstallationDirectory\Common7\IDE\ItemTemplates\VisualBasic\1033\
Custom Templates
By default, custom templates are located in:
\My Documents\Visual Studio Version\Templates\ProjectTemplates\Language\
\My Documents\Visual Studio Version\Templates\ItemTemplates\Language\
For example, the following directory contains custom Visual C# project templates:
C:\Documents and Settings\UserName\My Documents\<Visual Studio
version>\Templates\ProjectTemplates\Visual C#\
Custom templates do not include a subdirectory for localized templates. You can change the default
directory for custom templates in the Options dialog box, under Environment\Projects and Solutions .

Organizing Templates
The categories in the New Project and Add New Item dialog boxes reflect the directory structures that exist in
the installed and custom template locations. You can modify these directory structures to organize your templates
in a way that makes sense to you.
NOTE
You cannot create a new category at the programming language level. New categories can only be created within each
language.

If the directory structures for installed and custom templates for a particular language do not have the same
structure (that is, there are directories under one folder that do not exist under the other) the set of categories that
appear in the New Project dialog will be the merger of all categories.
Organizing Installed Templates
You can organize installed templates by creating subdirectories in the programming language folder. These
subdirectories appear in the New Project and Add New Item dialog boxes as virtual folders within each
language.
To c r e a t e n e w i n st a l l e d p r o j e c t t e m p l a t e c a t e g o r i e s

1. Create a folder in the language folder of the installed template directory. For example, to create an Office
category for Visual Studio project templates you would create the following directory:
\VisualStudioInstallationDirectory\Common7\IDE\ProjectTemplates\VisualBasic\1033\Office\
2. Place all the templates for this category in the new folder.
3. Close all instances of Visual Studio.
4. On the Star t menu, click Run , type cmd , and click OK .
5. At the command prompt, locate the directory that contains devenv.exe, and type devenv
/installvstemplates .
6. Run Visual Studio.
7. On the File menu, click New , and then click Project .
8. Verify that the Office category appears in the New Project dialog box, in the Project types pane, under
Visual Basic.
You can also group a subset of the project item templates into a custom folder.
To c r e a t e n e w i n st a l l e d i t e m t e m p l a t e c a t e g o r i e s

1. Create a folder in the language folder of the installed template directory. For example, to create a Web
category for Visual C# item templates you would create the following directory:
\VisualStudioInstallationDirectory\Common7\IDE\ItemTemplates\CSharp\1033\Web\
2. Place all templates for this category in the new folder.
3. Close all instances of Visual Studio.
4. On the Star t menu, click Run , type cmd , and click OK .
5. At the command prompt, locate the directory that contains devenv.exe, and type devenv /setup .
6. Run Visual Studio.
7. Create a project or open an existing project.
8. On the Project menu, click Add New Item .
9. Verify that the Web category appears in the Add New Item dialog box, in the Project types pane.
Organizing Custom Templates
Custom templates can be organized into their own categories by adding new folders in the custom template
location. The New Project dialog box reflects any changes you make to your template categories.
To c r e a t e n e w c u st o m p r o j e c t t e m p l a t e c a t e g o r i e s

1. Create a folder in the language folder in the custom project template directory. For example, to create a
HelloWorld category for Visual C# templates, you would create the following directory:
\My Documents\<Visual Studio version>\Templates\ProjectTemplates\CSharp\HelloWorld\
2. Place all the templates for this category in the new folder.
3. On the File menu, click New , and then click Project .
4. Verify that the HelloWorld category appears in the New Project dialog box, in the Project types pane,
under Visual C#.
You can also group a subset of the custom item templates into a custom folder.
To c r e a t e n e w c u st o m i t e m t e m p l a t e c a t e g o r i e s

1. Create a folder in the language folder in the custom item template directory. For example, to create a
HelloWorld category for Visual C# templates you would create the following directory:
\My Documents\<Visual Studio version>\Templates\ItemTemplates\CSharp\HelloWorld\
2. Place all the templates for this category in the new folder.
3. Create a project or open an existing project.
4. On the Project menu, click Add New Item .
5. Verify that the HelloWorld category appears in the Add New Item dialog box, in the Project types pane.
Displaying Templates in Parent Categories
You can enable templates in subcategories to be displayed in their parent categories by using the
NumberOfParentCategoriesToRollUp element in the .vstemplate file. These steps are identical for both project
templates and item templates.
To d i sp l a y t e m p l a t e s i n p a r e n t c a t e g o r i e s

1. Locate the .zip file that contains the template.


2. Extract the .zip file.
3. Open the .vstemplate file in Visual Studio.
4. In the TemplateData element, add a NumberOfParentCategoriesToRollUp element. For example, the following
code makes the template visible in the parent category, but no higher.

<TemplateData>
...
<NumberOfParentCategoriesToRollUp>
1
</NumberOfParentCategoriesToRollUp>
...
</TemplateData>

5. Save and close the .vstemplate file.


6. Select the files in your template, right-click the selection, click Send To , and then click Compressed
(zipped) Folder . The files are compressed into a .zip file.
7. Delete the extracted template files and the old template .zip file.
8. Put the new .zip file in the directory that had the deleted .zip file.

See Also
Customizing Templates Visual Studio Template Schema Reference NumberOfParentCategoriesToRollUp (Visual
Studio Templates) How to: Create Project Templates How to: Create Item Templates
Customizing Project and Item Templates
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

After project and item templates have been created, you still have the ability to further customize them to meet
your needs.
For example, you can perform the following tasks:
Modify and export an existing template as a custom template.
For more information, see How to: Update Existing Templates.
Pass custom parameters into a template to replace existing values.
For more information, see How to: Substitute Parameters in a Template.
Customize the wizards that create projects from templates.
For more information, see How to: Use Wizards with Project Templates.

Related Sections
Creating Project and Item Templates
How to: Troubleshoot Templates
How to: Create Project Templates
How to: Create Item Templates
How to: Create Starter Kits
Visual Studio Template Schema Reference
IWizard
How to: Update Existing Templates
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

After you create a template and compress the files into a .zip file, you may want to modify the template. You can do
this by manually changing the files in the template, or by exporting a new template from a project that is based on
the template.

Using the Export Template Wizard to Update an Existing Template


Visual Studio provides an Expor t Template wizard that can be used to update an existing template.
To use Export Template to update an existing template
1. On the File menu, click New and then click New Project .
2. Select the template that you want to update, enter a name and location for your temporary project, and click
OK .
3. Modify the project in Visual Studio.
4. On the File menu, click Expor t Template , and use the Expor t Template wizard to create a new template.
5. After the updated template is compressed into a .zip file, delete the old template .zip file.

Manually Updating an Existing Template


You can update an existing template outside Visual Studio by modifying the files in the compressed .zip file.
To manually update an existing template
1. Locate the .zip file that contains the template. By default, this file is located in \My Documents\Visual Studio
Version\My Exported Templates\.
2. Extract the .zip file.
3. Modify or delete the current template files, or add new files to the template.
4. Open, modify, and save the .vstemplate XML file to handle updated behavior or new files. For more
information about the .vstemplate schema, see Visual Studio Template Schema Reference. For more
information about what you can parameterize in the source files, see Template Parameters
5. Select the files in your template, right-click, click Send To , and then click Compressed (zipped) Folder .
The files that you selected are compressed into a .zip file.
6. Put the new .zip file in the same directory as the old .zip file.
7. Delete the extracted template files and the old template .zip file.
8. Start (as administrator) an instance of the Developer Command Prompt (on the start menu, under Visual
Studio 2010 / Visual Studio Tools/Developer Command Prompt ).
9. Run the following command: devenv /installvstemplates .
See Also
Customizing Templates Creating Project and Item Templates Visual Studio Template Schema Reference Template
Parameters How to: Create Starter Kits
How to: Substitute Parameters in a Template
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You may replace template parameters such as class names and namespaces when a file based on a template is
created. For a complete list of template parameters, see Template Parameters.

Procedure
You may replace parameters in the files of a template whenever a project based on that template is created. This
procedure explains how to create a template that replaces the name of a namespace with the safe project name
when a new project is created with the template.
To use a parameter to replace namespace name with the project name
1. Insert the parameter in one or more of the code files in the template. For example:

namespace $safeprojectname$

NOTE
Template parameters are written in the format $parameter$.

2. In the .vstemplate file for the template, locate the ProjectItem element that includes this file.
3. Set the ReplaceParameters attribute to true for the ProjectItem element. For example:

<ProjectItem ReplaceParameters="true">Class1.cs</ProjectItem>

See Also
Creating Project and Item Templates Template Parameters Visual Studio Template Schema Reference ProjectItem
Element (Visual Studio Item Templates)
How to: Troubleshoot Templates
2/19/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

If a template fails to load in the development environment, there are several ways to locate the problem.

Validating the .vstemplate File


If the .vstemplate file in a template does not adhere to the Visual Studio template schema, the template may not
appear in the New Project dialog box.
To validate the .vstemplate file
1. Locate the .zip file that contains the template.
2. Extract the .zip file.
3. On the File menu in Visual Studio, click Open , and then click File .
4. Select the .vstemplate file for the template, and click Open .
5. Verify that the XML of the .vstemplate file adheres to the Visual Studio template schema. For more
information on the .vstemplate schema, see Visual Studio Template Schema Reference.

NOTE
To get IntelliSense support while authoring the .vstemplate file, add a xmlns attribute to the VSTemplate element
and assign it a value of http://schemas.microsoft.com/developer/vstemplate/2005 .

6. Save and close the .vstemplate file.


7. Select the files included in your template, right-click, select Send To , and click Compressed (zipped)
Folder . The files that you selected are compressed into a .zip file.
8. Place the new .zip file in the same directory as the old .zip file.
9. Delete the extracted template files and the old template .zip file.

Monitoring the Event Log


Visual Studio logs errors encountered when processing template .zip files. If a template does not show up in the
New Project dialog box as expected, you can use Event Viewer to troubleshoot the issue.
To locate template errors in Event Viewer
1. In Windows, click Star t , click Control Panel , double-click Administrative Tools , and then double-click
Event Viewer .
2. In the left pane, click Application .
3. Look for events with a Source value of Visual Studio - VsTemplate .
4. Double-click on a template event to view the error.

See Also
Customizing Templates Creating Project and Item Templates Visual Studio Template Schema Reference
Visual Studio Template Reference
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The following links provide reference information about the different aspects of Visual Studio project and item
templates.

In This Section
Visual Studio Template Schema Reference Describes the XML elements used in .vstemplate files.
Template Parameters Describes the parameters available for project and item templates.
Microsoft.VisualStudio.TemplateWizard Describes the IWizard interface and related types.

Related Sections
How to: Create Project Templates
How to: Create Item Templates
Customizing Templates
How to: Create Starter Kits
Template Parameters
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

By using parameters in your templates, you can replace the values of key portions of the template, such as class
names and namespaces, when the template is instantiated. These parameters are replaced by the template
wizard that runs in the background when a user clicks OK in the New Project or Add New Item dialog boxes.

Declaring and Enabling Template Parameters


Template parameters are declared in the format $parameter$. For example:
$safeprojectname$
$guid1$
$guid5$
To enable parameter substitution in templates
1. In the .vstemplate file of the template, locate the ProjectItem element that corresponds to the item for
which you want to enable parameter replacement.
2. Set the ReplaceParameters attribute of the ProjectItem element to true .
3. In the code file for the project item, include parameters where appropriate. For example, the following
parameter specifies that the safe project name be used for the namespace in a file:

namespace $safeprojectname$

Reserved Template Parameters


The following table lists the reserved template parameters that can be used by any template.

NOTE
Template parameters are case-sensitive.

PA RA M ET ER DESC RIP T IO N

clrversion Current version of the common language runtime (CLR).

GUID [1-10] A GUID used to replace the project GUID in a project file. You
can specify up to 10 unique GUIDs (for example, guid1) .
PA RA M ET ER DESC RIP T IO N

itemname The name provided by the user in the Add New Item dialog
box.

machinename The current computer name (for example, Computer01).

projectname The name provided by the user in the New Project dialog
box.

registeredorganization The registry key value from


HKLM\Software\Microsoft\Windows
NT\CurrentVersion\RegisteredOrganization.

rootnamespace The root namespace of the current project. This parameter


applies only to item templates.

safeitemname The name provided by the user in the Add New Item dialog
box, with all unsafe characters and spaces removed.

safeprojectname The name provided by the user in the New Project dialog
box, with all unsafe characters and spaces removed.

time The current time in the format DD/MM/YYYY 00:00:00.

SpecificSolutionName The name of the solution. When "create solution directory" is


checked, SpecificSolutionName has the solution name.
When "create solution directory" is not checked,
SpecificSolutionName is blank.

userdomain The current user domain.

username The current user name.

webnamespace The name of the current Web site. This parameter is used in
the Web form template to guarantee unique class names. If
the Web site is at the root directory of the Web server, this
template parameter resolves to the root directory of the
Web Server.

year The current year in the format YYYY.

Custom Template Parameters


You can specify your own template parameters and values, in addition to the default reserved template
parameters that are used during parameter replacement.For more information, see CustomParameters Element
(Visual Studio Templates)

Example: Replacing Files Names


You can specify variable file names for project items by using a parameter with the TargetFileName attribute. For
example, you could specify that the .exe file use the project name, specified by $projectname$ , as the file name.
<TemplateContent>
<ProjectItem
ReplaceParameters="true"
TargetFileName="$projectname$.exe">
File1.exe
</ProjectItem>
...
</TemplateContent>

Example: Using the Project Name for the Namespace Name


To use the project name for the namespace in a Visual C# class file, Class1.cs, use the following syntax:

#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

#endregion

namespace $safeprojectname$
{
public class Class1
{
public Class1()
{

}
}
}

In the .vstemplate file for the project template, include the following XML when you reference the file Class1.cs:

<TemplateContent>
<ProjectItem ReplaceParameters="true">
Class1.cs
</ProjectItem>
...
</TemplateContent>

See Also
Customizing Templates
Writing Code in the Code and Text Editor
10/16/2020 • 13 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Visual Studio editor provides many features that make it easier for you to write and manage your code. You
can expand and collapse different blocks of code by using outlining. You can learn more about the code you are
using by using IntelliSense, the Object Browser , and the Call Hierarchy. You can navigate inside your code by
using features such as Navigate To , Go To Definition , and Find All References . You can insert blocks of code
with code snippets, and you can generate code by using features such as Generate From Usage . If you have
never used the Visual Studio 2015 editor before, see Editing Your Code for a quick overview.
You can view your code in a number of different ways. To see a class view of your solution, you can open the
Class View window or expand the nodes in the Solution Explorer under your class files.
You can search and replace text for single or multiple files. For more information, see Finding and Replacing Text.
If you use regular expressions, note that find and replace now use .NET regular expressions. For more
information, see Using Regular Expressions in Visual Studio.
The different Visual Studio languages offer different sets of features, and in some cases the features behave
differently in different languages. Many of these differences are specified in the descriptions of the features, but
for more information you can see the sections on specific Visual Studio languages.

IMPORTANT
The Visual Studio edition and the settings you are using may affect the features in the IDE. They might differ from those
described in this topic.

Editor Features
F EAT URE DESC RIP T IO N

Syntax Coloring Some syntax elements of code and markup files are colored
differently to distinguish them. For example, keywords (such
as using in C# and Imports in Visual Basic) are one color,
but types (such as Console and Uri ) are another color.
Other syntax elements are also colorized, such as string
literals and comments. C++ uses color to differentiate
among types, enumerations, and macros, among other
tokens.

You can see the default color for each type, and you can
change the color for any specific syntax element in the Fonts
and Colors, Environment, Options Dialog Box, which you can
open from the Tools menu.
F EAT URE DESC RIP T IO N

Error and Warning Marks As you add code and build your solution, you may see (a)
different-colored wavy underlines (known as squiggles) or (b)
light bulbs appearing in your code. Red squiggles denote
syntax errors, blue denotes compiler errors, green denotes
warnings, and purple denotes other types of errors. Light
bulbs suggest fixes for problems and make it easy to apply
the fix.

You can see the default color for each error and warning
squiggle in the Tools/Options/Environment/Fonts and
Colors dialog box. Look for Syntax Error , Compiler Error ,
Warning , and Other Error .

Brace Matching When the insertion point is placed on an open brace in a


code file, both it and the closing brace are highlighted. This
feature gives you immediate feedback on misplaced or
missing braces. You can turn brace matching on or off with
the Automatic Delimiter Highlighting setting
(Tools/Options/Text Editor ). You can change the highlight
color in the Fonts and Colors setting
(Tools/Options/Environment ). Look for Brace Matching
(Highlight) or Brace Matching (Rectangle) .

Line Numbers Line numbers can be displayed in the left margin of the code
window. They are not displayed by default. You can turn this
option on in the Text Editor All Languages settings
(Tools/Options/Text Editor/All Languages ). You can
display line numbers for individual programming languages
by changing the settings for those languages
(Tools/Options/Text Editor/<language> ). For line
numbers to print, you must select Include line numbers in
the Print dialog box.

Change Tracking The color of the left margin allows you to keep track of the
changes you have made in a file. Changes you have made
since the file was opened but not saved are denoted by a
yellow bar on the left margin (known as the selection
margin). After you have saved the changes (but before
closing the file), the bar turns green. If you undo a change
after you have saved the file, the bar turns orange. To turn
this feature off and on, change the Track changes option in
the Text Editor settings (Tools/Options/Text Editor ).

Selecting Code and Text You can select text either in the standard continuous stream
mode or in box mode, in which you select a rectangular
portion of text instead of a set of lines. To make a selection in
box mode, press ALT as you drag the mouse over the
selection (or press ALT + SHIFT + <arrow key>). The
selection includes all of the characters within the rectangle
defined by the first character and the last character in the
selection. Anything typed or pasted into the selected area is
inserted at the same point on each line.
F EAT URE DESC RIP T IO N

Zoom You can zoom in or out in any code window by pressing and
holding the CTRL key and moving the scroll wheel on the
mouse (or CTRL + SHIFT + . to increase and CTRL + SHIFT +
, to decrease). You can also use the Zoom box in the lower
left corner of the code window to set a specific zoom
percentage. The zoom feature does not work in tool
windows.

Virtual Space By default, lines in Visual Studio editors end after the last
character, so that the RIGHT ARROW key at the end of a line
moves the cursor to the beginning of the next line. In some
other editors a line does not end after the last character, and
you can place your cursor anywhere on the line. You can
enable virtual space in the editor in the Tools/Options/Text
Editor/All Languages settings. Note that you can enable
either Vir tual Space or Word Wrap , but not both.

Printing You can use the options in the Print dialog box to include
line numbers or hide collapsed regions of code when you
print a file. In the Page Setup dialog box, you can also
choose to print the full path and the name of the file by
choosing Page header .

You can set color printing options in the


Tools/Options/Environment/Fonts and Colors dialog
box. Choose Printer in the Show settings for list to
customize color printing. You can specify different colors for
printing a file than for editing a file.

Global Undo and Redo The Undo Last Global Action and Redo Last Global
Action commands on the Edit menu undo or redo global
actions that affect multiple files. Global actions include
renaming a class or namespace, performing a find-and-
replace operation across a solution, refactoring a database,
or any other action that changes multiple files. You can apply
the global undo and redo commands to actions in the
current Visual Studio session, even after you close the
solution in which an action was applied.

Advanced Editing Features


You can find a number of advanced features on the Edit/Advanced submenu. Not all these features are
available for all types of code files.

F EAT URE DESC RIP T IO N

Format Document Sets the proper indentation of lines of code and moves curly
braces to separate lines in the document.

Format Selection Sets the proper indentation of lines of code and moves curly
braces to separate lines in the selection.

Tabify Selected Lines Changes leading spaces to tabs where appropriate.


F EAT URE DESC RIP T IO N

Untabify Selected Lines Changes leading tabs to spaces. If you want to convert all
the spaces in your file to tabs (or all the tabs to spaces), you
can use the Edit.ConvertSpacesToTabs and
Edit.ConvertTabsToSpaces commands. These commands
do not appear in Visual Studio menus, but you can call them
from the Quick Access window or the command window.

Make Uppercase Changes all characters in the selection to uppercase, or if


there is no selection, changes the character at the insertion
point to uppercase.

Make Lowercase Changes all characters in the selection to lowercase, or if


there is no selection, changes the character at the insertion
point to lowercase.

Validate Document Validates JScript code files.

Delete Horizontal White Space Deletes tabs or spaces at the end of the current line.

View White Space Displays spaces as raised dots, and tabs as arrows. The end
of a file is displayed as a rectangular glyph. If
Tools/Options/Text Editor/All Languages/Word
Wrap/Show visible glyphs for word wrap is selected,
that glyph is also displayed.

Word Wrap Causes all the lines in a document to be visible in the code
window. You can turn word wrap off and on in the Text Editor
All Languages settings (Tools/Options/ Text Editor/All
Languages ).

Uncomment Selection Adds comment characters to the selection or the current line.

Comment Selection Removes comment characters from the selection or the


current line.

Increase Line Indent Adds a tab (or the equivalent spaces) to the selected lines or
the current line.

Decrease Line Indent Removes a tab (or the equivalent spaces) from the selected
lines or the current line.

Select Tag In a document that contains tags (for example, XML or


HTML), selects the tag.

Select Tag Content In a document that contains tags (for example, XML or
HTML), selects the content.

Navigate in the Code Window


You can move around in a document in several different ways. In addition to the standard operations, you can
use the Navigate Backward (or CTRL + MINUS) and Navigate For ward (CTRL + SHIFT + MINUS) buttons on
the toolbar to move the insertion point to previous locations or return to more recent locations in the active
document. These buttons retain the last 20 locations of the insertion point.
You can also use the enhanced scroll bar in a code window to get a bird’s-eye view of your code. In map mode,
you can see previews of the code when you move the cursor up and down the scroll bar, For more information,
see How to: Track Your Code by Customizing the Scrollbar.
The following commands are code-specific navigation methods:

C OMMAND DESC RIP T IO N

Go To <line number> (Edit/Go To or CTRL + G): Move to a specific line number in


the active document.

Navigate To (Edit/Navigate To or CTRL + ,): Finds a symbol or file in the


active solution. It helps you pick a good set of matching
results from a query. You can search for keywords that are
contained in a symbol by using camel casing and underscore
characters to divide the symbol into keywords.

Find All References (context menu): Finds all the references to the selected
element in the solution.

Go To Definition (context menu or F12): Finds the definition of the selected


element.

Peek Definition (context menu or Alt+F12): Finds the definition of the


selected element and displays it in a popup window. For
more information, see How to: View and Edit Code by Using
Peek Definition (Alt+F12).

Next Method, Previous Method (Edit/Next Method, Previous Method ) In Visual Basic
code files, use these commands to move the insertion point
to different methods.

Reference Highlighting When you click a symbol in the source code, all instances of
that symbol are highlighted in the document. The
highlighted symbols may include declarations and references,
and many other symbols that Find All References would
return. These include the names of classes, objects, variables,
methods, and properties. In Visual Basic code, keywords for
many control structures are also highlighted. To move to the
next or the previous highlighted symbol, press
CTRL+SHIFT+DOWN ARROW or CTRL+SHIFT+UP ARROW.
You can change the highlighting color in
Tools/Options/Environment/Fonts and
Colors/Highlighted Reference.
C OMMAND DESC RIP T IO N

Find code-related info You can find info about specific code, like changes and who
made those changes, references, bugs, work items, code
reviews, and unit test status when you use CodeLens in the
code editor. CodeLens works like a heads-up display when
you use Visual Studio Enterprise with Team Foundation
Server. See Find code changes and other history.

You can also use the navigation bar , that is, the two dropdown boxes displayed at the top of the code window,
to navigate in a code file. This bar allows you to navigate directly to a particular type or to one of the members
within a type. The navigation bar appears with Visual Basic, C#, and C++ code files.
To hide the navigation bar, change the Navigation bar option in the Text Editor All Languages settings
(Tools/Options/Text Editor/All Languages , or you can change the settings for individual languages). You can
navigate in the dropdown boxes as follows:
To shift focus from the code window to the navigation bar, press the shortcut key combination CTRL+F2.
To return focus from the navigation bar to the code window, press the ESC key.
To shift focus from item to item on the navigation bar, press the TAB key.
To select the Navigation bar item that has focus and return to the IDE, press the ENTER key
To navigate to a class or type, click its name in the left dropdown.
To navigate directly to a procedure in a class, click a procedure in the right dropdown.
In a partial class, members defined outside the current code file may be grayed out.

Find code using Navigate To


Visual Studio's "Navigate To" command does a focused search of your code to help you quickly find specified
elements in code files, file paths and code symbols. Unlike other text searches such as Find or Find in Files,
Navigate To limits its search to areas where actual code lives, such as files, forms and code modules. For example,
if you search for a string in an ASP.NET web application using Find or Find in Files in the whole solution, you
might get several hits, including instances of the string in code remarks. By using Navigate To, however, you
might only get a single function, ignoring any instances of the string in code remarks.
Navigate code using Navigate To
1. Open a solution or folder in Visual Studio.
2. On the main menu, choose Edit , Navigate To , or press CTRL + ,.
A small text box appears in the upper corner of the code editor.
3. In the text box, enter the name of the code element you want to find.
As you type, the results appear in a dropdown list below the text box.
4. To go to an element, choose it in the list.
Filter your search
To limit your search to only code symbols, preface your Navigate To query with an "@" character. For example, if
you search for @application , Navigate To displays, for example, only classes that have the word "application" in
them.
If you use camel casing in your code, you can find code elements faster by entering only the capital letters of
code element name. For example, if your code has a component called ViewSwitcher , you can find it by entering
just the capital letters of the name ( "VS" ) in the Navigate To window.

This feature is particularly helpful if your code has long names.

Customize the Editor


Impor t and Expor t Settings : You can share settings with another developer, have your settings conform to a
standard, or return to Visual Studio default settings by using the Impor t and Expor t Settings Wizard on the
Tools menu. You can change general settings or language and project-specific settings.
Keyboard Mapping : You can define new hotkeys or redefine existing ones in the
Tools/Options/Environment/Keyboard settings. For more information about hotkeys, see Default Keyboard
Shortcuts.
For information about language-specific editor options, see the following:
Visual Basic Settings
Using the Visual Studio Development Environment for C#
Options, Text Editor, JavaScript, Formatting
In this section
Finding and Replacing Text
Encodings and Line Breaks
Outlining
Refactoring
Productivity Tips
Using IntelliSense
Customizing the Editor
How to: Track Your Code by Customizing the Scrollbar
How to: View and Edit Code by Using Peek Definition (Alt+F12)
Perform quick actions with light bulbs
Code Snippets
Using the Toolbox
Viewing the Structure of Code
Setting Bookmarks in Code
Using the Task List
Find code changes and other history

See Also
Visual Studio IDE
Finding and Replacing Text
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can find and replace text in the Visual Studio code editor, and certain text-based output windows such as the
Find Results windows, using the Find and Replace control or Find/Replace in Files . You can also search and
replace in some designer windows, such as the XAML designer and the Windows Forms designer, and tool
windows
You can scope searches to the current document, the current solution, or a custom set of folders. You can also
specify a set of file name extensions for multi-file searches. You can customize search syntax by using .NET regular
expressions.
To find and replace regular expressions, see Using Regular Expressions in Visual Studio.

TIP
The Find/Command box is still available as a toolbar control, but is no longer visible by default. You can display the
Find/Command box by choosing Add or Remove Buttons on the Standard toolbar and then choosing Find . For more
information, see Find/Command Box.

Find and Replace control


The Find and Replace control appears in the upper right corner of the code editor window. The Find and
Replace control immediately highlights every occurrence of the given search string in the current document. You
can navigate from one occurrence to another by choosing the Find Next button or the Find Previous button on
the search control.
You can access replacement options by choosing the button next to the Find text box. To make one replacement at
a time, choose the Replace Next button next to the Replace text box. To replace all matches, choose the Replace
All button.
To change the highlight color for matches, choose the Tools menu, select Options , and then choose
Environment , and select Fonts and Colors . In the Show settings for list, select Text Editor , and then in the
Display items list, select Find Highlight (Extension) .
Searching Tool Windows
You can use the Find control in code or text windows, such as Output windows, and Find Results windows, by
choosing Find and Replace on the Edit menu or (CTRL+F).
A version of the Find control is also available in some tool windows. For example, you can now filter the list of
controls in the Toolbox window by entering text in the search box. Other tool windows that now allow you to
search their contents include Solution Explorer , the Proper ties window, and Team Explorer , among others.

Find/Replace in Files
Find/Replace in Files works like the Find and Replace control, except that you can define a scope for your
search. Not only can you search the current open file in the editor, but you can also search all open documents,
the entire solution, the current project, and selected folder sets. You can also search by file name extension. To
access the Find/Replace in Files dialog box, choose Find and Replace on the Edit menu (or CTRL+SHIFT+F).
When you choose Find All , a Find Results window opens and lists the matches for your search. Selecting a
result in the list displays the associated file and highlights the match. If the file is not already open for editing, it is
opened in a preview tab in the right side of the tab well. You can use the Find control to search through the Find
Results list.
Creating Custom Search Folder Sets
You can define a search scope by choosing the Choose Search Folders button (it looks like … ) next to the Look
in box. In the Choose Search Folders dialog box, you can specify a set of folders in which to search, and you
can save the specification so that you can reuse it later. You can specify folders on a remote machine only if you
have mapped its drive to the local machine.
Creating Custom Component Sets
You can define component sets as your search scope by choosing the Edit Custom Component Set button next
to the Look in box. You can specify installed .NET or COM components, Visual Studio projects that are included in
your solution, or any assembly or type library (.dll, .tlb, .olb, .exe, or .ocx). To search references, select the Look in
references box.

See Also
Using Regular Expressions in Visual Studio
Use Regular Expressions in Visual Studio
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Visual Studio uses .NET Framework regular expressions to find and replace text. For more information about .NET
regular expressions, see .NET Framework Regular Expressions.
Before Visual Studio 2012, Visual Studio used custom regular expression syntax in the Find and Replace windows.
See Visual Studio Regular Expression Conversions for an explanation of how to convert some of the more
commonly-used custom regular expression symbols to the .NET versions.

TIP
In Windows operating systems, most lines end in “\r\n” (a carriage return followed by a new line). These characters are not
visible, but are present in the editor and are passed to the .NET Regular Expression service.

TIP
For information about regular expressions that are used in replacement patterns, see Substitutions. To use a numbered
capture group, the syntax is $1 to specify the numbered group and (x) to specify the group in question. For example,
the grouped regular expression (\d)([a-z]) finds four matches in the following string: 1a 2b 3c 4d . The replacement
string z$1 converts that string to z1 z2 z3 z4 .

Regular expression examples


Here are some examples:

P URP O SE EXP RESSIO N EXA M P L E

Match any single character (except a . a.o matches "aro" in "around" and
line break) "abo" in "about" but not "acro" in
"across".

Match zero or more occurrences of the * a*r matches "r" in "rack", "ar" in "ark",
preceding expression (match as many and "aar" in "aardvark"
characters as possible)

Match any character zero or more .* c.*e matches “cke” in “racket”, “comme”
times (Wildcard *) in “comment”, and “code” in “code”

Match one or more occurrences of the + e.+e matches "eede" in "feeder" but
preceding expression (match as many not "ee".
characters as possible)
P URP O SE EXP RESSIO N EXA M P L E

Match any character one or more .+ e.+e matches "eede" in "feeder" but not
times (Wildcard ?) "ee".

Match zero or more occurrences of the *? e.*?e matches "ee" in "feeder" but
preceding expression (match as few not "eede".
characters as possible)

Match one or more occurrences of the +? e.+?e matches "ente" and "erprise" in
preceding expression (match as few "enterprise", but not the whole word
characters as possible) "enterprise".

Anchor the match string to the ^ ^car matches the word "car" only
beginning of a line or string when it appears at the beginning of a
line.

Anchor the match string to the end of \r?$ End\r?$ matches "end" only when it
a line appears at the end of a line.

Match any single character in a set [abc] b[abc] matches "ba", "bb", and "bc".

Match any character in a range of [a-f] be[n-t] matches "bet" in "between",


characters "ben" in "beneath", and "bes" in
"beside", but not "below".

Capture and implicitly number the () ([a-z])X\1 matches "aXa"and "bXb",


expression contained within but not "aXb". ". “\1” refers to the first
parenthesis expression group “[a-z]”.

Invalidate a match (?!abc) real (?!ity) matches "real" in


"realty" and "really" but not in "reality."
It also finds the second "real" (but not
the first "real") in "realityreal".

Match any character that is not in a [^abc] be[^n-t] matches "bef" in "before",
given set of characters "beh" in "behind", and "bel" in "below",
but not "beneath".

Match either the expression before or | (sponge&#124;mud) bath matches


the one after the symbol. "sponge bath" and "mud bath."

Escape the character following the | \^ matches the character ^.


backslash

Specify the number of occurrences of {x}, where x is the number of x(ab){2}x matches "xababx", and
the preceding character or group occurrences x(ab){2,3}x matches "xababx" and
"xabababx" but not "xababababx".

Match text in a Unicode character class, \p{X} \p{Lu} matches "T" and "D" in
where “X” is the Unicode number. For "Thomas Doe".
more information about Unicode
character classes, see

Unicode Standard 5.2 Character


Properties.
P URP O SE EXP RESSIO N EXA M P L E

Match a word boundary \b (Outside a character class \b \bin matches "in" in "inside" but not
specifies a word boundary, and inside a "pinto".
character class specifies a backspace).

Match a line break (ie a carriage return \r?\n End\r?\nBegin matches "End" and
followed by a new line). "Begin" only when "End" is the last
string in a line and "Begin" is the first
string in the next line.

Match any alphanumeric character \w a\wd matches "add" and "a1d" but
not "a d".

Match any whitespace character. (?([^\r\n])\s) Public\sInterface matches the


phrase "Public Interface".

Match any numeric character \d \d matches and "3" in "3456", "2" in


23", and "1" in "1".

Match a Unicode character \uXXXX where XXXX specifies the \u0065 matches the character "e".
Unicode character value.

Match an identifier \b(\w+|[\w-[0-9\]]\w*)\b Matches "type1" but not &type1" or


"#define".

Match a string inside quotes ((\".+?\")|('.+?')) Matches any string inside single or
double quotes.

Match a hexadecimal number \b0[xX]([0-9a-fA-F])\b Matches "0xc67f" but not "0xc67fc67f".

Match integers and decimals \b[0-9]*\.*[0-9]+\b Matches "1.333".


Find/Command Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can search for text and run Visual Studio commands from the Find/Command box. The Find/Command
box is still available as a toolbar control, but is no longer visible by default. You can display the
Find/Command box by choosing Add or Remove Buttons on the Standard toolbar and then choosing
Find .
To run a Visual Studio command, preface it with a greater than (>) sign.
The Find/Command box retains the last 20 items entered and displays them in a drop-down list. You can
navigate through the list by choosing the arrow keys.

Find/Command Box

Searching for Text


By default, when you specify text in the Find/Command box and then choose the ENTER key, Visual Studio
searches the current document or tool window using the options that are specified in the Find in Files dialog
box. For more information, see Finding and Replacing Text.

Entering Commands
To use the Find/Command box to issue a single Visual Studio command or alias rather than search for text,
enter the Visual Studio command, prefaced with a greater than (>) symbol. For example:

>File.NewFile c:\temp\MyFile /t:"General\Text File"

Alternatively, you can also use the Command window to enter and execute single or multiple commands. Some
commands or aliases can be entered and executed by themselves; others have required arguments in their
syntax. For a list of commands that have arguments, see Visual Studio Commands.

Escape Characters
A caret (^) character in a command line means that the character immediately following it is interpreted
literally, rather than as a control character. This can be used to embed straight quotation marks ("), spaces,
leading slashes, carets, or any other literal characters in a parameter or switch value, with the exception of
switch names. For example,

>Edit.Find ^^t /regex

A caret functions the same whether it is inside or outside quotation marks. If a caret is the last character on the
line, it is ignored.
See Also
Command Window Finding and Replacing Text
Find in Files
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Find in Files** allows you to search a specified set of files. The matches found and actions taken are listed in the
Find Results window selected in Result options .
You can use any of the following methods to display Find in Files in the Find and Replace window.
To display Find in Files
1. On the menu bar, choose Edit , Find and Replace .
2. Choose Find in Files .
To cancel a Find operation, press CTRL + BREAK.

NOTE
The Find and Replace tool does not search directories with the Hidden or System attribute set.

Find what
To search for a new text string or expression, specify it in the box. To search for any of the 20 strings that you
searched for most recently, open the list, and choose the string for which you want to search. Choose the adjacent
Expression Builder button if you want to use one or more regular expressions in your search string. For more
information, see Using Regular Expressions in Visual Studio.

Look in
The option chosen from the Look in drop-down list determines whether Find in Files searches only in currently
active files or in all files stored within certain folders. Select a search scope from the list or click the Browse (...)
button to display the Choose Search Folders dialog box and to enter your own set of directories. You can also
type a path directly into the Look in box.

WARNING
With the Entire Solution or Current Project options, project and solution files are not searched. If you want to look in
project files, choose a search folder.

NOTE
If the Look in option selected causes you to search a file that you have checked out from source code control, only the
version of that file which has been downloaded to your local machine is searched.
Include subfolders
Specifies that subfolders of the Look in folder will be searched.

Find options
You can expand or collapse the Find options section. The following options can be selected or cleared:
Match case When selected, a Find Results search will be case-sensitive
Match whole word When selected, the Find Results windows will only return whole word matches.
Use Regular Expressions If this check box is selected, you can use special notations to define patterns of text to
match in the Find what or Replace with text boxes. For a list of these notations, see Using Regular Expressions in
Visual Studio.
Look at these file types This list indicates the types of files to search through in the Look in directories. If this field
is blank, all of the files in the Look in directories will be searched.
Select any item in the list to enter a preconfigured search string that will find files of those particular types.

Result options
You can expand or collapse the Result options section. The following options can be selected or cleared:
Find results 1 window When selected, the results of the current search will replace the content of the Find Results
1 window. This window opens automatically to display your search results. To open this window manually, select
Other Windows from the View menu and choose Find Results 1 .
Find results 2 window When selected, the results of the current search will replace the content of the Find Results
2 window. This window opens automatically to display your search results. To open this window manually, select
Other Windows from the View menu and choose Find Results 2 .
Display file names only Displays a list of files containing search matches rather than displaying the search matches
themselves.
Append results Appends the results from the search to the previous search results.

See Also
Finding and Replacing Text Replace in Files Visual Studio Commands
Replace in Files
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Replace in Files** allows you to search the code of a specified set of files for a string or expression, and change
some or all of the matches found. The matches found and actions taken are listed in the Find Results window
selected in Result options .

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

You can use any of the following methods to display Replace in Files in the Find and Replace window.
To display Replace in Files
1. On the Edit menu, expand Find and Replace .
2. Choose Replace in Files .
— or —
If the Find and Replace window is already open, on the toolbar, choose Replace in Files .

Find what
To search for a new text string or expression, specify it in the box. To search for any of the 20 strings that you
searched for most recently, open the list, and choose the string for which you want to search. Choose the adjacent
Expression Builder button if you want to use one or more regular expressions in your search string. For more
information, see Using Regular Expressions in Visual Studio.

Replace With
To replace instances of the string in the Find what box with another string, enter the replacement string in the
Replace With box. To delete instances of the string in the Find what box, leave this field blank. Open the list to
display the 20 strings for which you searched most recently. Choose the adjacent Expression Builder button if
you want to use one or more regular expressions in your replacement string. For more information, see Using
Regular Expressions in Visual Studio.

Look in
The option chosen from the Look in drop-down list determines whether Replace in Files searches only in
currently active files or searches all files stored within certain folders. Select a search scope from the list, type a
folder path, or click the Browse (...) button to display the Choose Search Folders dialog box and choose a set of
folders to search. You can also type a path directly into the Look in box.
NOTE
If the Look in option selected causes you to search a file that you have checked out from source code control, only the
version of that file which has been downloaded to your local machine is searched.

Find options
You can expand or collapse the Find options section. The following options can be selected or cleared:
Match case When selected, the Find Results windows will only display instances of the Find what string that are
matched both by content and by case. For example, a search for "MyObject" with Match case selected will return
"MyObject" but not "myobject" or "MYOBJECT."
Match whole word When selected, the Find Results windows will only display instances of the Find what string
that are matched in complete words. For example, a search for "MyObject" will return "MyObject" but not
"CMyObject" or "MyObjectC."
Use Regular Expressions When this check box is selected, you can use special notations to define patterns of text in
the Find what or Replace with text boxes. For a list of these notations, see Using Regular Expressions in Visual
Studio.
Look at these file types This list indicates the types of files to search through in the Look in directories. If this field
is left blank, all of the files in the Look in directories will be searched.
Select any item in the list to enter a preconfigured search string that will find files of those particular types.

Result options
You can expand or collapse the Result options section. The following options can be selected or cleared:
Find Results 1 window When selected, the results of the current search will replace the content of the Find Results
1 window. This window opens automatically to display your search results. To open this window manually, select
Other Windows from the View menu and choose Find Results 1 .
Find Results 2 window When selected, the results of the current search will replace the content of the Find Results
2 window. This window opens automatically to display your search results. To open this window manually, select
Other Windows from the View menu and choose Find Results 2 .
Display file names only When this check box is selected, the Find Results windows list the full names and paths for
all files that contain the search string. However, the results don't include the line of code where the string appears.
This check box is available for Find in Files only.
Keep modified files open after Replace All When selected, leaves open all files in which replacements have been
made, so you can undo or save the changes. Memory constraints might limit the number of files that can remain
open after a replace operation.
Cau t i on

You can use Undo only on files that remain open for editing. If this option is not selected, files that were not
already open for editing will remain closed, and no Undo option will be available in those files.

See Also
Finding and Replacing Text Find in Files Visual Studio Commands
Encodings and Line Breaks
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In Visual Studio you can use the File/Advanced Save Options settings to determine the type of line break
characters you want. You can also change the encoding of a file with the same settings.

NOTE
If you have certain types of development settings (Visual Basic, F#, Web Development) you may not see Advanced Save
Options on the menu. To change your settings (for example to General), open Tools / Impor t and Expor t Settings . For
more information, see Customizing Development Settings in Visual Studio.

In Visual Studio the following characters are interpreted as line breaks:


CRLF: Carriage return + line feed, Unicode characters 000D + 000A
LF: Line feed, Unicode character 000A
NEL: Next line, Unicode character 0085
LS: Line separator, Unicode character 2028
PS: Paragraph separator, Unicode character 2029
Text that is copied from other applications keeps the original encoding and line break characters. For
example, when you copy text from Notepad and paste it into a text file in Visual Studio, the text has the same
settings that it had in Notepad.
When you open a file that has a different line break characters, you may see a dialog box that asks whether
the inconsistent line break characters should be normalized and which type of line breaks to choose.
Outlining
10/16/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can choose to hide some code from view by collapsing a region of code so that it appears under a plus sign
(+). You expand a collapsed region by clicking the plus sign. (Or you can press CTRL + M + M to collapse a region
and then CTRL+ M + M to expand it again.) You can also collapse an outlining region by double-clicking any line in
the region on the outlining margin, which appears just to the left of the code. You can see the contents of a
collapsed region as a tooltip when you hover over the collapsed region.
Regions in the outlining margin are also highlighted when you hover over the margin with the mouse. The default
highlighting color may seem rather faint in some color configurations. You can change it in
Tools/Options/Environment/Fonts and Colors/Collapsible Region .
When you work in outlined code, you can expand the sections you want to work on, collapse them when you are
done, and then move to other sections. When you do not wish to have outlining displayed, you can use the Stop
Outlining command to remove the outline information without disturbing your underlying code.
The Undo and Redo commands on the Edit menu affect these actions. The Copy , Cut , Paste , and drag-and-drop
operations retain outlining information, but not the state of the collapsible region. For example, when you copy a
region that is collapsed, the Paste operation will paste the copied text as an expanded region.
Cau t i on

When you change an outlined region, the outlining may be lost. For example, deletions or Find and Replace
operations may erase the end of the region.
The following commands can be found on the Edit/Outlining submenu.

C OMMAND DESC RIP T IO N

Hide Selection (CTRL + M , CTRL + H) - Collapses a selected block of code


that would not normally be available for outlining, for example
an if block. To remove the custom region, use Stop
Hiding Current (or CTRL + M, CTRL + U). Not available in
Visual Basic.

Toggle Outlining Expansion - Reverses the current hidden or expanded state of the
innermost outlining section when the cursor lies in a nested
collapsed section.

Toggle All Outlining (CTRL + M, CTRL + L) - Sets all regions to the same collapsed
or expanded state. If some regions are expanded and some
collapsed, then the collapsed regions are expanded.

Stop Outlining (CTRL + M, CTRL + P) - Removes all outlining information for


the entire document.
C OMMAND DESC RIP T IO N

Stop Hiding Current (CTRL + M, CTRL + U) - Removes the outlining information


for the currently selected user-defined region. Not available in
Visual Basic.

Collapse to Definitions (CTRL + M, CTRL + O) - Collapses the members of all types.

Collapse Block:<logical boundary> (Visual C++) Collapses a region in the function containing the
insertion point. For example, if the insertion point lies inside a
loop, the loop is hidden.

Collapse All in: <logical structures> (Visual C++) Collapses all the structures inside the function.

You can also use the Visual Studio SDK to define the text regions you want to expand or collapse. See Walkthrough:
Outlining.
Refactoring in Visual Studio
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Refactoring is the process of modifying code in order to make it easier to maintain, understand, and extend, but
without changing its behavior. Some common refactorings include:
1. splitting long functions into smaller ones
2. renaming variables, types, functions or parameters
3. reordering parameters
4. removing or reordering using directives
Because the logic of refactoring is closely tied to language syntax, each language service in Visual Studio
provides its own refactoring capabilities. For more information, see the following pages:
Refactoring in C#
Refactoring (C#)
Refactoring in Visual Basic
Refactoring and Rename Dialog Box (Visual Basic)
Refactoring in C++
Writing and refactoring code (C++)
Refactoring in F#
Refactoring support for F# is provided in Visual F# Power Tools, a third-party Visual Studio extension.

See Also
Visual Studio IDE Writing Code in the Code and Text Editor
Productivity Tips for Visual Studio
10/18/2019 • 8 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

By following these tips, you can more quickly and efficiently write, navigate, and debug your code in Visual Studio.
For more information about common keyboard shortcuts, see Tips and Tricks. For a more complete list, see
Identifying and Customizing Keyboard Shortcuts and Default Keyboard Shortcuts.
This topic includes the following sections:
Accessing Visual Studio Tools
Writing Code
Navigating Within Your Code
Finding Items Faster
Debugging Code
Managing Files, Toolbars, and Windows

Accessing Visual Studio Tools


You can more easily access the Developer Command Prompt or another tool if you pin it to the Start screen or the
taskbar.
1. From the Start screen, enter Visual Studio Tools , and then choose the Enter key.
2. In File Explorer , open the shortcut menu for the item that you want:
Build Notifications
Debuggable Package Manager
Developer Command Prompt for VS2013
Microsoft Feedback Client 2013
VS2013 ARM Cross Tools Command Prompt
VS2013 x64 Cross Tools Command Prompt
VS2013 x64 Native Tools Command Prompt
VS2013 x86 Native Tools Command Prompt
3. Choose Pin to Star t or Pin to Taskbar .

Writing Code
Write code more quickly by using the following features.
Use sample applications . You can speed up application development by downloading and installing
sample applications from the MSDN Code Gallery. You can also learn a particular technology or
programming concept by downloading and exploring a Sample Pack for that area.
Use IntelliSense . As you enter code in the editor, IntelliSense information, such as List Members,
Parameter Info, Quick Info, Signature Help, and Complete Word, appears. These features support fuzzy
matching of text; for example, the results lists for List Members includes not only entries that start with the
characters that you have entered but also entries that contain the character combination anywhere in their
names. For more information, see Using IntelliSense.
Change auto-inser tion of IntelliSense options as you enter code . By switching IntelliSense to
suggestion mode, you can specify that IntelliSense options are inserted only if you explicitly choose them.
To enable suggestion mode, choose the Ctrl + Alt + Spacebar keys, or, on the menu bar, choose Edit ,
IntelliSense , Toggle Completion Mode .
Use code snippets . You can use built-in snippets or create your own snippets.
To insert a snippet, on the menu bar, choose Edit , IntelliSense , Inser t Snippet or open the shortcut menu
in a file and choose Inser t Snippet . For more information, see Code Snippets.
Fix code errors inline . Smart Tags appear as blue or red boxes under a line of code. You can display
Smart Tag options by pointing to one of the boxes or by placing the cursor in the line of code and choosing
the Ctrl + . (period) keys.
Blue boxes suggest ways to fix errors in your code.
Figure 1: Error Smart Tags

Red boxes suggest ways to refactor your code.


Figure 2: Refactoring Smart Tags
Show and edit the definition of a code element . You can quickly show and edit the module in which a
code element, such as a member, a variable, or a local, is defined.
To open a definition in a pop-up window, highlight the element and then choose the Alt+F12 keys, or open
the shortcut menu for the element and then choose Peek Definition . To open a definition in a separate
code window, open the shortcut menu for the element, and then choose Go to Definition .

Navigating Within Your Code


You can use various techniques to find and move to specific locations in your code more quickly.
Bookmark lines of code . You can use bookmarks to navigate quickly to specific lines of code in a file.
To set a bookmark, on the menu bar, choose Edit , Bookmarks , Toggle Bookmark . You can view all of the
bookmarks for a solution in the Bookmarks window. For more information, see Setting Bookmarks in
Code.
Search for symbol definitions in a file . You can search within a solution to locate symbol definitions
and file names, but search results don’t include namespaces or local variables.
To access this feature, on the menu bar, choose Edit , Navigate To .
Browse the overall structure of your code . In Solution Explorer , you can search and browse classes
and their types and members in your projects. You can also search for symbols, view a method’s Call
Hierarchy, find symbol references, and perform other tasks. If you choose a code element in Solution
Explorer , the associated file opens in a Preview tab, and the cursor moves to the element in the file. For
more information, see Viewing the Structure of Code.

Finding Items Faster


You can search across the IDE for commands, files, and options, in addition to filtering the contents of tool
windows to show only relevant information for your current task.
Filter the contents of tool windows . You can search within the contents of many tool windows, such as
the Toolbox , the Proper ties window, and Solution Explorer , but display only items whose names
contain the characters that you specify.
Display only the errors you want to address . If you choose the Filter button on the Error List
toolbar, you can reduce the number of errors that appear in the Error List window. You can display only the
errors in the files that are open in the editor, only the errors in the current file, or only the errors in the
current project. You can also search within the Error List window to find specific errors.
Find dialog boxes, menu commands, and options . In the Quick Launch, Environment, Options Dialog
Box box, enter keywords or phrases for the items that you’re trying to find. For example, the following
options appear if you enter new project :
Figure 3: Quick Launch results list for new project
Quick Launch displays links to the New Project dialog box, the Add New Item dialog box, and the
Projects and Solutions page in the Options dialog box, among others. Quick Launch results can also
include project files and tool windows.

Debugging Code
Debugging can consume a lot of time, but the following tips can help you speed up the process.
Test the same page, application, or site in different browsers . As you debug your code, you can
easily switch among the installed web browsers, including Page Inspector (Visual Studio), without having to
open the Browse With dialog box. You can use the Debug Target list, which is on the Standard toolbar
next to the Star t Debugging button, to quickly verify which browser you’re using as you debug or view
pages.

Set temporar y breakpoints . You can create a temporary breakpoint in the current line of code and start
the debugger simultaneously. When you hit that line of code, the debugger enters break mode. For more
information, see Navigating through Code with the Debugger.
To use this feature, choose the Ctrl + F10 keys, or open the shortcut menu for the line of code on which you
want to break, and then choose Run To Cursor .
Move the execution point during debugging . You can move the current execution point to a different
section of code and then restart debugging from that point. This technique is useful if you want to debug a
section of code without having to recreate all of the steps that are required to reach that section. For more
information, see Navigating through Code with the Debugger.
To move the execution point, drag the yellow arrowhead to a location where you want to set the next
statement in the same source file, and then choose the F5 key to continue debugging.
Capture value information for variables . You can add a DataTip to a variable in your code and pin it so
that you can access the last known value for the variable after debugging has finished. For more
information, see View data values in Data Tips.
To add a DataTip, the debugger must be in break mode. Place the cursor on the variable, and then choose
the pin button on the DataTip that appears. When debugging is stopped, a blue pin icon appears in the
source file next to the line of code that contains the variable. If you point to the blue pin, the value of the
variable from the most recent debugging session appears.
Clear the Immediate window . You can erase the contents of the Immediate Window at design time by
entering >cls or >Edit.ClearAll
For more information about additional commands, see Visual Studio Command Aliases.

Managing Files, Toolbars, and Windows


At any one time, you may be working in multiple code files and moving among several tool windows as you
develop an application. You can keep organized by using the following tips.
Keep files that you frequently use visible in the editor . You can pin files to the left side of the tab
well so that they remain visible regardless of how many files are open in the editor.
To pin a file, choose the file’s tab, and then choose the Toggle Pin Status button.
Move documents and windows to other monitors . If you use more than one monitor when you
develop applications, you can work on portions of your application more easily by moving files that are
open in the editor to another monitor. You can also move tool windows, such as debugger windows, to
another monitor and tab dock document and tool windows together to create “rafts.” For more information,
see How to: Arrange and Dock Windows.
You can also manage files more easily by creating another instance of Solution Explorer and moving it to
another monitor. To create another instance of Solution Explorer , open a shortcut menu in Solution
Explorer , and then choose New Solution Explorer View .
Customize the fonts that appear in Visual Studio . You can change the font face, size, and color that’s
used for text in the IDE. For example, you can customize the color of specific code elements in the editor and
the font face in tool windows or throughout the IDE. For more information, see How to: Change Fonts and
Colors and How to: Change Fonts and Colors in the Editor.

See Also
Default Keyboard Shortcuts for Frequently Used Commands How to: Customize Menus and Toolbars Walkthrough:
Create a Simple Application Accessibility Tips and Tricks
Tips and Tricks for Visual Studio
10/16/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can navigate in Visual Studio more easily by using the shortcuts in this topic. For more general information,
see Keyboard Shortcuts in Visual Studio. For information about how to optimize Visual Studio for accessibility, see
Accessibility Tips and Tricks.
Window Management
Window Shortcuts
Visual Studio Search
Editor Find
Code Editor
Toolbars
Debugging
Application Lifecycle Management

Window Management
C OMMAND SH O RTC UT

Drag Off Floating Tab Wells Ctrl+click for multi-select

Maximize Floating Window Double-click on title bar

Re-dock Floating Window Ctrl+double-click title bar

Close Active Document Ctrl+F4

Show Open File List Ctrl+Alt+Down

Show All Floating Windows Ctrl+Shift+M

Window Shortcuts
C OMMAND SH O RTC UT

Move/Dock Floating Windows Win+Left / Win+Right

Maximize/Minimize Windows Win+Up / Win+Down


C OMMAND SH O RTC UT

Show Jump List Win+Alt+n

Start New Instance Win+Shift+n

Switch Between Windows Win+n

Visual Studio Search


C OMMAND SH O RTC UT

Solution Explorer Search Ctrl+;

Place Focus in Search box in any tool window Alt+` when the tool window has focus

Quick Launch Ctrl+Q

Quick Launch Scope Results - @opt Options


- @cmd Commands
- @mru Most recently used
- @doc Open documents

Search in Tools Options Ctrl+E

Editor Find
C OMMAND SH O RTC UT

Quick Find Ctrl+F

Quick Find Next Result Enter

Quick Find Previous Result Shift+Enter

Quick Find Expand Drop Down Alt+Down

Dismiss Find Esc

Quick Replace Ctrl+H

Quick Replace Replace Next Alt+R

Quick Replace Replace All Alt+A

Find in Files Ctrl+Shift+F

Replace in Files Ctrl+Shift+H


Code Editor
C OMMAND SH O RTC UT

IntelliSense Suggestion Mode Ctrl+Alt+Space (Toggle)

Force Show IntelliSense Ctrl+J

Smart Tags Ctrl+.

Snippet Picker Ctrl+K,X or ?,Tab (VB)

Surround With Ctrl+K,S

Show Quick Info Ctrl+K,I

Navigate To Ctrl+,

Go To Definition F12

Peek Definition Alt+F12

Go To Definition Stack Ctrl+Shift+8 (Back), Ctrl+Shift+7 (Forward)

Navigate Highlighted References Ctrl+Shift+Up (Previous), Ctrl+Shift+Down (Next)

Editor Zoom Ctrl+Shift+> (In), Ctrl+Shift+< (Out)

Block Selection Hold Alt and drag mouse, Shift+Alt+Arrow Keys

Move Line Up/Down Alt+Up / Alt+Down

Peek Definition Alt+F12

Close the Peek Definition window Esc

Promote the Peek Definition window to a regular document Ctrl+Alt+Home


tab

Navigate between multiple Peek Definition windows Ctrl+Alt+- and Ctrl+Alt+=

Navigate between multiple Peek results F8 and Shift+F8

Toggle between the code editor window and the Peek Shift+Esc
Definition window

Toolbars
C OMMAND SH O RTC UT

Add Buttons Click toolbar overflow button


C OMMAND SH O RTC UT

Find Combo in Standard toolbar Ctrl+D

Find Textbox Command Mode Type “>”

Create new alias >alias NewAlias Command

Debugging
C OMMAND SH O RTC UT

Start Debugging F5

Stop Debugging Shift+F5

Restart Debugging Ctrl+Shift+F5

Step Over F10

Step Into F11

Step Out Shift+F11

Run To Cursor Ctrl+F10

Set Next Statement Ctrl+Shift+F10

Set and Toggle Breakpoint F9

Disable Breakpoint Ctrl+F9

Immediate Window Ctrl+Alt+I

Immediate Window Command Mode Type “>”

Immediate Window Clear Buffer >cls

Immediate Window Print Value ?varname

Application Lifecycle Management


See Keyboard shortcuts: Visual Studio Online, TFS web portal, and Team Explorer.

See Also
Visual Studio Blog
Visual Studio Tips and Tricks Blog
Visual Studio Toolbox on Channel 9
Identifying and Customizing Keyboard Shortcuts in
Visual Studio
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can identify keyboard shortcuts for Visual Studio commands, customize those shortcuts, and export them for
others to use. Many shortcuts always invoke the same commands, but the behavior of a shortcut can vary based
on the following conditions:
Which default environment settings you chose the first time that you ran Visual Studio (for example,
General Development or Visual C#).
Whether you've customized the shortcut's behavior.
Which context you're in when you choose the shortcut. For example, the F2 shortcut invokes the
Edit.EditCell command if you're using the Settings Designer and the File.Rename command if you're using
Team Explorer.
Regardless of settings, customization, and context, you can always find and change a keyboard shortcut in
the Options dialog box. You can also look up the default keyboard shortcuts for several dozen commands
in Default Keyboard Shortcuts for Frequently Used Commands, and you can find a complete list of all
default shortcuts (based on the General Development Settings) in Default Keyboard Shortcuts.
In this topic
Identifying a keyboard shortcut
Customizing a keyboard shortcut
Sharing custom keyboard shortcuts
If a shortcut is assigned to a command in the Global context and no other contexts, that shortcut will
always invoke that command. But a shortcut can be assigned to one command in the Global context and a
different command in a specific context. If you use such a shortcut when you're in the specific context, the
shortcut invokes the command for the specific context, not the Global context.

NOTE
Your settings and edition of Visual Studio might change the names and locations of menu commands and the options that
appear in dialog boxes. This topic is based on the General Development Settings .

Identifying a keyboard shortcut


1. On the menu bar, choose Tools , Options .
2. Expand Environment , and then choose Keyboard .
3. In the Show commands containing box, enter all or part of the name of the command without spaces.
For example, you can find commands for solutionexplorer .
4. In the list, choose the correct command.
For example, you can choose View.SolutionExplorer .
5. If the command has a keyboard shortcut, it appears in the Shor tcut(s) for selected command list.

Customizing a keyboard shortcut


1. On the menu bar, choose Tools , Options .
2. Expand the Environment folder, and then choose Keyboard .
3. In the Show commands containing box, enter all or part of the name of the command without spaces.
For example, you can find commands for solutionexplorer .
4. In the list, choose the command to which you want to assign a keyboard shortcut.
5. In the Use new shor tcut in list, choose the feature area in which you want to use the shortcut.
For example, you can choose Global if you want the shortcut to work in all contexts. You can use any
shortcut that isn't mapped (as Global) in another editor. Otherwise, the editor overrides the shortcut.

NOTE
You can't assign the following keys as part of a keyboard shortcut in Global: Print Scrn/Sys Rq, Scroll Lock,
Pause/Break, Tab, Caps Lock, Insert, Home, End, Page Up, Page Down, the Windows logo key, the Application key,
any of the Arrow keys, or Enter; Num Lock, Delete, or Clear on the numeric keypad; or Ctrl+Alt+Delete.

6. In the Press shor tcut key(s) box, enter the shortcut that you want to use.

NOTE
You can create a shortcut that combines a letter with the Alt key, the Ctrl key, or both. You can also create a
shortcut that combines the Shift key and a letter with the Alt key, the Ctrl key, or both.

If a shortcut is already assigned to another command, it appears in the Shor tcut currently used by box.
In that case, choose the Backspace key to delete that shortcut before you try a different one.

7. Choose the Assign button.

NOTE
If you specify a different shortcut for a command, choose the Assign button, and then choose the Cancel button,
the dialog box closes, but the change isn't reverted.

Sharing custom keyboard shortcuts


You can share your custom keyboard shortcuts by exporting them to a file and then giving the file to others so
that they can import the data.
To export only keyboard shortcuts
1. On the menu bar, choose Tools , Impor t and Expor t Settings .
2. Choose Expor t selected environment settings , and then choose the Next button.
3. Under What settings do you want to expor t? , clear the All Settings check box, expand Options , and
then expand Environment .
4. Select the Keyboard check box, and then choose the Next button.
5. In the What do you want to name your settings file? and Store my settings file in this director y
boxes, either leave the default values or specify different values, and then choose the Finish button.
By default, your shortcuts are saved in a file in the %USERPROFILE%\Documents\Visual Studio
2013\Settings folder. The name of the file reflects the date when you exported the settings, and the
extension is .vssettings.
To import only keyboard shortcuts
1. On the menu bar, choose Tools , Impor t and Expor t Settings .
2. Choose the Impor t selected environment settings option button, and then choose the Next button.
3. Choose the No, just impor t new settings, over writing my current settings option button, and then
choose the Next button.
4. Under My Settings , choose the file that contains the shortcuts that you want to import, or choose the
Browse button to locate the correct file.
5. Choose the Next button.
6. Under Which settings do you want to impor t? , clear the All Settings check box, expand Options ,
and then expand Environment .
7. Select the Keyboard check box, and then choose the Finish button.

See Also
Accessibility Features of Visual Studio
Default Keyboard Shortcuts for Frequently Used
Commands in Visual Studio
10/16/2020 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can access frequently used commands in Visual Studio by choosing these default keyboard shortcuts. For a
complete list of commands that have default shortcuts, see Default Keyboard Shortcuts.

NOTE
You can look up the shortcut for any command by opening the Options dialog box, expanding the Environment node,
and then choosing Keyboard .

In this topic
Build
Edit
Project
Tools
Window
Debug
File
Refactor
View||

Build
C O M M A N DS K EY B O A RD SH O RTC UT S [ C O N T EXT S]

Build.BuildSolution Ctrl+Shift+B [Global]

Build.Cancel Ctrl+Break [Global]

Build.Compile Ctrl+F7 [Global]

Build.RunCodeAnalysisonSolution Alt+F11 [Global]

Debug
C O M M A N DS K EY B O A RD SH O RTC UT S [ C O N T EXT S]

Debug.BreakatFunction Ctrl+B [Global]

Debug.BreakAll Ctrl+Alt+Break [Global]

Debug.DeleteAllBreakpoints Ctrl+Shift+F9 [Global]

Debug.Exceptions Ctrl+Alt+E [Global]

Debug.QuickWatch Ctrl+Alt+Q [Global]

or Shift+F9 [Global]

Debug.Restart Ctrl+Shift+F5 [Global]

Debug.RunToCursor Ctrl+F10 [Global]

Debug.SetNextStatement Ctrl+Shift+F10 [Global]

Debug.Start F5 [Global]

Debug.StartWithoutDebugging Ctrl+F5 [Global]

Debug.StepInto F11 [Global]

Debug.StepOut Shift+F11 [Global]

Debug.StepOver F10 [Global]

Debug.StopDebugging Shift+F5 [Global]

Debug.ToggleBreakpoint F9 [Global]

Edit
C O M M A N DS K EY B O A RD SH O RTC UT S [ C O N T EXT S]

Edit.BreakLine Enter [Text Editor, Report Designer, Windows Forms Designer]

or Shift+Enter [Text Editor]

Edit.CollapsetoDefinitions Ctrl+M, Ctrl+O [Text Editor]

Edit.CommentSelection Ctrl+K, Ctrl+C [Text Editor]

Edit.CompleteWord Alt+Right Arrow [Text Editor, Workflow Designer]

or Ctrl+Spacebar [Text Editor, Workflow Designer]

or Ctrl+K, W [Workflow Designer]

or Ctrl+K, Ctrl+W [Workflow Designer]


C O M M A N DS K EY B O A RD SH O RTC UT S [ C O N T EXT S]

Edit.Copy Ctrl+C [Global]

or Ctrl+Insert [Global]

Edit.Cut Ctrl+X [Global]

or Shift+Delete [Global]

Edit.Delete Delete [Global, Team Explorer]

or Shift+Delete [Sequence Diagram, UML Activity Diagram,


Layer Diagram]

or Ctrl+Delete [Class Diagram]

Edit.Find Ctrl+F [Global]

Edit.FindAllReferences Shift+F12 [Global]

dit.FindinFiles Ctrl+Shift+F [Global]

Edit.FindNext F3 [Global]

Edit.FindNextSelected Ctrl+F3 [Global]

Edit.FormatDocument Ctrl+K, Ctrl+D [Text Editor]

Edit.FormatSelection Ctrl+K, Ctrl+F [Text Editor]

Edit.GoTo Ctrl+G [Global]

Edit.GoToDeclaration Ctrl+F12 [Global]

Edit.GoToDefinition F12

Edit.GoToFindCombo Ctrl+D [Global]

Edit.GoToNextLocation F8 [Global]

Edit.InsertSnippet Ctrl+K, Ctrl+X [Global]

Edit.InsertTab Tab [Report Designer, Windows Forms Designer, Text Editor]

Edit.LineCut Ctrl+L [Text Editor]

Edit.LineDownExtendColumn Shift+Alt+Down Arrow [Text Editor]

Edit.LineOpenAbove Ctrl+Enter [Text Editor]


C O M M A N DS K EY B O A RD SH O RTC UT S [ C O N T EXT S]

Edit.ListMembers Ctrl+J [Text Editor, Workflow Designer]

or Ctrl+K, Ctrl+L [Workflow Designer]

or Ctrl+K, L [Workflow Designer]

dit.NavigateTo Ctrl+, [Global]

Edit.OpenFile Ctrl+Shift+G [Global]

Edit.OvertypeMode Insert [Text Editor]

Edit.ParameterInfo Ctrl+Shift+Spacebar [Text Editor, Workflow Designer]

or Ctrl+K, Ctrl+P [Workflow Designer]

or Ctrl+K, P [Workflow Designer]

Edit.Paste Ctrl+V [Global]

or Shift+Insert [Global]

Edit.PeekDefinition Alt+F12 [Text Editor]

Edit.Redo Ctrl+Y [Global]

or Shift+Alt+Backspace [Global]

or Ctrl+Shift+Z [Global]

Edit.Replace Ctrl+H [Global]

Edit.SelectAll Ctrl+A [Global]

Edit.SelectCurrentWord Ctrl+W [Text Editor]

Edit.SelectionCancel Esc [Text Editor, Report Designer, Settings Designer, Windows


Forms Designer, Managed Resources Editor]

dit.SurroundWith Ctrl+K, Ctrl+S [Global]

Edit.TabLeft Shift+Tab [Text Editor, Report Designer, Windows Forms Editor]

Edit.ToggleAllOutlining Ctrl+M, Ctrl+L [Text Editor]

Edit.ToggleBookmark Ctrl+K, Ctrl+K [Text Editor]

Edit.ToggleCompletionMode Ctrl+Alt+Space [Text Editor]

Edit.ToggleOutliningExpansion Ctrl+M, Ctrl+M [Text Editor]

Edit.UncommentSelection Ctrl+K, Ctrl+U [Text Editor]


C O M M A N DS K EY B O A RD SH O RTC UT S [ C O N T EXT S]

Edit.Undo Ctrl+Z [Global]

or Alt+Backspace [Global]

Edit.WordDeleteToEnd Ctrl+Delete [Text Editor]

Edit.WordDeleteToStart Ctrl+Backspace [Text Editor]

File
C O M M A N DS K EY B O A RD SH O RTC UT S [ C O N T EXT S]

File.Exit Alt+F4 [Global]

File.NewFile Ctrl+N [Global]

File.NewProject Ctrl+Shift+N [Global]

File.NewWebSite Shift+Alt+N [Global]

File.OpenFile Ctrl+O [Global]

File.OpenProject Ctrl+Shift+O [Global]

File.OpenWebSite Shift+Alt+O [Global]

File.Rename F2 [Team Explorer]

File.SaveAll Ctrl+Shift+S [Global]

File.SaveSelectedItems Ctrl+S [Global]

File.ViewinBrowser Ctrl+Shift+W [Global]

Project
C O M M A N DS K EY B O A RD SH O RTC UT S [ C O N T EXT S]

Project.AddExistingItem Shift+Alt+A [Global]

Project.AddNewItem Ctrl+Shift+A [Global]

Refactor
C OMMAND K EY B O A RD SH O RTC UT [ C O N T EXT ]

Refactor.ExtractMethod Ctrl+R, Ctrl+M [Global]


Tools
C OMMAND K EY B O A RD SH O RTC UT [ C O N T EXT ]

Tools.AttachtoProcess Ctrl+Alt+P [Global]

View
C O M M A N DS K EY B O A RD SH O RTC UT S [ C O N T EXT S]

View.ClassView Ctrl+Shift+C [Global]

View.EditLabel F2 [Global]

View.ErrorList Ctrl+\, Ctrl+E [Global]

or Ctrl+\, E [Global]

View.NavigateBackward Ctrl+- [Global]

View.NavigateForward Ctrl+Shift+- [Global]

View.ObjectBrowser Ctrl+Alt+J [Global]

View.Output Ctrl+Alt+O [Global]

View.PropertiesWindow F4

View.Refresh F5 [Team Explorer, Team Foundation Build Detail Editor]

View.ServerExplorer Ctrl+Alt+S [Global]

View.ShowSmartTag Ctrl+. [Global]

or Shift+Alt+F10 [Global, HTML Editor Design View]

View.SolutionExplorer Ctrl+Alt+L [Global]

iew.TfsTeamExplorer Ctrl+\, Ctrl+M [Global]

View.Toolbox Ctrl+Alt+X [Global]

View.ViewCode Enter [Class Diagram]

or F7 [Settings Designer]

View.ViewDesigner Shift+F7 [HTML Editor Source View]

Window
C O M M A N DS K EY B O A RD SH O RTC UT S [ C O N T EXT S]

Window.ActivateDocumentWindow Esc [Global]

Window.CloseDocumentWindow Ctrl+F4 [Global]

Window.NextDocumentWindow Ctrl+F6 [Global]

Window.NextDocumentWindowNav Ctrl+Tab [Global]

Window.NextSplitPane F6 [Global]
Default Keyboard Shortcuts in Visual Studio
10/16/2020 • 13 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can more easily access a variety of commands and windows in Visual Studio by choosing the appropriate
keyboard shortcut. This topics lists the default shortcuts for the General Development profile, which you might
have chosen when you installed Visual Studio. No matter which profile you chose, you can identify the shortcut
for a command by opening the Options dialog box, expanding the Environment node, and then choosing
Keyboard . You can also customize your shortcuts by assigning a different shortcut to any given command.
For a list of common keyboard shortcuts and other productivity information, see Tips and Tricks and Productivity
Tips.
The sections in the following list include commands that are global in that you can access them from anywhere in
Visual Studio by using keyboard shortcuts:
Analyze
Edit
Project
Test|
Architecture
Editor Context Menus
Project and Solution Context Menus
Test Explorer
Build
File
Refactor
Tools
Class View Context Menus
Help
Solution Explorer
View
Debug
Load Test
Team
Window
Debugger Context Menus
Other Context Menus
Team Foundation Context Menus
Azure
Diagnostics Hub
Each section in the following list includes commands for which the keyboard shortcuts are specific to the context
for which the section is named.
ADO.NET Entity Data Model Designer
Layer Diagram
Settings Designer
VC Image Editor
Class Diagram
Managed Resources Editor
Solution Explorer
VC String Editor
Coded UI Test Editor
Merge Editor Window
Team Explorer
View Designer
DataSet Editor
Microsoft SQL Server Data Tools, Schema Compare
Team Foundation Build Detail Editor
Visual Studio
Difference Viewer
Microsoft SQL Server Data Tools, Table Designer
Test Explorer
Windows Forms Designer
DOM Explorer
Microsoft SQL Server Data Tools, T-SQL Editor
Text Editor
Work Item Editor
F# Interactive
Microsoft SQL Server Data Tools, T-SQL PDW Editor
UML Activity Diagram
Work Item Query View
Graph Document Editor
Page Inspector
UML Class Diagram
Work Item Results View
Graphics Diagnostics
Query Designer
UML Component Diagram
Workflow Designer
HTML Editor
Query Results
UML Use Case Diagram
XAML UI Designer
HTML Editor Design View
Report Designer
VC Accelerator Editor
XML (Text) Editor
HTML Editor Source View
Sequence Diagram
VC Dialog Editor
XML Schema Designer

Global
Analyze
C O M M A N DS K EY B O A RD SH O RTC UT S

Analyze.NavigateBackward Shift+Alt+3

Analyze.NavigateForward Shift+Alt+4

Architecture
C O M M A N DS K EY B O A RD SH O RTC UT S

Architecture.NewDiagram Ctrl+\, Ctrl+N

Build
C O M M A N DS K EY B O A RD SH O RTC UT S

Build.BuildSolution Ctrl+Shift+B

Build.Cancel Ctrl+Break

Build.Compile Ctrl+F7

Build.RunCodeAnalysisonSolution Alt+F11

Class View Context Menus


C O M M A N DS K EY B O A RD SH O RTC UT S

ClassViewContextMenus.ClassViewMultiselectProjectreferenc Alt+Enter
esItems.Properties

Debug
C O M M A N DS K EY B O A RD SH O RTC UT S

Debug.ApplyCodeChanges Alt+F10

Debug.Autos Ctrl+Alt+V, A

Debug.BreakAll Ctrl+Alt+Break

Debug.BreakatFunction Ctrl+B

Debug.Breakpoints Ctrl+Alt+B

Debug.CallStack Ctrl+Alt+C
C O M M A N DS K EY B O A RD SH O RTC UT S

Debug.DeleteAllBreakpoints Ctrl+Shift+F9

Debug.DiagnosticsHub.Launch Alt+F2

Debug.Disassembly Ctrl+Alt+D

Debug.DOMExplorer Ctrl+Alt+V, D

Debug.EnableBreakpoint Ctrl+F9

Debug.Exceptions Ctrl+Alt+E

Debug.GoToPreviousCallorIntelliTraceEvent Ctrl+Shift+F11

Debug.Graphics.StartDiagnostics Alt+F5

Debug.Immediate Ctrl+Alt+I

Debug.IntelliTraceCalls Ctrl+Alt+Y, T

Debug.IntelliTraceEvents Ctrl+Alt+Y, F

Debug.JavaScriptConsole Ctrl+Alt+V, C

Debug.Locals Ctrl+Alt+V, L

Debug.LocationToolbar.ProcessCombo Ctrl+5

Debug.LocationToolbar.StackFrameCombo Ctrl+7

Debug.LocationToolbar.ThreadCombo Ctrl+6

Debug.LocationToolbar.ToggleCurrentThreadFlaggedState Ctrl+8

Debug.LocationToolbar.ToggleFlaggedThreads Ctrl+9

Debug.Memory1 Ctrl+Alt+M, 1

Debug.Memory2 Ctrl+Alt+M, 2

Debug.Memory3 Ctrl+Alt+M, 3

Debug.Memory4 Ctrl+Alt+M, 4

Debug.Modules Ctrl+Alt+U

Debug.ParallelStacks Ctrl+Shift+D, S

Debug.ParallelWatch1 Ctrl+Shift+D, 1
C O M M A N DS K EY B O A RD SH O RTC UT S

Debug.ParallelWatch2 Ctrl+Shift+D, 2

Debug.ParallelWatch3 Ctrl+Shift+D, 3

Debug.ParallelWatch4 Ctrl+Shift+D, 4

Debug.Processes Ctrl+Alt+Z

Debug.QuickWatch Shift+F9

or

Ctrl+Alt+Q

Debug.RefreshWindowsapp Ctrl+Shift+R

Debug.Registers Ctrl+Alt+G

Debug.Restart Ctrl+Shift+F5

Debug.RunToCursor Ctrl+F10

Debug.SetNextStatement Ctrl+Shift+F10

Debug.ShowCallStackonCodeMap Ctrl+Shift+`

Debug.ShowNextStatement Alt+Num *

Debug.Start F5

Debug.StartWindowsPhoneApplicationAnalysis Alt+F1

Debug.StartWithoutDebugging Ctrl+F5

Debug.StepInto F11

Debug.StepIntoCurrentProcess Ctrl+Alt+F11

Debug.StepIntoSpecific Shift+Alt+F11

Debug.StepOut Shift+F11

Debug.StepOutCurrentProcess Ctrl+Shift+Alt+F11

Debug.StepOver F10

Debug.StepOverCurrentProcess Ctrl+Alt+F10

Debug.StopDebugging Shift+F5

Debug.StopPerformanceAnalysis Shift+Alt+F2
C O M M A N DS K EY B O A RD SH O RTC UT S

Debug.Tasks Ctrl+Shift+D, K

Debug.Threads Ctrl+Alt+H

Debug.ToggleBreakpoint F9

Debug.ToggleDisassembly Ctrl+F11

Debug.Watch1 Ctrl+Alt+W, 1

Debug.Watch2 Ctrl+Alt+W, 2

Debug.Watch3 Ctrl+Alt+W, 3

Debug.Watch4 Ctrl+Alt+W, 4

Debugger Context Menus


C O M M A N DS K EY B O A RD SH O RTC UT S

DebuggerContextMenus.BreakpointsWindow.Delete Alt+F9, D

DebuggerContextMenus.BreakpointsWindow.GoToDisassemb Alt+F9, A
ly

DebuggerContextMenus.BreakpointsWindow.GoToSourceCod Alt+F9, S
e

Diagnostics Hub
C OMMAND K EY B O A RD SH O RTC UT

DiagnosticsHub.StopCollection Ctrl+Alt+F2

Edit
C O M M A N DS

Edit.Copy Ctrl+C

or

Ctrl+Ins

Edit.Cut Ctrl+X

or

Shift+Delete
C O M M A N DS

Edit.CycleClipboardRing Ctrl+Shift+V

or

Ctrl+Shift+Ins

Edit.Delete Delete

Edit.Find Ctrl+F

Edit.FindAllReferences Shift+F12

Edit.FindinFiles Ctrl+Shift+F

Edit.FindNext F3

Edit.FindNextSelected Ctrl+F3

Edit.FindPrevious Shift+F3

Edit.FindPreviousSelected Ctrl+Shift+F3

Edit.GenerateMethod Ctrl+K, Ctrl+M

Edit.GoTo Ctrl+G

Edit.GoToDeclaration Ctrl+F12

Edit.GoToDefinition F12

Edit.GoToFindCombo Ctrl+D

Edit.GoToNextLocation F8

Edit.GoToPrevLocation Shift+F8

Edit.InsertSnippet Ctrl+K, Ctrl+X

Edit.MoveControlDown Ctrl+Down Arrow

Edit.MoveControlDownGrid Down Arrow

Edit.MoveControlLeft Ctrl+Left Arrow

Edit.MoveControlLeftGrid Left Arrow

Edit.MoveControlRight Ctrl+Right Arrow

Edit.MoveControlRightGrid Right Arrow

Edit.MoveControlUp Ctrl+Up Arrow


C O M M A N DS

Edit.MoveControlUpGrid Up Arrow

Edit.NavigateTo Ctrl+,

Edit.NextBookmark Ctrl+K, Ctrl+N

Edit.NextBookmarkInFolder Ctrl+Shift+K, Ctrl+Shift+N

Edit.OpenFile Ctrl+Shift+G

Edit.Paste Ctrl+V

or

Shift+Ins

Edit.PreviousBookmark Ctrl+K, Ctrl+P

Edit.PreviousBookmarkInFolder Ctrl+Shift+K, Ctrl+Shift+P

Edit.QuickFindSymbol Shift+Alt+F12

Edit.Redo Ctrl+Y

or

Ctrl+Shift+Z

or

Shift+Alt+Backspace

Edit.RefreshRemoteReferences Ctrl+Shift+J

Edit.Replace Ctrl+H

Edit.ReplaceinFiles Ctrl+Shift+H

Edit.SelectAll Ctrl+A

Edit.SelectNextControl Tab

Edit.SelectPreviousControl Shift+Tab

Edit.ShowTileGrid Enter

Edit.SizeControlDown Ctrl+Shift+Down Arrow

Edit.SizeControlDownGrid Shift+Down Arrow

Edit.SizeControlLeft Ctrl+Shift+Left Arrow


C O M M A N DS

Edit.SizeControlLeftGrid Shift+Left Arrow

Edit.SizeControlRight Ctrl+Shift+Right Arrow

Edit.SizeControlRightGrid Shift+Right Arrow

Edit.SizeControlUp Ctrl+Shift+Up Arrow

Edit.SizeControlUpGrid Shift+Up Arrow

Edit.StopSearch Alt+F3, S

Edit.SurroundWith Ctrl+K, Ctrl+S

Edit.Undo Ctrl+Z

or

Alt+Backspace

Editor Context Menus


C O M M A N DS K EY B O A RD SH O RTC UT S

EditorContextMenus.CodeWindow.Breakpoint.BreakpointEditl Alt+F9, L
abels

EditorContextMenus.CodeWindow.CodeMap.ShowItem Ctrl+`

EditorContextMenus.CodeWindow.Execute Ctrl+Alt+F5

EditorContextMenus.CodeWindow.GoToView Ctrl+M, Ctrl+G

EditorContextMenus.CodeWindow.ToggleHeaderCodeFile Ctrl+K, Ctrl+O

EditorContextMenus.CodeWindow.ViewCallHierarchy Ctrl+K, Ctrl+T

or

Ctrl+K, T

File
C O M M A N DS K EY B O A RD SH O RTC UT S

File.Exit Alt+F4

File.NewFile Ctrl+N

File.NewProject Ctrl+Shift+N

File.NewWebSite Shift+Alt+N
C O M M A N DS K EY B O A RD SH O RTC UT S

File.OpenFile Ctrl+O

File.OpenProject Ctrl+Shift+O

File.OpenWebSite Shift+Alt+O

File.Print Ctrl+P

File.SaveAll Ctrl+Shift+S

File.SaveSelectedItems Ctrl+S

File.ViewinBrowser Ctrl+Shift+W

Help
C O M M A N DS K EY B O A RD SH O RTC UT S

Help.AddandRemoveHelpContent Ctrl+Alt+F1

Help.F1Help F1

Help.ViewHelp Ctrl+F1

Help.WindowHelp Shift+F1

Load Test
C OMMAND K EY B O A RD SH O RTC UT

LoadTest.JumpToCounterPane Ctrl+R, Q

Other Context Menus


C OMMAND K EY B O A RD SH O RTC UT

OtherContextMenus.MicrosoftDataEntityDesignContext.Add Insert
NewDiagram

Project
C O M M A N DS K EY B O A RD SH O RTC UT S

Project.AddExistingItem Shift+Alt+A

Project.AddNewItem Ctrl+Shift+A

Project.ClassWizard Ctrl+Shift+X

Project.Override Ctrl+Alt+Ins
C O M M A N DS K EY B O A RD SH O RTC UT S

Project.Previewchanges Alt+;, Alt+C

Project.Publishselectedfiles Alt+;, Alt+P

Project.Replaceselectedfilesfromserver Alt+;, Alt+R

Project and Solution Context Menus


C O M M A N DS K EY B O A RD SH O RTC UT S

ProjectandSolutionContextMenus.Item.MoveDown Alt+Down Arrow

ProjectandSolutionContextMenus.Item.MoveUp Alt+Up Arrow

Refactor
C O M M A N DS K EY B O A RD SH O RTC UT S

Refactor.EncapsulateField Ctrl+R, Ctrl+E

Refactor.ExtractInterface Ctrl+R, Ctrl+I

Refactor.ExtractMethod Ctrl+R, Ctrl+M

Refactor.RemoveParameters Ctrl+R, Ctrl+V

Refactor.Rename Ctrl+R, Ctrl+R

Refactor.ReorderParameters Ctrl+R, Ctrl+O

Solution Explorer
C O M M A N DS K EY B O A RD SH O RTC UT S

SolutionExplorer.OpenFilesFilter Ctrl+[, O

or

Ctrl+[, Ctrl+O

SolutionExplorer.PendingChangesFilter Ctrl+[, P

or

Ctrl+[, Ctrl+P

SolutionExplorer.SyncWithActiveDocument Ctrl+[, S

or

Ctrl+[, Ctrl+S

Team
C O M M A N DS K EY B O A RD SH O RTC UT S

Team.Git.GoToGitBranches Ctrl+0, Ctrl+N

or

Ctrl+0, N

Team.Git.GoToGitChanges Ctrl+0, Ctrl+G

or

Ctrl+0, G

Team.Git.GoToGitCommits Ctrl+0, Ctrl+O

or

Ctrl+0, O

Team.TeamExplorerSearch Ctrl+'

Team Foundation Context Menus


C O M M A N DS K EY B O A RD SH O RTC UT S

TeamFoundationContextMenus.Commands.GoToBuilds Ctrl+0, Ctrl+B

or

Ctrl+0, B

TeamFoundationContextMenus.Commands.GoToConnect Ctrl+0, Ctrl+C

or

Ctrl+0, C

TeamFoundationContextMenus.Commands.GoToDocuments Ctrl+0, Ctrl+D

or

Ctrl+0, D

TeamFoundationContextMenus.Commands.GoToHome Ctrl+0, Ctrl+H

or

Ctrl+0, H

TeamFoundationContextMenus.Commands.GoToMyWork Ctrl+0, Ctrl+M

or

Ctrl+0, M
C O M M A N DS K EY B O A RD SH O RTC UT S

TeamFoundationContextMenus.Commands.GoToPendingCha Ctrl+0, Ctrl+P


nges
or

Ctrl+0, P

TeamFoundationContextMenus.Commands.GoToReports Ctrl+0, Ctrl+R

or

Ctrl+0, R

TeamFoundationContextMenus.Commands.GoToSettings Ctrl+0, Ctrl+S

or

Ctrl+0, S

TeamFoundationContextMenus.Commands.GoToWebAccess Ctrl+0, Ctrl+A

or

Ctrl+0, A

TeamFoundationContextMenus.Commands.GoToWorkItems Ctrl+0, Ctrl+W

or

Ctrl+0, W

Test
C O M M A N DS K EY B O A RD SH O RTC UT S

Test.UseCodedUITestBuilder Ctrl+\, Ctrl+C

Test.UseExistingActionRecording Ctrl+\, Ctrl+A

Test Explorer
C O M M A N DS K EY B O A RD SH O RTC UT S

TestExplorer.DebugAllTests Ctrl+R, Ctrl+A

TestExplorer.DebugAllTestsInContext Ctrl+R, Ctrl+T

TestExplorer.RepeatLastRun Ctrl+R, L

TestExplorer.RunAllTests Ctrl+R, A

TestExplorer.RunAllTestsInContext Ctrl+R, T

Tools
C O M M A N DS K EY B O A RD SH O RTC UT S

Tools.AttachtoProcess Ctrl+Alt+P

Tools.CodeSnippetsManager Ctrl+K, Ctrl+B

Tools.ForceGC Ctrl+Shift+Alt+F12, Ctrl+Shift+Alt+F12

Tools.GoToCommandLine Ctrl+/

View
C O M M A N DS K EY B O A RD SH O RTC UT S

View.AllWindows Shift+Alt+M

View.ArchitectureExplorer Ctrl+\, Ctrl+R

View.Backward Alt+Left Arrow

View.BookmarkWindow Ctrl+K, Ctrl+W

View.BrowseNext Ctrl+Shift+1

View.BrowsePrevious Ctrl+Shift+2

View.CallHierarchy Ctrl+Alt+K

View.ClassView Ctrl+Shift+C

View.ClassViewGoToSearchCombo Ctrl+K, Ctrl+V

View.CodeDefinitionWindow Ctrl+\, D

or

Ctrl+\, Ctrl+D

View.CommandWindow Ctrl+Alt+A

View.DataSources Shift+Alt+D

View.DocumentOutline Ctrl+Alt+T

View.EditLabel F2

View.ErrorList Ctrl+\, E

or

Ctrl+\, Ctrl+E

View.F#Interactive Ctrl+Alt+F
C O M M A N DS K EY B O A RD SH O RTC UT S

View.FindSymbolResults Ctrl+Alt+F12

View.Forward Alt+Right Arrow

View.ForwardBrowseContext Ctrl+Shift+7

View.FullScreen Shift+Alt+Enter

View.NavigateBackward Ctrl+-

View.NavigateForward Ctrl+Shift+-

View.NextError Ctrl+Shift+F12

View.Notifications Ctrl+W, N

or

Ctrl+W, Ctrl+N

View.ObjectBrowser Ctrl+Alt+J

View.ObjectBrowserGoToSearchCombo Ctrl+K, Ctrl+R

View.Output Ctrl+Alt+O

View.PopBrowseContex Ctrl+Shift+8

View.PropertiesWindow F4

View.PropertyPages Shift+F4

View.ResourceView Ctrl+Shift+E

View.ServerExplorer Ctrl+Alt+S

View.ShowSmartTag Shift+Alt+F10

or

Ctrl+.

View.SolutionExplorer Ctrl+Alt+L

View.SQLServerObjectExplorer Ctrl+\, Ctrl+S

View.TaskList Ctrl+\, T

or

Ctrl+\, Ctrl+T
C O M M A N DS K EY B O A RD SH O RTC UT S

View.TfsTeamExplorer Ctrl+\, Ctrl+M

View.Toolbox Ctrl+Alt+X

View.UMLModelExplorer Ctrl+\, Ctrl+U

View.ViewCode F7

View.ViewDesigner Shift+F7

View.WebBrowser Ctrl+Alt+R

View.ZoomIn Ctrl+Shift+.

View.ZoomOut Ctrl+Shift+,

Window
C O M M A N DS K EY B O A RD SH O RTC UT S

Window.ActivateDocumentWindow Esc

Window.AddTabtoSelection Ctrl+Shift+Alt+Space

Window.CloseDocumentWindow Ctrl+F4

Window.CloseToolWindow Shift+Esc

Window.KeepTabOpen Ctrl+Alt+Home

Window.MovetoNavigationBar Ctrl+F2

Window.NextDocumentWindow Ctrl+F6

Window.NextDocumentWindowNav Ctrl+Tab

Window.NextPane Alt+F6

Window.NextSplitPane F6

Window.NextTab Ctrl+Alt+PgDn

or

Ctrl+PgDn

Window.NextTabandAddtoSelection Ctrl+Shift+Alt+PgDn

Window.NextToolWindowNav Alt+F7

Window.PreviousDocumentWindow Ctrl+Shift+F6
C O M M A N DS K EY B O A RD SH O RTC UT S

Window.PreviousDocumentWindowNav Ctrl+Shift+Tab

Window.PreviousPane Shift+Alt+F6

Window.PreviousSplitPane Shift+F6

Window.PreviousTab Ctrl+Alt+PgUp

or

Ctrl+PgUp

Window.PreviousTabandAddtoSelection Ctrl+Shift+Alt+PgUp

Window.PreviousToolWindowNav Shift+Alt+F7

Window.QuickLaunch Ctrl+Q

Window.QuickLaunchPreviousCategory Ctrl+Shift+Q

Window.ShowDockMenu Alt+-

Window.ShowEzMDIFileList Ctrl+Alt+Down Arrow

Window.SolutionExplorerSearch Ctrl+;

Window.WindowSearch Alt+`

Azure
C O M M A N DS K EY B O A RD SH O RTC UT S

WindowsAzure.RetryMobileServiceScriptOperation Ctrl+Num *, Ctrl+R

WindowsAzure.ShowMobileServiceScriptErrorDetails Ctrl+Num *, Ctrl+D

ADO.NET Entity Data Model Designer


C O M M A N DS K EY B O A RD SH O RTC UT S

OtherContextMenus.MicrosoftDataEntityDesignContext.Mov Alt+Down Arrow


eProperties.Down

OtherContextMenus.MicrosoftDataEntityDesignContext.Mov Alt+PgDn
eProperties.Down5

OtherContextMenus.MicrosoftDataEntityDesignContext.Mov Alt+End
eProperties.ToBottom

OtherContextMenus.MicrosoftDataEntityDesignContext.Mov Alt+Home
eProperties.ToTop
C O M M A N DS K EY B O A RD SH O RTC UT S

OtherContextMenus.MicrosoftDataEntityDesignContext.Mov Alt+Up Arrow


eProperties.Up

OtherContextMenus.MicrosoftDataEntityDesignContext.Mov Alt+PgUp
eProperties.Up5

OtherContextMenus.MicrosoftDataEntityDesignContext.Refac Ctrl+R, R
tor.Rename

OtherContextMenus.MicrosoftDataEntityDesignContext.Rem Shift+Del
ovefromDiagram

View.EntityDataModelBrowser Ctrl+1

View.EntityDataModelMappingDetails Ctrl+2

Class Diagram
C O M M A N DS K EY B O A RD SH O RTC UT S

ClassDiagram.Collapse Num -

ClassDiagram.Expand Num +

Edit.Delete Ctrl+Del

Edit.ExpandCollapseBaseTypeList Shift+Alt+B

Edit.NavigateToLollipop Shift+Alt+L

Edit.RemovefromDiagram Delete

View.ViewCode Enter

Coded UI Test Editor


C O M M A N DS K EY B O A RD SH O RTC UT S

OtherContextMenus.UITestEditorContextMenu.CopyReferenc Ctrl+C
etoClipboard

OtherContextMenus.UITestEditorContextMenu.InsertDelayBe Ctrl+Alt+D
fore

OtherContextMenus.UITestEditorContextMenu.LocateAll Shift+Alt+L

OtherContextMenus.UITestEditorContextMenu.LocatetheUIC Ctrl+Shift+L
ontrol

OtherContextMenus.UITestEditorContextMenu.Movecode Ctrl+Alt+C
C O M M A N DS K EY B O A RD SH O RTC UT S

OtherContextMenus.UITestEditorContextMenu.Splitintoanew Ctrl+Shift+T
method

DataSet Editor
C O M M A N DS K EY B O A RD SH O RTC UT S

OtherContextMenus.ColumnContext.InsertColumn Insert

OtherContextMenus.DbTableContext.Add.Column Ctrl+L

Difference Viewer
C O M M A N DS K EY B O A RD SH O RTC UT S

Diff.IgnoreTrimWhitespace Ctrl+\, Ctrl+Spacebar

Diff.InlineView Ctrl+\, Ctrl+1

Diff.LeftOnlyView Ctrl+\, Ctrl+3

Diff.NextDifference F8

Diff.PreviousDifference Shift+F8

Diff.RightOnlyView Ctrl+\, Ctrl+4

Diff.SideBySideView Ctrl+\, Ctrl+2

Diff.SwitchBetweenLeftAndRight Ctrl+\, Ctrl+Tab

Diff.SynchronizeViewToggle Ctrl+\, Ctrl+Down Arrow

EditorContextMenus.CodeWindow.AddComment Ctrl+Shift+K

EditorContextMenus.CodeWindow.EditLocalFile Ctrl+Shift+P

DOM Explorer
C O M M A N DS K EY B O A RD SH O RTC UT S

DOMExplorer.Refresh F5

DOMExplorer.SelectElement Ctrl+B

DOMExplorer.ShowLayout Ctrl+Shift+I

F# Interactive
C OMMAND K EY B O A RD SH O RTC UT

OtherContextMenus.FSIConsoleContext.CancelInteractiveEval Ctrl+Break
uation

Graph Document Editor


C O M M A N DS K EY B O A RD SH O RTC UT S

ArchitectureContextMenus.DirectedGraphContextMenu.Adva Insert
nced.Add.AddNode

ArchitectureContextMenus.DirectedGraphContextMenu.Adva B
nced.Select.BothDependencies

ArchitectureContextMenus.DirectedGraphContextMenu.Adva I
nced.Select.IncomingDependencies

ArchitectureContextMenus.DirectedGraphContextMenu.Adva O
nced.Select.OutgoingDependencies

ArchitectureContextMenus.DirectedGraphContextMenu.New Ctrl+Shift+K
Comment
or

Ctrl+E, C

ArchitectureContextMenus.DirectedGraphContextMenu.Rem Delete
ove

ArchitectureContextMenus.DirectedGraphContextMenu.Rena F2
me

Graphics Diagnostics
C O M M A N DS K EY B O A RD SH O RTC UT S

Debug.Graphics.CaptureFrame None

Graphics.MovePixelSelectionDown Shift+Alt+Down Arrow

Graphics.MovePixelSelectionLeft Shift+Alt+Left Arrow

Graphics.MovePixelSelectionRight Shift+Alt+Right Arrow

Graphics.MovePixelSelectionUp Shift+Alt+Up Arrow

Graphics.ZoomToActualSize Shift+Alt+0

Graphics.ZoomToFitInWindow Shift+Alt+9

Graphics.ZoomIn Shift+Alt+=
C O M M A N DS K EY B O A RD SH O RTC UT S

Graphics.ZoomOut Shift+Alt+-

HTML Editor
C OMMAND K EY B O A RD SH O RTC UT

OtherContextMenus.HTMLContext.GoToController Ctrl+M, Ctrl+G

HTML Editor Design View


C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.MoveControlDown Ctrl+Down Arrow

Edit.MoveControlUp Ctrl+Up Arrow

Format.Bold Ctrl+B

Format.ConverttoHyperlink Ctrl+L

Format.InsertBookmark Ctrl+Shift+L

Format.Italic Ctrl+I

Format.Underline Ctrl+U

Project.AddContentPage Ctrl+M, Ctrl+C

Table.ColumntotheLeft Ctrl+Alt+Left Arrow

Table.ColumntotheRight Ctrl+Alt+Right Arrow

Table.RowAbove Ctrl+Alt+Up Arrow

Table.RowBelow Ctrl+Alt+Down Arrow

View.ASP.NETNonvisualControls Ctrl+Shift+N

View.EditMaster Ctrl+M, Ctrl+M

View.NextView Ctrl+PgDn

View.ShowSmartTag Shift+Alt+F10

View.ViewMarkup Shift+F7

Window.PreviousTab Ctrl+PgUp
HTML Editor Source View
C O M M A N DS K EY B O A RD SH O RTC UT S

OtherContextMenus.HTMLContext.GoToController Ctrl+M, Ctrl+G

View.NextView Ctrl+PgDn

View.SynchronizeViews Ctrl+Shift+Y

View.ViewDesigner Shift+F7

Window.PreviousTab Ctrl+PgUp

Layer Diagram
C OMMAND K EY B O A RD SH O RTC UT

Edit.Delete Shift+Delete

Managed Resources Editor


C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.EditCell F2

Edit.Remove Delete

Edit.RemoveRow Ctrl+Delete

Edit.SelectionCancel Escape

Resources.Audio Ctrl+4

Resources.Files Ctrl+5

Resources.Icons Ctrl+3

Resources.Images Ctrl+2

Resources.Other Ctrl+6

Resources.Strings Ctrl+1

Merge Editor Window


C O M M A N DS K EY B O A RD SH O RTC UT S

TeamFoundationContextMenus.MergeContextMenu.SetFocus Alt+1
onLeftWindow
C O M M A N DS K EY B O A RD SH O RTC UT S

TeamFoundationContextMenus.MergeContextMenu.SetFocus Alt+2
onResultWindow

TeamFoundationContextMenus.MergeContextMenu.SetFocus Alt+3
onRightWindow

Microsoft SQL Server Data Tools, Schema Compare


C O M M A N DS K EY B O A RD SH O RTC UT S

SQL.SSDTSchemaCompareCompare Shift+Alt+C

SQL.SSDTSchemaCompareGenerateScript Shift+Alt+G

SQL.SSDTSchemaCompareNextChange Shift+Alt+.

SQL.SSDTSchemaComparePreviousChange Shift+Alt+,

SQL.SSDTSchemaCompareStop Alt+Break

SQL.SSDTSchemaCompareWriteUpdates Shift+Alt+U

Microsoft SQL Server Data Tools, Table Designer


C O M M A N DS K EY B O A RD SH O RTC UT S

CommitAllEdits Shift+Alt+U

SQL.ExpandWildcards Ctrl+R, E

or

Ctrl+R, Ctrl+E

SQL.FullyqualifyNames Ctrl+R, Q

or

Ctrl+R, Ctrl+Q

SQL.MovetoSchema Ctrl+R, M

or

Ctrl+R, Ctrl+M
C O M M A N DS K EY B O A RD SH O RTC UT S

SQL.Rename F2

or

Ctrl+R, R

or

Ctrl+R, Ctrl+R

ViewFileInScriptPanel Shift+Alt+PgDn

Microsoft SQL Server Data Tools, T-SQL Editor


C O M M A N DS K EY B O A RD SH O RTC UT S

CommitAllEdits Shift+Alt+U

SQL.ExecuteWithDebugger Alt+F5

SQL.ExpandWildcards Ctrl+R, E

or

Ctrl+R, Ctrl+E

SQL.FullyqualifyNames Ctrl+R, Q

or

Ctrl+R, Ctrl+Q

SQL.MovetoSchema Ctrl+R, M

or

Ctrl+R, Ctrl+M

SQL.Rename F2

or

Ctrl+R, R

or

Ctrl+R, Ctrl+R

SQL.TSqlEditorCancelQuery Alt+Break

SQL.TSqlEditorExecuteQuery Ctrl+Shift+E

SQL.TSqlEditorResultsAsFile Ctrl+D, F

SQL.TSqlEditorResultsAsGrid Ctrl+D, G
C O M M A N DS K EY B O A RD SH O RTC UT S

SQL.TSqlEditorResultsAsText Ctrl+D, T

SQL.TSqlEditorShowEstimatedPlan Ctrl+D, E

SQL.TSqlEditorToggleExecutionPlan Ctrl+D, A

SQL.TSqlEditorToggleResultsPane Ctrl+D, R

TSqlEditorCloneQuery Ctrl+Alt+N

TSqlEditorDatabaseCombo Shift+Alt+PgDn

Microsoft SQL Server Data Tools, T-SQL PDW Editor


C O M M A N DS K EY B O A RD SH O RTC UT S

SQL.TSqlEditorCancelQuery Alt+Break

SQL.TSqlEditorExecuteQuery Ctrl+Shift+E

SQL.TSqlEditorResultsAsFile Ctrl+D, F

SQL.TSqlEditorResultsAsGrid Ctrl+D, G

SQL.TSqlEditorResultsAsText Ctrl+D, T

SQL.TSqlEditorShowEstimatedPlan Ctrl+D, E

SQL.TSqlEditorToggleExecutionPlan Ctrl+D, A

SQL.TSqlEditorToggleResultsPane Ctrl+D, R

TSqlEditorCloneQuery Ctrl+Alt+N

TSqlEditorDatabaseCombo Shift+Alt+PgDn

Page Inspector
C OMMAND K EY B O A RD SH O RTC UT

PageInspector.Minimize F12

Query Designer
C O M M A N DS K EY B O A RD SH O RTC UT S

QueryDesigner.CancelRetrievingData Ctrl+T
C O M M A N DS K EY B O A RD SH O RTC UT S

QueryDesigner.Criteria Ctrl+2

QueryDesigner.Diagram Ctrl+1

QueryDesigner.ExecuteSQL Ctrl+R

QueryDesigner.GotoRow Ctrl+G

QueryDesigner.JoinMode Ctrl+Shift+J

QueryDesigner.Results Ctrl+4

QueryDesigner.SQL Ctrl+3

Query Results
C O M M A N DS K EY B O A RD SH O RTC UT S

SQL.QueryResultsNewRow Alt+End

SQL.QueryResultsRefresh Shift+Alt+R

SQL.QueryResultsStop Alt+Break

Report Designer
C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.BreakLine Enter

Edit.CharLeft Left Arrow

Edit.CharLeftExtend Shift+Left Arrow

Edit.CharRight Right Arrow

Edit.CharRightExtend Shift+Right Arrow

Edit.InsertTab Tab

Edit.LineDown Down Arrow

Edit.LineDownExtend Shift+Down Arrow

Edit.LineUp Up Arrow

Edit.LineUpExtend Shift+Up Arrow

Edit.MoveControlDown Ctrl+Down Arrow


C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.MoveControlLeft Ctrl+Left Arrow

Edit.MoveControlRight Ctrl+Right Arrow

Edit.MoveControlUp Ctrl+Up Arrow

Edit.SelectionCancel Esc

Edit.SizeControlDown Ctrl+Shift+Down Arrow

Edit.SizeControlLeft Ctrl+Shift+Left Arrow

Edit.SizeControlRight Ctrl+Shift+Right Arrow

Edit.SizeControlUp Ctrl+Shift+Up Arrow

Edit.TabLeft Shift+Tab

View.ReportData Ctrl+Alt+D

Sequence Diagram
C O M M A N DS K EY B O A RD SH O RTC UT S

ArchitectureDesigner.Sequence.NavigateToCode F12

Edit.Delete Shift+Del

Settings Designer
C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.EditCell F2

Edit.RemoveRow Ctrl+Delete

Edit.SelectionCancel Esc

View.ViewCode F7

Solution Explorer
C OMMAND K EY B O A RD SH O RTC UT

ClassViewContextMenus.ClassViewProject.View.ViewinPageIn Ctrl+K, Ctrl+G


spector

Team Explorer
C OMMAND K EY B O A RD SH O RTC UT

Edit.Delete Delete

File.Rename F2

TeamFoundationContextMenus.Commands.GoToTeamExplore Alt+Home
rNavigation

TeamFoundationContextMenus.Commands.GoToTeamExplore Alt+Down Arrow


rNextSectionContent

TeamFoundationContextMenus.Commands.GoToTeamExplore Alt+0
rPageContent

TeamFoundationContextMenus.Commands.GoToTeamExplore Alt+Up Arrow


rPreviousSectionContent

TeamFoundationContextMenus.Commands.GoToTeamExplore Alt+1
rSection1Content

TeamFoundationContextMenus.Commands.GoToTeamExplore Alt+2
rSection2Content

TeamFoundationContextMenus.Commands.GoToTeamExplore Alt+3
rSection3Content

TeamFoundationContextMenus.Commands.GoToTeamExplore Alt+4
rSection4Content

TeamFoundationContextMenus.Commands.GoToTeamExplore Alt+5
rSection5Content

TeamFoundationContextMenus.Commands.GoToTeamExplore Alt+6
rSection6Content

TeamFoundationContextMenus.Commands.GoToTeamExplore Alt+7
rSection7Content

TeamFoundationContextMenus.Commands.GoToTeamExplore Alt+8
rSection8Content

TeamFoundationContextMenus.Commands.GoToTeamExplore Alt+9
rSection9Content

TeamFoundationContextMenus.Commands.TeamExplorerNavi Alt+Left Arrow


gateBackward

TeamFoundationContextMenus.Commands.TeamExplorerNavi Alt+Right Arrow


gateForward

TeamFoundationContextMenus.MyWorkPageInProgress.TfsC Shift+Alt+C
ontextMyWorkPageCreateCopyWI
C OMMAND K EY B O A RD SH O RTC UT

TeamFoundationContextMenus.MyWorkPageInProgress.TfsC Shift+Alt+L
ontextMyWorkPageNewLinkedWI

View.Refresh F5

Team Foundation Build Detail Editor


C OMMAND K EY B O A RD SH O RTC UT

View.Refresh F5

Test Explorer
C OMMAND K EY B O A RD SH O RTC UT

TestExplorer.OpenTest F12

Text Editor
C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.BreakLine Enter

or

Shift+Enter

Edit.CharLeft Left Arrow

Edit.CharLeftExtend Shift+Left Arrow

Edit.CharLeftExtendColumn Shift+Alt+Left Arrow

Edit.CharRight Right Arrow

Edit.CharRightExtend Shift+Right Arrow

Edit.CharRightExtendColumn Shift+Alt+Right Arrow

Edit.CharTranspose Ctrl+T

Edit.ClearBookmarks Ctrl+K, Ctrl+L

Edit.CollapseAllOutlining Ctrl+M, Ctrl+A

Edit.CollapseCurrentRegion Ctrl+M, Ctrl+S

Edit.CollapseTag Ctrl+M, Ctrl+T


C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.CollapsetoDefinitions Ctrl+M, Ctrl+O

Edit.CommentSelection Ctrl+K, Ctrl+C

Edit.CompleteWord Ctrl+Space

or

Alt+Right Arrow

Edit.CopyParameterTip Ctrl+Shift+Alt+C

Edit.DecreaseFilterLevel Alt+,

Edit.DeleteBackwards Backspace

or

Shift+Bkspce

Edit.DeleteHorizontalWhiteSpace Ctrl+K, Ctrl+\

Edit.DocumentEnd Ctrl+End

Edit.DocumentEndExtend Ctrl+Shift+End

Edit.DocumentStart Ctrl+Home

Edit.DocumentStartExtend Ctrl+Shift+Home

Edit.ExpandAllOutlining Ctrl+M, Ctrl+X

Edit.ExpandCurrentRegion Ctrl+M, Ctrl+E

Edit.FormatDocument Ctrl+K, Ctrl+D

Edit.FormatSelection Ctrl+K, Ctrl+F

Edit.GotoBrace Ctrl+]

Edit.GotoBraceExtend Ctrl+Shift+]

Edit.HideSelection Ctrl+M, Ctrl+H

Edit.IncreaseFilterLevel Alt+.

Edit.IncrementalSearch Ctrl+I

Edit.InsertTab Tab

Edit.LineCut Ctrl+L
C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.LineDelete Ctrl+Shift+L

Edit.LineDown Down Arrow

Edit.LineDownExtend Shift+Down Arrow

Edit.LineDownExtendColumn Shift+Alt+Down Arrow

Edit.LineEnd End

Edit.LineEndExtend Shift+End

Edit.LineEndExtendColumn Shift+Alt+End

Edit.LineOpenAbove Ctrl+Enter

Edit.LineOpenBelow Ctrl+Shift+Enter

Edit.LineStart Home

Edit.LineStartExtend Shift+Home

Edit.LineStartExtendColumn Shift+Alt+Home

Edit.LineTranspose Shift+Alt+T

Edit.LineUp Up Arrow

Edit.LineUpExtend Shift+Up Arrow

Edit.LineUpExtendColumn Shift+Alt+Up Arrow

Edit.ListMembers Ctrl+J

Edit.MakeLowercase Ctrl+U

Edit.MakeUppercase Ctrl+Shift+U

Edit.MoveSelectedLinesDown Alt+Down Arrow

Edit.MoveSelectedLinesUp Alt+Up Arrow

Edit.NextHighlightedReference Ctrl+Shift+Down Arrow

Edit.OvertypeMode Insert

Edit.PageDown PgDn

Edit.PageDownExtend Shift+PgDn
C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.PageUp PgUp

Edit.PageUpExtend Shift+PgUp

Edit.ParameterInfo Ctrl+Shift+Spacebar

Edit.PasteParameterTip Ctrl+Shift+Alt+P

Edit.PeekBackward Ctrl+Alt+-

Edit.PeekDefinition Alt+F12

Edit.PeekForward Ctrl+Alt+=

Edit.PreviousHighlightedReference Ctrl+Shift+Up Arrow

Edit.QuickInfo Ctrl+K, Ctrl+I

Edit.ReverseIncrementalSearch Ctrl+Shift+I

Edit.ScrollLineDown Ctrl+Down Arrow

Edit.ScrollLineUp Ctrl+Up Arrow

Edit.SelectCurrentWord Ctrl+W

Edit.SelectionCancel Escape

Edit.SelectToLastGoBack Ctrl+=

Edit.ShowCodeLensMenu Alt+`

Edit.StopHidingCurrent Ctrl+M, Ctrl+U

Edit.StopOutlining Ctrl+M, Ctrl+P

Edit.SwapAnchor Ctrl+K, Ctrl+A

Edit.TabLeft Shift+Tab

Edit.ToggleAllOutlining Ctrl+M, Ctrl+L

Edit.ToggleBookmark Ctrl+K, Ctrl+K

Edit.ToggleCompletionMode Ctrl+Alt+Space

Edit.ToggleOutliningExpansion Ctrl+M, Ctrl+M

Edit.ToggleTaskListShortcut Ctrl+K, Ctrl+H


C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.ToggleWordWrap Ctrl+E, Ctrl+W

Edit.UncommentSelection Ctrl+K, Ctrl+U

Edit.ViewBottom Ctrl+PgDn

Edit.ViewBottomExtend Ctrl+Shift+PgDn

Edit.ViewTop Ctrl+PgUp

Edit.ViewTopExtend Ctrl+Shift+PgUp

Edit.ViewWhiteSpace Ctrl+R, Ctrl+W

Edit.WordDeleteToEnd Ctrl+Delete

Edit.WordDeleteToStart Ctrl+Backspace

Edit.WordNext Ctrl+Right Arrow

Edit.WordNextExtend Ctrl+Shift+Right Arrow

Edit.WordNextExtendColumn Ctrl+Shift+Alt+Right Arrow

Edit.WordPrevious Ctrl+Left Arrow

Edit.WordPreviousExtend Ctrl+Shift+Left Arrow

Edit.WordPreviousExtendColumn Ctrl+Shift+Alt+Left Arrow

Edit.WordTranspose Ctrl+Shift+T

EditorContextMenus.CodeWindow.ExecuteInInteractive Alt+Enter

EditorContextMenus.CodeWindow.ExecuteLineInInteractive Alt+'

OtherContextMenus.HTMLContext.ViewinPageInspector Ctrl+K, Ctrl+G

TeamFoundationContextMenus.Annotate.TfsAnnotateMoveN Alt+PgDn
extRegion

TeamFoundationContextMenus.Annotate.TfsAnnotateMovePr Alt+PgUp
eviousRegion

UML Activity Diagram


C OMMAND K EY B O A RD SH O RC T UT

Edit.Delete Shift+Del
UML Class Diagram
C OMMAND K EY B O A RD SH O RC T UT

Edit.DeleteFromModel Shift+Del

UML Component Diagram


C OMMAND K EY B O A RD SH O RC T UT

Edit.DeleteFromModel Shift+Del

UML Use Case Diagram


C OMMAND K EY B O A RD SH O RC T UT

Edit.DeleteFromModel Shift+Del

VC Accelerator Editor
C O M M A N DS K EY B O A RD SH O RC T UT S

Edit.NewAccelerator Insert

Edit.NextKeyTyped Ctrl+W

VC Dialog Editor
C O M M A N DS K EY B O A RD SH O RC T UT S

Edit.MoveControlDown Down Arrow

Edit.MoveControlLeft Left Arrow

Edit.MoveControlRight Right Arrow

Edit.MoveControlUp Up Arrow

Edit.ScrollColumnLeft Ctrl+Left Arrow

Edit.ScrollColumnRight Ctrl+Right Arrow

Edit.ScrollLineDown Ctrl+Down Arrow

Edit.ScrollLineUp Ctrl+Up Arrow

Edit.SizeControlDown Shift+Down Arrow

Edit.SizeControlLeft Shift+Left Arrow


C O M M A N DS K EY B O A RD SH O RC T UT S

Edit.SizeControlRight Shift+Right Arrow

Edit.SizeControlUp Shift+Up Arrow

Format.AlignBottoms Ctrl+Shift+Down Arrow

Format.AlignCenters Shift+F9

Format.AlignLefts Ctrl+Shift+Left Arrow

Format.AlignMiddles F9

Format.AlignRights Ctrl+Shift+Right Arrow

Format.AlignTops Ctrl+Shift+Up Arrow

Format.ButtonBottom Ctrl+B

Format.ButtonRight Ctrl+R

Format.CenterHorizontal Ctrl+Shift+F9

Format.CenterVertical Ctrl+F9

Format.CheckMnemonics Ctrl+M

Format.SizetoContent Shift+F7

Format.SpaceAcross Alt+Right Arrow

or

Alt+Left Arrow

Format.SpaceDown Alt+Up Arrow

or

Alt+Down Arrow

Format.TabOrder Ctrl+D

Format.TestDialog Ctrl+T

Format.ToggleGuides Ctrl+G

VC Image Editor
C O M M A N DS K EY B O A RD SH O RTC UT S

Image.AirbrushTool Ctrl+A
C O M M A N DS K EY B O A RD SH O RTC UT S

Image.BrushTool Ctrl+B

Image.CopyandOutlineSelection Ctrl+Shift+U

Image.DrawOpaque Ctrl+J

Image.EllipseTool Alt+P

Image.EraseTool Ctrl+Shift+I

Image.FilledEllipseTool Ctrl+Shift+Alt+P

Image.FilledRectangleTool Ctrl+Shift+Alt+R

Image.FilledRoundedRectangleTool Ctrl+Shift+Alt+W

Image.FillTool Ctrl+F

Image.FlipHorizontal Ctrl+H

Image.FlipVertical Shift+Alt+H

Image.LargerBrush Ctrl+=

Image.LineTool Ctrl+L

Image.MagnificationTool Ctrl+M

Image.Magnify Ctrl+Shift+M

Image.NewImageType Insert

Image.NextColor Ctrl+]

or

Ctrl+Right Arrow

Image.NextRightColor Ctrl+Shift+]

or

Ctrl+Shift+Right Arrow

Image.OutlinedEllipseTool Shift+Alt+P

Image.OutlinedRectangleTool Shift+Alt+R

Image.OutlinedRoundedRectangleTool Shift+Alt+W

Image.PencilTool Ctrl+I
C O M M A N DS K EY B O A RD SH O RTC UT S

Image.PreviousColor Ctrl+[

or

Ctrl+Left Arrow

Image.PreviousRightColor Ctrl+Shift+[

or

Ctrl+Shift+Left Arrow

Image.RectangleSelectionTool Shift+Alt+S

Image.RectangleTool Alt+R

Image.Rotate90Degrees Ctrl+Shift+H

Image.RoundedRectangleTool Alt+W

Image.ShowGrid Ctrl+Alt+S

Image.ShowTileGrid Ctrl+Shift+Alt+S

Image.SmallBrush Ctrl+.

Image.SmallerBrush Ctrl+-

Image.TextTool Ctrl+T

Image.UseSelectionasBrush Ctrl+U

Image.ZoomIn Ctrl+Shift+.

or

Ctrl+Up Arrow

Image.ZoomOut Ctrl+Shift+,

or

Ctrl+Down Arrow

VC String Editor
C OMMAND K EY B O A RD SH O RTC UT

Edit.NewString Insert

View Designer
C O M M A N DS K EY B O A RD SH O RTC UT S

QueryDesigner.CancelRetrievingData Ctrl+T

QueryDesigner.Criteria Ctrl+2

QueryDesigner.Diagram Ctrl+1

QueryDesigner.ExecuteSQL Ctrl+R

QueryDesigner.GotoRow Ctrl+G

QueryDesigner.JoinMode Ctrl+Shift+J

QueryDesigner.Results Ctrl+4

QueryDesigner.SQL Ctrl+3

Visual Studio
C OMMAND K EY B O A RD SH O RTC UT

OtherContextMenus.ORDesignerContext.HideMethodsPane Ctrl+1

Windows Forms Designer


C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.BreakLine Enter

Edit.CharLeft Left Arrow

Edit.CharLeftExtend Shift+Left Arrow

Edit.CharRight Right Arrow

Edit.CharRightExtend Shift+Right Arrow

Edit.DocumentEnd End

Edit.DocumentEndExtend Shift+End

Edit.DocumentStart Home

Edit.DocumentStartExtend Shift+Home

Edit.InsertTab Tab

Edit.LineDown Down Arrow

Edit.LineDownExtend Shift+Up Arrow


C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.LineUp Up Arrow

Edit.LineUpExtend Shift+Down Arrow

Edit.MoveControlDown Ctrl+Down Arrow

Edit.MoveControlLeft Ctrl+Left Arrow

Edit.MoveControlRight Ctrl+Right Arrow

Edit.MoveControlUp Ctrl+Up Arrow

Edit.SelectionCancel Escape

Edit.SizeControlDown Ctrl+Shift+Down Arrow

Edit.SizeControlLeft Ctrl+Shift+Left Arrow

Edit.SizeControlRight Ctrl+Shift+Right Arrow

Edit.SizeControlUp Ctrl+Shift+Up Arrow

Edit.TabLeft Shift+Tab

Work Item Editor


C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.CreateCopyofWorkItem Shift+Alt+C

Edit.RefreshWorkItem F5

Team.NewLinkedWorkItem Shift+Alt+L

Work Item Query View


C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.CreateCopyofWorkItem Shift+Alt+C

Edit.Indent Shift+Alt+Right Arrow

Edit.Outdent Shift+Alt+Left Arrow

Team.NewLinkedWorkItem Shift+Alt+L

Team.Refresh F5

Window.Toggle Shift+Alt+V
Work Item Results View
C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.CreateCopyofWorkItem Shift+Alt+C

Edit.Indent Shift+Alt+Right Arrow

Edit.Outdent Shift+Alt+Left Arrow

Team.GotoNextWorkItem Shift+Alt+N

Team.GotoPreviousWorkItem Shift+Alt+P

Team.NewLinkedWorkItem Shift+Alt+L

Team.Refresh F5

Window.Toggle Shift+Alt+V

Workflow Designer
C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.CompleteWord Ctrl+K, W

or

Ctrl+K, Ctrl+W

or

Ctrl+Spacebar

or

Alt+Right Arrow

Edit.DecreaseFilterLevel Alt+,

Edit.IncreaseFilterLevel Alt+.

Edit.ListMembers Ctrl+K, L

or

Ctrl+K, Ctrl+L

or

Ctrl+J
C O M M A N DS K EY B O A RD SH O RTC UT S

Edit.ParameterInfo Ctrl+K, P

or

Ctrl+K, Ctrl+P

or

Ctrl+Shift+Spacebar

Edit.QuickInfo Ctrl+K, I

or

Ctrl+K, Ctrl+I

WorkflowDesigner.Collapse Ctrl+E, Ctrl+C

or

Ctrl+E, C

WorkflowDesigner.CollapseAll or

WorkflowDesigner.ConnectNodes Ctrl+E, Ctrl+F

or

Ctrl+E, F

WorkflowDesigner.CreateVariable Ctrl+E, Ctrl+N

or

Ctrl+E, N

WorkflowDesigner.ExpandAll Ctrl+E, Ctrl+X

or

Ctrl+E, X

WorkflowDesigner.ExpandInPlace Ctrl+E, Ctrl+E

or

Ctrl+E, E

WorkflowDesigner.GoToParent Ctrl+E, Ctrl+P

or

Ctrl+E, P
C O M M A N DS K EY B O A RD SH O RTC UT S

WorkflowDesigner.MoveFocus Ctrl+E, Ctrl+M

or

Ctrl+E, M

WorkflowDesigner.NavigateThroughDesigner Ctrl+Alt+F6

WorkflowDesigner.Restore Ctrl+E, Ctrl+R

or

Ctrl+E, R

WorkflowDesigner.ShowHideArgumentDesigner Ctrl+E, Ctrl+A

or

Ctrl+E, A

WorkflowDesigner.ShowHideImportsDesigner Ctrl+E, Ctrl+I

or

Ctrl+E, I

WorkflowDesigner.ShowHideOverviewMap Ctrl+E, Ctrl+O

or

Ctrl+E, O

WorkflowDesigner.ShowHideVariableDesigner Ctrl+E, Ctrl+V

or

Ctrl+E, V

WorkflowDesigner.ToggleSelection Ctrl+E, Ctrl+S

or

Ctrl+E, S

WorkflowDesigner.ZoomIn Ctrl+Num +

WorkflowDesigner.ZoomOut Ctrl+Num -

XAML UI Designer
C O M M A N DS K EY B O A RD SH O RTC UT S

Design.FitAll Ctrl+0

Design.ShowHandles F9
C O M M A N DS K EY B O A RD SH O RTC UT S

Design.ZoomIn Ctrl+Alt+=

Design.ZoomOut Ctrl+Alt+-

Format.EditText F2

Format.ResetLayout.All Ctrl+Shift+R

View.EdgeLeftMoveLeft Ctrl+Shift+,

View.EdgeLeftMoveRight Ctrl+Shift+.

View.EdgeRightMoveLeft Ctrl+Shift+Alt+,

View.EdgeRightMoveRight Ctrl+Shift+Alt+.

Run project code Ctrl+F9

XML (Text) Editor


C O M M A N DS K EY B O A RD SH O RTC UT S

XML.StartXSLTDebugging Alt+F5

XML.StartXSLTWithoutDebugging Ctrl+Alt+F5

XML Schema Designer


C O M M A N DS K EY B O A RD SH O RTC UT S

GraphView.BottomtoTop Alt+Up Arrow

GraphView.LefttoRight Alt+Right Arrow

GraphView.RighttoLeft Alt+Left Arrow

GraphView.ToptoBottom Alt+Down Arrow

OtherContextMenus.GraphView.RemovefromWorkspace Delete

XsdDesigner.ShowContentModelView Ctrl+2

XsdDesigner.ShowGraphView Ctrl+3

XsdDesigner.ShowStartView Ctrl+1

See Also
Image Editor for Icons Using IntelliSense
Using IntelliSense
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

IntelliSense is the general term for a number of features: List Members, Parameter Info, Quick Info, and
Complete Word. These features help you to learn more about the code you are using, keep track of the
parameters you are typing, and add calls to properties and methods with only a few keystrokes.
Many aspects of IntelliSense are language-specific. For more information about IntelliSense for different
languages, see the topics listed under See Also.

List Members
A list of valid members from a type (or namespace) appears after you type a trigger character (for example, a
period ( . ) in managed code or :: in C++). If you continue typing characters, the list is filtered to include only
the members that begin with those characters.
After selecting an item, you can insert it into your code by pressing TAB or by typing a space. If you select an
item and type a period, the item appears followed by the period, which brings up another member list. When
you select an item but before you insert it, you get Quick Info for the item.
In the member list, the icon to the left represents the type of the member, such as namespace, class, function, or
variable. For a list of icons, see Class View and Object Browser Icons. The list may be quite long, so you can press
PAGE UP and PAGE DOWN to move up or down in the list.

You can invoke the List Members feature manually by typing CTRL+J, clicking Edit/IntelliSense/List
Members , or clicking the List Members button on the editor toolbar. When it is invoked on a blank line or
outside a recognizable scope, the list displays symbols in the global namespace.
To turn List Members off by default (so that it does not appear unless specifically invoked), go to
Tools/Options/All Languages and deselect Auto list members . If you want to turn off List Members only
for a specific language, go to the General settings for that language.
You can also change to suggestion mode, in which only the text you type is inserted into the code. For example,
if you enter an identifier that is not in the list and press TAB, in completion mode the entry would replace the
typed identifier. To toggle between completion mode and suggestion mode, press CTRL+ALT+SPACEBAR or click
Edit/IntelliSense/Toggle Completion Mode .
Parameter Info
Parameter Info gives you information about the number, names, and types of parameters required by a method,
attribute generic type parameter (in C#), or template (in C++).
The parameter in bold indicates the next parameter that is required as you type the function. For overloaded
functions, you can use the UP and DOWN arrow keys to view alternative parameter information for the function
overloads.

When you annotate functions and parameters with XML Documentation comments, the comments will display
as Parameter Info. For more information, see Supplying XML Code Comments.
You can manually invoke Parameter Info by clicking Edit IntelliSense/Parameter Info , typing
CTRL+SHIFT+SPACE, or clicking the Parameter Info button on the editor toolbar.

Quick Info
Quick Info displays the complete declaration for any identifier in your code.

When you select a member from the List Members box, Quick Info also appears.

You can manually invoke Quick Info by clicking Edit/IntelliSense/Quick Info , typing CTRL+I, or clicking the
Quick Info button on the editor toolbar.
If a function is overloaded, IntelliSense may not display information for all forms of the overload.
You can turn Quick Info off In C++ by setting Tools/Options/Text Editor/C/C++/Advanced/Auto Quick
Info to false .

Complete Word
Complete Word completes the rest of a variable, command, or function name once you have entered enough
characters to disambiguate the term. You can invoke Complete Word by clicking Edit/IntelliSense/Complete
Word , typing CTRL+SPACE, or clicking the Complete Word button on the editor toolbar.

IntelliSense Options
IntelliSense options are on by default. To turn them off, click Tools/Options/Text Editor and deselect
Parameter information or Auto list members if you do not want the List Members feature.

Troubleshooting IntelliSense
The IntelliSense options may not work as you expect in certain cases.
The cursor is below a code error. You might not be able to use IntelliSense if an incomplete function or other
error exists in the code above the cursor because IntelliSense might not be able to parse the code elements. You
can resolve this problem by commenting out the applicable code.
The cursor is in a code comment. You can't use IntelliSense if the cursor is in a comment in your source file.
The cursor is in a string literal. You can't use IntelliSense if the cursor is in the quotation marks around a
string literal, as in the following example:

MessageBox( hWnd, "String literal|") )

The automatic options are turned off. By default, IntelliSense works automatically, but you can disable it.
Even if automatic statement completion is disabled, you can invoke an IntelliSense feature.

See Also
Visual Basic-Specific IntelliSense Visual C# IntelliSense JavaScript IntelliSense Supplying XML Code Comments
Visual Basic-Specific IntelliSense
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Visual Basic source code editor offers the following IntelliSense features:
Syntax tips
Syntax tips display the syntax of the statement that you are typing. This is useful for statements such as
Declare.

Automatic Completion
Completion on various keywords
For example, if you type goto and a space, IntelliSense will display a list of the defined labels in a drop-
down menu. Other supported keywords include Exit , Implements , Option , and Declare .
Completion on Enum and Boolean

When a statement will refer to a member of an enumeration, IntelliSense will display a list of the members
of the Enum . When a statement will refer to a Boolean , IntelliSense will display a true-false drop-down
menu.
Completion can be turned off by default by deselecting Auto list members from the General property
page in the Visual Basic folder.
You can manually invoke completion by invoking List Members, Complete Word, or ALT+RIGHT ARROW.
For more information, see Using IntelliSense.

IntelliSense in Zone
IntelliSense in Zone assists Visual Basic developers who need to deploy applications through ClickOnce and are
constrained to partial trust settings. This feature:
Enables you to choose the permissions the application will run with.
Display APIs in the chosen Zone as available in List Members, and display APIs that require additional
permissions as unavailable.
For more information, see Code Access Security for ClickOnce Applications.

See Also
Using IntelliSense
Filtered Completion Lists in Visual Basic
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In Visual Basic, IntelliSense completion lists have two tab controls located near the bottom of the lists. The
Common tab, which is selected by default, displays items that are most often used to complete the statement that
you are writing. The All tab displays all items that are available for automatic completion, including those that are
also on the Common tab.

See Also
Using IntelliSense Visual Basic-Specific IntelliSense
Visual C# IntelliSense
10/18/2019 • 8 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Visual C# IntelliSense is available when coding in the editor, and while you debugging in the Immediate Mode
command window.

Completion Lists
The IntelliSense completion lists in Visual C# contain tokens from List Members, Complete Word, and more. It
provides quick access to:
Members of a type or namespace,
Variables, commands, and functions names,
Code snippets,
Language Keywords,
Extension Methods
The Completion List in C# is also smart enough to filter out irrelevant tokens and pre-select a token based
on context. For more information, see Filtered Completion Lists in C# and Pre-selected Completion List
Items in C#.
Code Snippets in Completion Lists
In Visual C#, the completion list includes code snippets to help you easily insert predefined bodies of code into
your program. Code snippets appear in the completion list as the snippet's Shortcut Element (Intellisense Code
Snippets). For more information about code snippets that are available in Visual C# by default, see Visual C# Code
Snippets.
Language Keywords in Completion Lists
In Visual C#, the completion list also includes language keywords. For more information about C# language
keywords, see C# Keywords.
Extension Methods in Completion Lists
In Visual C#, the completion list includes Extension Methods that are in scope.

NOTE
The completion list does not display all extension methods for String objects.

Extension methods use a different icon than instance methods. For a listing of list icons, see Class View and Object
Browser Icons. When an instance method and extension method with the same name are both in scope, the
completion list displays the extension method icon.
Filtered Completion Lists
IntelliSense removes unnecessary members from the completion list by using filters.
Visual C# filters the completion lists that appear for these items:
Interfaces and base classes. IntelliSense automatically removes items from the interface and base class
completion lists, in both class declaration base and interface lists and constraint lists. For example, enums
do not appear in the completion list for base classes, because enums cannot be used for base classes. The
completion list of base classes only contains interfaces and namespaces. If you select an item in the list and
then type a comma, IntelliSense removes base classes from the completion list because Visual C# does not
support multiple inheritance. The same behavior occurs for constraint clauses also.
Attributes : When you apply an attribute to a type, the completion list is filtered so that the list only
contains those types that descend from the namespaces that contain those types, such as Attribute.
as and is operators.
Catch clauses.
Object Initializers: Only members that can be initialized will appear in the completion list.
new keyword : When you type new and then press the SPACEBAR, a completion list appears. An item is
automatically selected in the list, based on the context in your code. For example, items are automatically
selected in the completion list for declarations and for return statements in methods.
as and is Operators: A filtered completion list is displayed automatically when you press the SPACEBAR
after you have typed the as or is keyword.
Events: When you type the keyword event , the completion list only contains delegate types.
Parameter help automatically sorts to the first method overload that matches the parameters as you enter
them. If multiple method overloads are available, you can use the up and down arrows to navigate to the
next possible overload in the list.

Most recently used members


IntelliSense remembers the members that you have recently selected in the pop-up List Members box for
automatic object name completion. The next time you use Member List, the most recently used members are
shown at the top. The history of most recently used members is cleared between each session in the IDE.

override
When you type override and then press SPACEBAR, IntelliSense displays all of the valid base class members that
you can override in a pop-up list box. Typing the return type of the method after override will prompt IntelliSense
to only show methods that return the same type. When IntelliSense cannot find any matches, it will display all of
the base class members.

Automatic Code Generation


Add using
The Add using IntelliSense operation enables you to maintain your focus on the code you are writing rather than
requiring you to shift your focus to another part of the code.
To initiate the Add using operation, position the cursor on a type reference that cannot be resolved. For example,
when you create a console application and then add XmlTextReader to the body of the Main method, a smart tag
will appear under the rightmost character of XmlTextReader , since it appears as a type reference that cannot be
resolved.
You can then invoke the Add using by selecting it from Resolve submenu of the IntelliSense menu or the context
menu, or by invoking Add using through the smart tag. The smart tag is only visible when the cursor is positioned
on, or adjacent to, the unbound type.

Organize usings
The Organize Usings options sort and remove using and extern declarations without changing the behavior
of the source code. Over time, source files may become bloated and difficult to read because of unnecessary and
unorganized using directives. The Organize Usings options compact source code by removing unused using
directives and improves readability by sorting them.
To see the available options in the Visual Studio IDE, on the Edit menu, point to IntelliSense , and then point to
Organize Usings . The IDE provides the following options to organize and remove usings directives:
Implement Interface
IntelliSense provides an option to help you implement an interface while working in the Code Editor. Normally, to
implement an interface properly you must create a method declaration for every member of the interface in your
class. Using IntelliSense, after you type the name of an interface in a class declaration, a smart tag is displayed. The
smart tag gives you the option to implement the interface automatically, using explicit or implicit naming. Under
explicit naming, the method declarations carry the name of the interface; under implicit naming, the method
declarations do not indicate the interface to which they belong. An explicitly named interface method can only be
accessed through an interface instance, and not through a class instance. For more information, see Explicit
Interface Implementation.
Implement Interface will generate the minimum number of method stubs that is required to satisfy the interface. If
a base class implements parts of the interface, then those stubs are not regenerated.
Implement abstract base class
IntelliSense provides an option to help you implement members of an abstract base class automatically while
working in the Code Editor. Normally, to implement members of an abstract base class requires creating a new
method definition for each method of the abstract base class in your derived class. Using IntelliSense, after typing
the name of an abstract base class in a class declaration, a smart tag is displayed. The smart tag gives you the
option to implement the base class methods automatically.
The method stubs that are generated by the Implement Abstract Base Class feature are modeled by the code
snippet defined in the file MethodStub.snippet. Code Snippets are modifiable. For more information, see
Walkthrough: Creating a Code Snippet.
Generate from usage
The Generate From Usage feature enables you to use classes and members before you define them. You can
generate a stub for any class, constructor, method, property, field, or enum that you want to use but have not yet
defined. You can generate new types and members without leaving your current location in code. This minimizes
interruption to your workflow.
A wavy underline appears under each undefined identifier. When you rest the mouse pointer on the identifier, an
error message appears in a tooltip.
To display the appropriate options, you can use one of the following procedures:
Click the undefined identifier. A short underline appears under the leftmost character. Rest the mouse
pointer on the short underline, and a smart tag (an icon) appears. Click the smart tag.
Click the undefined identifier, and then press CTRL+. (period).
Right-click the undefined identifier, and then click Generate .
The options that appear can include the following:
Generate proper ty stub
Generate field stub
Generate method stub
Generate class
Generate new type (for a class, struct, interface, or enum)

Generate event handlers


In the Code Editor, IntelliSense can help you hook up methods (event handlers) to event fields.
When you type the += operator after an event field in a .cs file, IntelliSense prompts you with the option to press
the TAB key. This inserts a new instance of a delegate that points to the method handling the event.

If you press TAB, IntelliSense automatically finishes the statement for you and displays the event handler reference
as selected text in the Code Editor. To complete the automatic event hookup, IntelliSense prompts you to press the
TAB key again to create an empty stub for the event handler.

NOTE
If a new delegate that is created by IntelliSense references an existing event handler, IntelliSense communicates this
information in the tooltip. You can then modify this reference; the text is already selected in the Code Editor. Otherwise,
automatic event hookup is complete at this point.

If you press TAB, IntelliSense stubs out a method with the correct signature and puts the cursor in the body of your
event handler.

NOTE
Use the Navigate Backward command on the View menu (CTRL+-) to go back to the event hookup statement.

The following task shows how IntelliSense automatically hooks up an event handler named button1_Click to an
event field named button1.Click .

See Also
Visual Studio IDE
Walkthrough: Test-First Support with the Generate
From Usage Feature
10/18/2019 • 9 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This topic demonstrates how to use the Generate From Usage feature, which supports test-first development.
Test-first development is an approach to software design in which you first write unit tests based on product
specifications, and then write the source code that is required to make the tests succeed. Visual Studio supports
test-first development by generating new types and members in the source code when you first reference them in
your test cases, before they are defined.
Visual Studio generates the new types and members with minimal interruption to your workflow. You can create
stubs for types, methods, properties, fields, or constructors without leaving your current location in code. When you
open a dialog box to specify options for type generation, the focus returns immediately to the current open file
when the dialog box closes.
The Generate From Usage feature can be used with test frameworks that integrate with Visual Studio. In this topic,
the Microsoft Unit Testing Framework is demonstrated.

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following
instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more
information, see Personalizing the IDE.

To create a Windows Class Library project and a Test project


1. In Visual C# or Visual Basic, create a new Windows Class Library project. Name it GFUDemo_VB or GFUDemo_CS
, depending on which language you are using.
2. In Solution Explorer , right-click the solution icon at the top, point to Add , and then click New Project . In
the New Project dialog box, in the Project Types pane on the left, click Test .
3. In the Templates pane, click Unit Test Project and accept the default name of UnitTestProject1. The
following illustration shows the dialog box when it appears in Visual C#. In Visual Basic, the dialog box looks
similar.
New
Project dialog box
4. Click OK to close the New Project dialog box.
5. In your class project, in Solution Explorer , right-click the References entry and click Add Reference .
6. In the Reference Manager dialog box, select Projects and then select your unit test project.
7. Click OK to close the Reference Manager dialog box.
8. In the Class1 file, immediately after the last of the existing using statements, add a using statement for the
test project:
In Visual Basic, add Using UnitTestProject1

In C#, add using UnitTestProject1;

9. Save your solution. You are now ready to begin writing tests
To generate a new class from a unit test
1. The test project contains a file that is named UnitTest1. Double-click this file in Solution Explorer to open it
in the Code Editor. A test class and test method have been generated.
2. Locate the declaration for class UnitTest1 and rename it to AutomobileTest . In C#, if a UnitTest1()
constructor is present, rename it to AutomobileTest() .

NOTE
IntelliSense now provides two alternatives for IntelliSense statement completion: completion mode and suggestion
mode. Use suggestion mode for situations in which classes and members are used before they are defined. When an
IntelliSense window is open, you can press CTRL+ALT+SPACEBAR to toggle between completion mode and
suggestion mode. See Using IntelliSense for more information. Suggestion mode will help when you are typing
Automobile in the next step.

3. Locate the TestMethod1() method and rename it to DefaultAutomobileIsInitializedCorrectly() . Inside this


method, create a new instance of a class named Automobile , as shown in the following illustrations. A wavy
underline appears, which indicates a compile-time error, and a smart tag appears under the type name. The
exact location of the smart tag varies, depending on whether you are using Visual Basic or Visual C#.
Visual Basic

Visual C#
4. Rest the mouse pointer over the smart tag to see an error message that states that no type named
Automobile is defined yet. Click the smart tag or press CTRL+. (CTRL+period) to open the Generate From
Usage shortcut menu, as shown in the following illustrations.

Visual Basic

Visual C#
5. Now you have two choices. You could click Generate 'Class Automobile' to create a new file in your test
project and populate it with an empty class named Automobile . This is a quick way to create a new class in a
new file that has default access modifiers in the current project. You can also click Generate new type to
open the Generate New Type dialog box. This provides options that include putting the class in an existing
file and adding the file to another project.
Click Generate new type to open the Generate New Type dialog box, which is shown in the following
illustration. In the Project list, click GFUDemo_VB or GFUDemo_CS to instruct Visual Studio to add the file
to the source code project instead of the test project.

Generate New Type dialog box


6. Click OK to close the dialog box and create the new file.
7. In Solution Explorer , look under the GFUDemo_VB or GFUDemo_CS project node to verify that the new
Automobile.vb or Automobile.cs file is there. In the Code Editor, the focus is still in
AutomobileTest.DefaultAutomobileIsInitializedCorrectly . You can continue to write your test with a
minimum of interruption.
To generate a property stub
1. Assume that the product specification states that the Automobile class has two public properties named
Model and TopSpeed . These properties must be initialized with default values of "Not specified" and -1
by the default constructor. The following unit test will verify that the default constructor sets the properties
to their correct default values.
Add the following line of code to DefaultAutomobileIsInitializedCorrectly .

Assert.IsTrue((myAuto.Model == "Not specified") && (myAuto.TopSpeed == -1));

Assert.IsTrue((myAuto.Model = "Not specified") And (myAuto.TopSpeed = -1))

Because the code references two undefined properties on Automobile , a smart tag appears. Click the smart
tag for Model and then click Generate proper ty stub . Generate a property stub for the TopSpeed
property also.
In the Automobile class, the types of the new properties are correctly inferred from the context.
The following illustration shows the smart tag shortcut menu.

Visual Basic

Visual C#
To locate the source code
1. Use the Navigate To feature to navigate to the Automobile.cs or Automobile.vb source code file so that you
can verify that the new properties have been generated.
The Navigate To feature enables you to quickly enter a text string, such as a type name or part of a name,
and go to the desired location by clicking the element in the result list.
Open the Navigate To dialog box by clicking in the Code Editor and pressing CTRL+, (CTRL+comma). In the
text box, type automobile . Click the Automobile class in the list, and then click OK .
The Navigate To window is shown in the following illustration.
Navigate To window
To generate a stub for a new constructor
1. In this test method, you will generate a constructor stub that will initialize the Model and TopSpeed
properties to have values that you specify. Later, you will add more code to complete the test. Add the
following additional test method to your AutomobileTest class.

[TestMethod]
public void AutomobileWithModelNameCanStart()
{
string model = "Contoso";
int topSpeed = 199;
Automobile myAuto = new Automobile(model, topSpeed);
}

<TestMethod()> Public Sub AutomobileWithModelNameCanStart()


Dim model As String = "Contoso"
Dim topSpeed As Integer = 199
Dim myAuto As New Automobile(model, topSpeed)
End Sub

2. Click the smart tag under the new class constructor and then click Generate constructor stub . In the
Automobile class file, notice that the new constructor has examined the names of the local variables that are
used in the constructor call, found properties that have the same names in the Automobile class, and
supplied code in the constructor body to store the argument values in the Model and TopSpeed properties.
(In Visual Basic, the _model and _topSpeed fields in the new constructor are the implicitly defined backing
fields for the Model and TopSpeed properties.)
3. After you generate the new constructor, a wavy underline appears under the call to the default constructor in
DefaultAutomobileIsInitializedCorrectly . The error message states that the Automobile class has no
constructor that takes zero arguments. To generate an explicit default constructor that does not have
parameters, click the smart tag and then click Generate constructor stub .
To generate a stub for a method
1. Assume that the specification states that a new Automobile can be put into a Running state if its Model and
TopSpeed properties are set to something other than the default values. Add the following lines to the
AutomobileWithModelNameCanStart method.

myAuto.Start();
Assert.IsTrue(myAuto.IsRunning == true);
myAuto.Start()
Assert.IsTrue(myAuto.IsRunning = True)

2. Click the smart tag for the myAuto.Start method call and then click Generate method stub .
3. Click the smart tag for the IsRunning property and then click Generate proper ty stub . The Automobile
class now contains the following code.

public class Automobile


{
public string Model { get; set; }
public int TopSpeed { get; set; }

public Automobile(string model, int topSpeed)


{
this.Model = model;
this.TopSpeed = topSpeed;
}

public Automobile()
{
// TODO: Complete member initialization
}

public void Start()


{
throw new NotImplementedException();
}

public bool IsRunning { get; set; }


}

Public Class Automobile


Sub New(ByVal model As String, ByVal topSpeed As Integer)
_model = model
_topSpeed = topSpeed
End Sub
Sub New()
' TODO: Complete member initialization
End Sub

Property Model() As String


Property TopSpeed As Integer
Property IsRunning As Boolean
Sub Start()
Throw New NotImplementedException
End Sub
End Class

To run the tests


1. On the Unit Test menu, point to Run Unit Tests , and then click All Tests . This command runs all tests in all
test frameworks that are written for the current solution.
In this case, there are two tests, and they both fail, as expected. The DefaultAutomobileIsInitializedCorrectly
test fails because the Assert.IsTrue condition returns False . The AutomobileWithModelNameCanStart test fails
because the Start method in the Automobile class throws an exception.
The Test Results window is shown in the following illustration.
Test Results window
2. In the Test Results window, double-click on each test result row to go to the location of each test failure.
To implement the source code
1. Add the following code to the default constructor so that the Model , TopSpeed and IsRunning properties
are all initialized to their correct default values of "Not specified" , -1 , and True ( true ).

public Automobile()
{
this.Model = "Not specified";
this.TopSpeed = -1;
this.IsRunning = true;
}

Sub New()
Model = "Not specified"
TopSpeed = -1
IsRunning = True
End Sub

2. When the Start method is called, it should set the IsRunning flag to true only if the Model or TopSpeed
properties are set to something other than their default value. Remove the NotImplementedException from
the method body and add the following code.

public void Start()


{
if (this.Model != "Not specified" || this.TopSpeed != -1)
this.IsRunning = true;
else
this.IsRunning = false;
}

Sub Start()
If Model <> "Not specified" Or TopSpeed <> -1 Then
IsRunning = True
Else
IsRunning = False
End If
End Sub

To run the tests again


1. On the Test menu, point to Run , and then click All Tests in Solution . This time the tests pass. The Test
Results window is shown in the following illustration.

Test Results window

See Also
Generate From Usage Writing Code Using IntelliSense Unit Test Your Code
JavaScript IntelliSense
1/10/2020 • 10 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

IntelliSense helps you write code faster and with fewer errors by providing information while you code. As you
work with client script in the JavaScript editor, IntelliSense lists the objects, functions, properties, and parameters
that are available based on your current context. You can select a coding option from the pop-up list provided by
IntelliSense to complete the code.
IntelliSense makes it easier to complete the following tasks:
Find member information.
Insert language elements directly into your code.
Maintain your context without having to leave the code editor.
Support custom IntelliSense with XML documentation comments and JavaScript IntelliSense extensibility.
This topic contains the following sections:
Determining IntelliSense Context
Processing IntelliSense Information
JavaScript IntelliSense Features
JavaScript IntelliSense Extensibility
JavaScript Validation
For more information about the IntelliSense functionality of Visual Studio, see Using IntelliSense.

Determining IntelliSense Context


JavaScript IntelliSense provides coding choices based on all script that is relevant to your current script context.
This includes scripting elements in the current file. It also includes any code that is referenced directly or indirectly
from your script, such as script file references, assembly script references, service references, and page-
associated references.
Your current script context is created based on the following items:
Functions that are defined in all script blocks in the active document. Inline script blocks are supported in
files that have the file-name extensions .aspx., .ascx, .master, .html, and .htm.
script elements with src attributes that point to another script file. The target script file must have the
file-name extension .js.
JavaScript files that reference other JavaScript files by using a reference directive.
Reference groups for global objects, IntelliSense extensions, or delay-loaded script files.
References to XML Web services.
The ScriptManager and ScriptManagerProxy controls, if the Web application is an AJAX-enabled ASP.NET
application.
The Microsoft Ajax Library, if you are working in an AJAX-enabled ASP.NET Web application.

NOTE
IntelliSense is not supported for script that is in event-handler attributes on HTML elements, or that is defined in
href attributes.

Processing IntelliSense Information


To provide JavaScript IntelliSense, the language service performs the following operations:
Creates a list of dependent JavaScript files that are based on references in the active document, and based
on recursively examining script references in the referenced files.
Traverses the list and collects type information and other relevant data from each file.
Aggregates the data and passes it to the JavaScript language service, which makes the type information
and data available to IntelliSense.
Monitors the files for changes that might affect the IntelliSense list and updates the list as needed. Scripts
on remote stores (such as those referenced using HTTP) do not get monitored.

JavaScript IntelliSense Features


JavaScript IntelliSense supports the following objects:
Document Object Model (DOM) elements
Intrinsic objects
User-defined variables, functions, and objects
Objects defined in external files using references such as script references, reference directives, and
reference groups.
Objects defined in remote files that are downloaded by Visual Studio.
Objects specified in XML documentation comments, such as parameters and fields.
Objects described using standard JavaScript comment tags (//). For more information, see Extending
JavaScript IntelliSense.
Objects supported using the JavaScript IntelliSense Extensibility mechanism. For more information, see
Extending JavaScript IntelliSense.
ASP.NET AJAX objects
When IntelliSense is unable to determine the type of an object, it provides options for statement
completion using identifiers in the active document. For more information, see Statement Completion for
Identifiers.
HTML DOM Elements
JavaScript IntelliSense provides programming references for Dynamic HTML (DHTML) DOM elements, such as
body , form , and div . Only the elements that are included in the current document and master page are
displayed by IntelliSense. JavaScript IntelliSense also supports the window and document objects and their
members.
Intrinsic Objects
JavaScript IntelliSense provides programming references for intrinsic objects such as Array , String , Math ,
Date , and Number . For more information about intrinsic objects, see Standard built-in objects.

User-defined Variables, Functions, and Objects


When you change a JavaScript file, Visual Studio scans opened and referenced documents to determine all
available code resources. This includes the variables, functions, and objects that you have created. These
resources are then available to JavaScript IntelliSense.
For more information about user-defined variables, functions, and objects, see Creating Your Own Objects on the
MSDN website.
External File References
You can include various types of external file references to achieve IntelliSense support in your code. External file
references may be script references, reference directives, or they can be specified using reference groups.
Script References
Instead of writing all client script in a page, you can reference external files that include scripting code. This makes
it easier for you to reuse code between pages, and it enables client script to be cached by the browser.
If you are not working with an ASP.NET AJAX-enabled Web page, you can reference an external script file by using
the src attribute in the opening tag of a script element. The src attribute specifies the URL to an external file
that contains the source code or data.
The following example shows markup that uses the src attribute in a < script > tag to reference a script file.

<script type="text/javascript" src="~/Scripts/JavaScript.js">

</script>

If you are working with an ASP.NET AJAX-enabled Web page, you can reference script files by using the
ScriptReference object of the ScriptManager control.
The following example shows markup that uses a ScriptReference object in a ScriptManager control to reference
a script file.

<asp:ScriptManager ID="ScriptManager1" runat="server">


<Scripts>
<asp:ScriptReference Path="~/Scripts/JavaScript.js" />
</Scripts>
</asp:ScriptManager>

IntelliSense also supports script files that are embedded as resources in an assembly in ASP.NET AJAX Web
applications. For more information about embedded script resources, see Walkthrough: Embedding a JavaScript
File as a Resource in an Assembly.
Reference Directives
A reference directive enables Visual Studio to establish a relationship between the script you are currently
editing and other scripts. The reference directive lets you include a script file in the scripting context of the
current script file. This enables IntelliSense to reference externally defined functions, types, and fields as you code.
You create a reference directive in the form of an XML comment. The directive must be declared earlier in the
file than any script. A reference directive can include a disk-based script reference, an assembly-based script
reference, a service-based script reference, or a page-based script reference.
The following example shows examples of using disk-based reference directives. In the first example, the
language service looks for the file in the same folder that contains the project file (for example, .jsproj).
/// <reference path="ScriptFile1.js" />

/// <reference path="Scripts/ScriptFile2.js" />

/// <reference path="../ScriptFile3.js" />

/// <reference path="~/Scripts/ScriptFile4.js" />

The following example shows how to create a reference to an assembly-based script.


/// <reference name "Ajax.js" assembly="System.Web.Extensions, ..." />

The following example shows how to reference service-based script:


/// <reference path="MyService.asmx" />

/// <reference path="Services/MyService.asmx" />

/// <reference path="../MyService.asmx" />

/// <reference path="~/Services/MyService.asmx" />

NOTE
JavaScript IntelliSense is not supported for script that is contained in Web service (.asmx) files in Web Application Projects
(WAP).

The following example shows how to reference page-based script.


/// <reference path="Default.aspx" />

/// <reference path="Admin/Default.aspx" />

/// <reference path="../Default.aspx" />

/// <reference path="~/Admin/Default.aspx" />

The following rules apply to a reference directive.


The reference XML comment must be declared before any script.
You must use XML comments syntax with three slashes. References made by using standard comments
syntax (two slashes) are ignored.
Only one file or resource can be specified per directive.
Multiple references to page-based scripts are not allowed.
If a page reference is specified, no other type of reference directives is allowed.
File names use relative paths. You can use the tilde operator ( ~ ) to make application-root-relative paths.
Absolute paths are ignored.
Reference directives in referenced pages will not be processed—that is, reference directives are not
resolved recursively for pages. Only script that is referenced directly by the page is included.
Reference Groups
You can use predefined reference groups to specify that particular IntelliSense .js files are in scope for different
JavaScript projects. The following reference group types are available:
Implicit (Windows), for Windows 8.x Store apps using JavaScript. Files included in this group are in scope
for every .js file opened in the Code Editor for the project of the specified type.
Implicit (Web), for HTML5 projects. Files included in this group are in scope for every .js file opened in the
Code Editor for these project types.
Dedicated worker reference groups, for HTML5 Web Workers. Files specified in this group are in scope for
.js files that have an explicit reference to a dedicated worker reference group.
Generic, for other JavaScript project types.
In most scenarios, you don't have to modify reference groups. However, if you want to make changes, you
can use configuration options for the JavaScript Code Editor to specify the files included in the reference
groups. For instructions about using this feature, see Options, Text Editor, JavaScript, IntelliSense.

TIP
The IntelliSense references are typically used to provide IntelliSense support for global objects and for IntelliSense
extensions. You can also use this feature for scripts that must be loaded at runtime using the script loader.

Remote File References


You can instruct Visual Studio to download remote JavaScript files that are referenced in a JavaScript file in order
to provide IntelliSense support for the remote file or library. When you use this feature, files will download when
you include them as a reference in your JavaScript file.

NOTE
Except for Web projects, this feature works only for JavaScript files that are opened outside the context of a project. For
Web projects, remote files referenced in your project are downloaded by default.

For instructions about using this feature, see Options, Text Editor, JavaScript, IntelliSense.

WARNING
If you enable this feature and you observe slower performance in the Code Editor, we recommend that you disable it.

XML Documentation Comments


XML documentation comments are text descriptions of code elements that you add to script. These text
descriptions are displayed in IntelliSense when you reference the commented script. For example, you can
provide information about a function's parameters and return value. XML documentation comments are available
only from referenced files, assemblies, and services. For more information, see XML Documentation Comments
and Create XML Documentation Comments.
IntelliSense can display XML documentation comments in the following scenarios:
A .js file that references another .js file.
A .js file that references an .aspx file.
An .aspx file that references a .js file.
IntelliSense is not available when one .aspx file references another .aspx file.
ASP.NET AJAX Objects
ASP.NET AJAX also supports JavaScript IntelliSense. ASP.NET AJAX includes a client framework that extends the
standard types that are available in ECMAScript (JavaScript). To enable JavaScript IntelliSense to provide details
about ASP.NET AJAX objects, XML documentation comments have been added throughout the Microsoft Ajax
Library. These XML documentation comments are displayed when you use types and members that are contained
in the ASP.NET AJAX Library.

NOTE
Private members are not displayed by JavaScript IntelliSense. Private members are denoted in ASP.NET AJAX as members
that begin with an underscore (_).

JavaScript IntelliSense Extensibility


The JavaScript language service provides objects and functions that enable you to modify the IntelliSense
experience for developers who use third-party libraries. These features are especially useful when the default
language service isn't able to provide all the information that you want to provide to customers. For more
information, see Extending JavaScript IntelliSense.

JavaScript Validation
JavaScript scripting validation occurs constantly in the background. When Visual Studio detects syntax errors in
the JavaScript code, feedback is provided in the following ways:
Underlined elements in the editor. Wavy red underlines indicate errors. If you hold the mouse pointer over
the error, a tooltip displays the error description.
Error List window. The Error List window displays the error description, the file where the error
occurred, the line and column number, and the project. To display the Error List window, in the View
menu, click Error List .
The Output window shows references that were not loaded.

See Also
Using IntelliSense
Create XML Documentation Comments
Extending JavaScript IntelliSense
Statement Completion for Identifiers
XML Documentation Comments
About the DHTML Object Model
List Members
SRC Attribute | src Property
Create JSDoc Comments for JavaScript IntelliSense
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

IntelliSense in Visual Studio displays information that you add to a script using standard JSDoc comments. You can
use JSDoc comments to provide information about code elements such as functions, fields, and variables.

JSDoc Comment Tags


The following standard JSDoc comment tags are used by IntelliSense to display information about your code.

JSDO C TA G SY N TA X N OT ES

@deprecated @deprecated description Specifies a deprecated function or


method.

@description @description description Specifies the description for a function


or method.

@param @param {type} Specifies information for a parameter in


parameterNamedescription a function or method.

TypeScript also supports @paramTag.

@property @property {type} propertyName Specifies information, including a


description, for either a field or member
that's defined on an object.

@returns @returns {type} Specifies a return value.

For TypeScript, use @returnType instead


of @returns.

@summary @summary description Specifies the description for a function


or method (same as @description).

@type @type {type} Specifies the type for a constant or a


variable.

@typedef @typedef {type} customTypeName Specifies a custom type.

Examples
The following example shows the use of the @description, @param, and @return JSDoc tags for a function named
getArea .
/** @description Determines the area of a circle that has the specified radius parameter.
* @param {number} radius The radius of the circle.
* @return {number}
*/
function getArea(radius) {
var areaVal;
areaVal = Math.PI * radius * radius;
return areaVal;
}

In the preceding example, IntelliSense shows the description, parameter, and return information when you type the
opening parenthesis for getArea .

The following example shows how to use the @typedef tag with the @property tag.

/**
* @typedef {object} Weather
* @property {string} current The current weather.
*/
function getForecast(Weather) {
}

var w = new Weather();

The following example shows the use of the @type JSDoc tags. As shown in this example, single asterisks (*) that
follow the initial asterisk pair (**) are not required.

/**
@type {string}
*/
const RED = 'FF0000';

The following example shows how to use the @deprecated JSDoc tag.

/**
* @deprecated since version 2.0
*/
function old() {
}
Create XML Documentation Comments for
JavaScript IntelliSense
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

XML documentation comments are JavaScript comments that you add to a script to provide information about
code elements such as functions, fields, and variables. In Visual Studio, these text descriptions are displayed with
IntelliSense when you reference the script function.
This topic provides a basic tutorial on using XML documentation comments. For information about using other
elements, such as <var> and <value>, and for additional code examples, see XML Documentation Comments. For
information about providing IntelliSense information for an asynchronous callback such as a Promise , see
<returns>.

NOTE
XML documentation comments are available only from referenced files, assemblies, and services.

To create XML documentation comments for a JavaScript function


In the function, add <summary>, <param>, and <returns> elements, and precede each element with three
slash marks (///).

NOTE
Each element must be on a single line.

The following example shows a JavaScript function.

function getArea(radius)
{
/// <summary>Determines the area of a circle that has the specified radius parameter.</summary>
/// <param name="radius" type="Number">The radius of the circle.</param>
/// <returns type="Number">The area.</returns>
var areaVal;
areaVal = Math.PI * radius * radius;
return areaVal;
}

To view the XML documentation comments, type the name and the opening parenthesis of a function that is
marked with XML documentation comments, as in the following example:

var areaVal = getArea(

When you type the opening parenthesis of the function that contains the XML documentation comments,
the Code Editor uses IntelliSense to display the information that is defined in XML documentation
comments.
To create XML Documentation comments for a JavaScript field
In a constructor function or object definition, add a <field> element preceded by three slash marks (///).
The following example shows the use of the <field> element in a constructor function. For additional
examples, see <field>.

function Engine() {
/// <field name='HorsePower' type='Number'>The engine's horsepower.</field>
this.HorsePower = 150;
}

To view the XML documentation comments, create an object by using the function constructor that is
marked with XML documentation comments, as in the following example.

var eng = new Engine();

On the next line, type the name of the object and a period to show IntelliSense information for the field.

eng.

To create XML documentation comments for an overloaded function


1. In the function, add a <signature> element for each overload. In these elements, add other elements, such
as <summary> , <param> , and <returns> , preceding each element with three slash marks (///).
The following example shows an overloaded JavaScript function. In this example, the overloads differ by
parameter type.

function calc(a) {
/// <signature>
/// <summary>Function summary 1.</summary>
/// <param name="a" type="Number">A number.</param>
/// <returns type="Number" />
/// </signature>
/// <signature>
/// <summary>Function summary 2.</summary>
/// <param name="a" type="String">A string.</param>
/// <returns type="Number" />
/// </signature>
return a;
}

2. To view the XML documentation comments, type the name and the opening parenthesis of the function that
is marked with XML documentation comments, as in the following example:

calc(

To create localized IntelliSense


1. Create an XML file that has documentation comments in the OpenAjax MessageBundle format.
IMPORTANT
MessageBundle is the recommended format. This format is not supported in Microsoft Ajax or in .winmd files. For
information about using the alternative VSDoc format, see <loc>.

The following example shows content in a sidecar file that contains the localized IntelliSense information.
This is an XML file that's located in a culture-specific folder, like JA. The folder must be in the same location
as the .js file that contains the <loc> element. The file name of the XML file must match the filename
parameter specified in the <loc> element.

<messagebundle>
<msg name="1">A class that represents a rectangle</msg>
<msg name="2">The length of the rectangle</msg>
<msg name="3">The height of the rectangle</msg>
</messagebundle>

2. In your .js file, add the following code. The <loc> element must be declared before any script, and follows
the same usage rules as the <reference> element. For more information, see JavaScript IntelliSense and
<loc>.

/// <loc filename="messageFilename.xml" format="messagebundle"/>

3. In your .js file, add the XML documentation elements and default descriptions. Set the locid attribute
values to match the corresponding name attribute values from the sidecar file. The default descriptions will
be replaced by localized IntelliSense information, if it's available.

function add(a,b)
{
/// <summary locid='1'>description</summary>
/// <param name='a' locid='2'>parameter a description</param>
/// <param name='b' locid='3'>parameter b description</param>
}

4. To view the XML documentation comments, type the name and the opening parenthesis of the function, as
in the following example:

add(

See Also
JavaScript IntelliSense XML Documentation Comments NIB: Walkthrough: JavaScript IntelliSense in ASP.NET
Extending JavaScript IntelliSense
10/18/2019 • 21 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The JavaScript IntelliSense extensibility feature enables you to customize IntelliSense results in the JavaScript
editor for third-party libraries. This can improve the experience of developers who use these libraries.
The JavaScript language service provides IntelliSense features for third-party JavaScript libraries that are added to
a project. For most libraries, statement completion is provided automatically by the language service. The
following illustration shows an example of statement completion:

If your library includes descriptions of variables, functions, and objects in standard JavaScript comment tags (//),
you automatically benefit, by default, from IntelliSense extensibility features, which provide descriptive
information in a pop-up box that appears to the right of elements in a completion list, or when you type the
opening parenthesis in a function call. The comments in the pop-up box contain the description of the member.
The following example shows the pop-up box for a completion list.

To further improve the developer experience, you might want to provide type information to developers in the
pop-up box. You can provide type information by using JavaScript XML Documentation Comments instead of
standard comment tags. You add XML Documentation Comments by using triple-slash comment tags (///) and a
defined set of XML elements.
Alternatively, you can provide type information by using JavaScript IntelliSense extensibility. This feature enables
you to customize IntelliSense results by creating JavaScript extensions and adding them to the script context. In
the extension, which is a JavaScript file, you subscribe to events that are exposed by the intellisense object of
the language service. JavaScript IntelliSense extensibility is the preferred solution for libraries if a behavior pattern
in the library prevents the JavaScript language service from providing the desired level of IntelliSense support,
and if an alternative to declarative XML Documentation Comments is also needed. By customizing the IntelliSense
results, you can create a first-class IntelliSense experience, regardless of any behavioral patterns that might restrict
the language service's default capabilities. For more information, see Statement Completion for Identifiers.

Adding an Extension to the Script Context


For an IntelliSense extension to be executed, it needs to be added to the current script context. The extension can
be automatically added to the script context by the automatic discovery mechanism, or you can add the extension
to the script context manually by using reference groups or the reference directive.
The automatic discovery mechanism enables the language service to automatically find extensions that follow the
file naming convention libraryname.intellisense.js, and that are located in the same directory as the library to
which the extension applies. For example, a valid extension for the jQuery library would be jQuery.intellisense.js.
For more restrictive jQuery extensions, you can use file names such as jQuery-1.7.1.intellisense.js (a version-
specific extension) or jQuery.ui.intellisense.js (an extension for a scoped jQuery library). The most restrictive
version of the extension is used if more than one extension is found for a given library.
If you want to use the extension for all your JavaScript project files, you might instead choose to add the extension
to a reference group. There are several types of reference groups, either those that include implicit references and
those that include dedicated worker references. To add an extension, you typically need to add the file as an
implicit reference group, either Implicit (Windows) , Implicit (Web) . Implicit references are in scope for every .js
file opened in the Code Editor. When you use this method, you need to add both the extension and the file that the
extension is supplementing.
Use the IntelliSense page of the Options dialog box to add an extension as a reference group. You can access
the IntelliSense page by choosing Tools , Options on the menu bar, and then choosing Text Editor , JavaScript ,
IntelliSense , References . For more information about reference groups, see JavaScript IntelliSense and Options,
Text Editor, JavaScript, IntelliSense.
If you want to use the extension for a specific set of files, use a reference directive. When you use this method, you
need to reference both the extension and the file the extension is supplementing. For information about using the
reference directive, see JavaScript IntelliSense.

Handling IntelliSense events


The extensibility feature enables you to customize IntelliSense results by subscribing to events such as the
statementcompletion event of the language service intellisense object. The following example shows a simple
extension that's used by the language service to hide members that begin with an underscore from statement
completion. This code is contained in underscorefilter.js and is in the \\Visual Studio installation
path\JavaScript\References folder.
intellisense.addEventListener('statementcompletion', function (event) {
if (event.targetName === "this") return;

var filterRegex;

if (event.target === undefined || event.target === window)


filterRegex = /^_.*\d{2,}/;
else
filterRegex = /^_.*/;

event.items = event.items.filter(function (item) {


return !filterRegex.test(item.name);
});
});

In the preceding code, the extension checks the targetName Property and target Property properties of the
statementcompletion event object to exclude objects such as this and window , and to ensure that a valid
statement completion list can be identified. If a completion list can be identified, the extension updates the
statement completion items Property collection by filtering out members that begin with an underscore.
For additional examples, look in the \\Visual Studio installation path\JavaScript\References folder. The
showPlainComments.js file in this folder provides examples of using other events to provide default IntelliSense
support for standard JavaScript comment tags (//). Like underscorefilter.js, showPlainComments.js is already
available as a working extension, and you can see the resulting IntelliSense information when using comment tags
in your code for variables, functions, and objects. For additional examples, see Code Examples.

WARNING
If you modify the extension files included with Visual Studio, you may disable JavaScript IntelliSense or the feature supported
by the extension.

In your extension code, you can create handlers for the following event types by using addEventListener :
statementcompletion , which adds a handler for a statement completion event. Statement completion
provides a list of members for a particular type that appears after you type a special character such as a
period (.), or a list of identifiers that appears while you type or when you press CTRL + J. The handler
receives an event object of type CompletionEvent , which supports the following members: items Property,
target Property, targetName Property, and scope Property.
signaturehelp , which adds a handler for IntelliSense Parameter Info. Parameter information gives you
information about the number, names, and types of parameters required by a function. The handler
receives an event object of type SignatureHelpEvent , which supports the following members: target
Property, parentObject Property, functionComments Property, functionHelp Property.
statementcompletionhint , which adds a handler for IntelliSense Quick Info. The Quick Info pop-up box
shows the complete declaration for identifiers in your code. The handler receives an event object of type
CompletionHintEvent , which supports the following members: completionItem Property, and symbolHelp
Property.
For examples that show IntelliSense features such as statement completion, parameter information, and
Quick Info, see Using IntelliSense.
NOTE
In JavaScript, Quick Info refers to the pop-up box that appears to the right of a completion list. You cannot manually invoke
Quick Info.

intellisense Object
The following table shows the functions that are available for the intellisense object. The intellisense object is
available only at design time.

F UN C T IO N DESC RIP T IO N

addEventListener(type, handler); Adds an event handler for an IntelliSense event.

type is a string value. Valid values include


statementcompletion , signaturehelp , and
statementcompletionhint .

handler is an event handler function that receives an event


object of one of the following types:

- CompletionEvent , used for the statementcompletion


event.
- SignatureHelpEvent , used for the signaturehelp event.
- CompletionHintEvent , used for the
statementcompletionhint event.

For examples that use this function, see Code Examples.

annotate(obj, doc); Specifies documentation for an object by copying


documentation comments from one object to another object.

obj specifies the object to which to copy the


documentation.

doc specifies the object from which to copy the


documentation.

For an example that shows how to use this function, see


Adding IntelliSense Annotations.
F UN C T IO N DESC RIP T IO N

getFunctionComments(func); Returns the comments for a specified function.

func specifies the function for which comments are


returned.

You can set the func parameter by using


completionItem.value .

The returned functionComments object includes the


following members: above , inside , and paramComment .
For more information, see the functionComments Property
property.

getFunctionComments can be called only from within one of


the event handlers that are registered by addEventListener
.

For an example that shows how to use this function, see


\\Visual Studio installation
path\JavaScript\References\showPlainComments.js.

logMessage(msg); Sends diagnostic messages to the Output window.

msg is a string that contains the message.

For an example that shows how to use this function, see


Sending Messages to the Output Window.

nullWithCompletionsOf(value); Returns a special null value for which the completion list is
determined by the object passed in the value parameter.

value determines the completion list for the returned value.


value can be any type.

The null return value is treated as null at design-time, but the


completion list for the return value is the same as the
completion list for the value parameter.

One use for this function is to provide IntelliSense for a return


value when the return type is predictable at runtime, but the
return value is null at design-time.

redirectDefinition(func, definition); Instructs IntelliSense to use the provided definition function


instead of the original func function when parameter help or
Go To Definition is requested.

func specifies the target function.

definition specifies the function to be used instead of the


target function for parameter information and Go To
Definition .
F UN C T IO N DESC RIP T IO N

setCallContext(func, thisArg); Sets the call context, or scope, for the specified function.

func specifies the function for which to set the scope.

thisArg is an object literal to which the this keyword can


refer to, which specifies the new scope for the member. You
can include arguments to pass in this parameter, for example,
intellisense.setCallContext(func, { thisArg: "",
args: [23,2] });

setCallContext provides behavior similar to


Function.prototype.bind , except that it used only for
design-time IntelliSense support. You can use
setCallContext to set the function scope if you need to
simulate a call to code that is not otherwise reachable, so that
when you call the function, the function call will include the
correct scope and arguments.

undefinedWithCompletionsOf(value); Returns a special undefined value for which the completion list
is determined by the object passed in the value parameter.

value determines the completion list for the returned value.


value can be any type.

The undefined return value is treated as undefined at design-


time, but the completion list for the return value is the same
as the completion list for the value parameter.

One use for this function is to provide IntelliSense for a return


value when the return type is predictable at runtime, but the
return value is undefined at design-time.

version() Returns the Visual Studio version.

Event Members
The following sections describe the members that are exposed in the event object for the following events:
statementcompletion , signaturehelp , and statementcompletionhint .

completionItem Property
Returns the identifier, known as the completion item, for which a Quick Info pop-up box is requested. This
property is available for the statementcompletionhint event object and for the items Property property of the
statementcompletion event object.

Return value: completionItem object


Following are the members of the completionItem object:
name . Read/write when used in the items collection; otherwise, read-only. Returns a string that identifies
the completion item.
kind . Read/write when used in the items collection; otherwise, read-only. Returns a string that represents
the type of completion item. The possible values are method, field, property, parameter, variable, and
reserved.
glyph . Read/write when used in the items collection; otherwise, read-only. Returns a string that
represents an icon that's displayed in the completion list. The possible values for glyph use the following
format: vs:glyphType, where glyphType corresponds to the language-independent members in the
StandardGlyphGroup enumeration. For example, vs:GlyphGroupMethod is one possible value for glyph .
When glyph is not set, the kind property determines the default icon.
parentObject . Read-only. Returns the parent object.
value . Read-only. Returns an object that represents the value of the completion item.
comments . Read-only. Returns a string that contains the comments that are above the field or variable.
. Read-only. Returns the scope of the completion item. The possible values are global, local,
scope
parameter, and member.
items Property
Gets or sets the array of statement completion items. Each element in the array is a completionItem Property
object. The items property is available for the statementcompletion event object.
Return value: array
functionComments Property
Returns the comments for the function. This property is available for the signaturehelp event object.
Return value: comments object
Following are the members of the comments object:
above . Returns the comments above the function.
inside . Returns the comments inside the function, typically in VSDoc format.
paramComments . Returns an array representing comments for each parameter in the function. The members
of the array include:
name . Returns a string representing the parameter name.
comment . Returns a string that contains the parameter comment.
functionHelp Property
Returns the Help for the function. This property is available for the signaturehelp event object.
Return value: functionHelp object
Following are the members of the functionHelp object:
functionName . Read/write. Returns a string that contains the function name.
signatures. Read/write. Gets or sets the array of function signatures. Each element in the array is a
signature object. Some signature properties, such as locid , correspond to common XML
Documentation Comments attributes.
The members of the signature object include:
description . Read/write. Returns a string that describes the function.
locid . Read/write. Returns a string identifier that contains localization information about the
function.
helpKeyword . Read/write. Returns a string that contains the Help keyword.
externalFile . Read/write. Returns a string that represents the file that contains the member ID.
externalid . Read/write. Returns a string that represents the member ID of the function.
params . Read/write. Gets or sets the array of parameters for the function. Each element in the
parameters array is a parameter object that has properties that correspond to the following
attributes of the <param> element:
name . Read/write. Returns a string that represents the parameter name.
type . Read/write. Returns a string that represents the parameter type.
elementType . Read/write. If the type is Array , returns a string that represents the type of the
elements in the array.
description . Read/write. Returns a string that describes the parameter.
locid . Read/write. Returns a string identifier that contains localization information about the
function.
optional . Read/write. Returns a string that indicates whether the parameter is optional. true
indicates that the parameter is optional; false indicates that it isn't.
returnValue . Read/write. Gets or sets a return value object with properties that correspond to the
following attributes of the <returns> element:
type . Read/write. Returns a string that represents the return type.
elementType . Read/write. If the type is Array , returns a string that represents the type of the
elements in the array.
description . Read/write. Returns a string that describes the return value.
locid . Read/write. Returns a string identifier that contains localization information about the
function.
helpKeyword . Read/write. Returns a string that contains the Help keyword.
externalFile . Read/write. Returns a string that represents the file that contains the member
ID.
externalid . Read/write. Returns a string that represents the member ID of the function.
parentObject Property
Returns the parent object of a member function. For example, for document.getElementByID , parentObject returns
the document object. This property is available for the signaturehelp event object.
Return value: object
target Property
Returns an object that represents the item to the left of the trigger character, which is a period (.). For functions,
target returns the function for which Parameter Info is requested. This property is available for the
statementcompletion and signaturehelp event objects.

Return value: object


targetName Property
Returns a string that represents the target. For example, for "this.", targetName returns "this". For "A.B" (when the
cursor is after "B"), targetName returns "B". This property is available for the statementcompletion event object.
Return value: string
symbolHelp Property
Returns the completion item for which a Quick Info pop-up box is requested. This property is available for the
statementcompletionhint event object.

Return value: symbolHelp object.


Some properties of the symbolHelp object, such as locid , correspond to common XML Documentation
Comments attributes.
Following are the members of the symbolHelp object:
name . Read/write. Returns a string that contains the identifier name.
symbolType. Read/write. Returns a string that represents the symbol type. Possible values include Unknown,
Boolean, Number, String, Object, Function, Array, Date, and Regex.
symbolDisplayType . Read/write. Returns a string that contains the type name to display. If
symbolDisplayType isn't set, symbolType is used.

elementType . Read/write. If the symbolType is Array , returns a string that represents the type of the
elements in the array.
scope . Read/write. Returns a string that represents the scope of the symbol. Possible values include global,
local, parameter, and member.
description . Read/write. Returns a string that contains a description of the symbol.
locid . Read/write. Returns a string identifier that contains localization information about the symbol.
helpKeyword . Read/write. Returns a string that contains the Help keyword.
externalFile . Read/write. Returns a string that represents the file that contains the member ID.
externalid . Read/write. Returns a string that represents the member ID of the symbol.
functionHelp . Read/write. Returns a functionHelp Property, which might contain information when the
symbolType is Function.
scope Property
Returns the completion scope of the event. The possible values for the completion scope are global and members.
This property is available for the statementcompletion event object.
Return value: string

Debugging IntelliSense extensions


You can't debug extensions, but you can use the intellisense Object function to send information to the Visual
Studio Output window. For an example that shows how to use this function, see Sending Messages to the Output
Window later in this topic. For logMessage to work, at least one event handler must be registered in an extension.

Code Examples
This section includes code examples that show how to use the IntelliSense extensibility APIs. There are also other
ways to use these APIs. For additional examples, see the following files in the \\Visual Studio installation
path\JavaScript\References folder. These are working examples used by the JavaScript language service.
underscoreFilter.js. This code hides private members from IntelliSense. It includes event handlers for the
statementcompletion event.
showPlainComments.js. This code provides IntelliSense support for standard comments. It includes event
handlers for the signaturehelp and statementcompletionhint events.
Adding IntelliSense Annotations
The following procedure shows how to provide IntelliSense documentation support for a third-party library
without modifying the library directly. To do this, you can use intellisense.annotate in an extension.
For this example to work, you need the following JavaScript files in your project:
demoLib.js, which is a project file that represents a third-party library.
demoLib.intellisense.js, which is the IntelliSense extension. This file doesn't need to be included in the
project, but it does need to be in the same folder as exampleLib.js.
appCode.js, which is a project file that represents app code.
To a d d a n I n t e l l i Se n se a n n o t a t i o n

1. Add the following code to demoLib.js.

function someFunc(a) { };
var rectangle;

2. Add the following code to demoLib.intellisense.js.

intellisense.annotate(someFunc, function (a) {


/// <signature>
/// <summary>Description of someFunc</summary>
/// <param name="a">Param a</param>
/// </signature>
});

intellisense.annotate(window, {
// This is a comment on a global variable named rectangle.
rectangle: undefined
});

3. Add the following reference directive as the first line in appCode.js. The path used here indicates that the
JavaScript files are in the same folder.

/// <reference path="demoLib.js" />

4. In appCode.js, type the following code. You'll see the XML documentation comments in the extension
displayed as IntelliSense Parameter Info.

5. In appCode.js, type the following code. While you type, you'll see the standard comments in the extension
displayed as IntelliSense Quick Info.
Sending Messages to the Output Window
The following procedure shows how to send messages to the Output window. You can send messages to help
debug IntelliSense extensions.
For this example to work, you need the following JavaScript files in your project:
exampleLib.js, which is a project file that represents a third-party library.
exampleLib.intellisense.js, which is the IntelliSense extension. This file doesn't need to be included in the
project, but it does need to be in the same folder as exampleLib.js.
appCode.js, which is a project file that represents app code.
To se n d a m e ssa g e t o t h e O u t p u t w i n d o w

1. Add the following code to exampleLib.js.

var someVar = {
a: 1,
b: 'hello'
};

2. Add the following code to exampleLib.intellisense.js.

intellisense.addEventListener('statementcompletion', function (e) {


// Prints out statement completion info: Either (1) the member
// list, if the trigger character was typed, or (2) the
// statement completion identifiers.
// e.target represents the object left of the trigger character.
intellisense.logMessage(
e.target ? 'member list requested, target: ' + e.targetName : 'statement completion for current
scope requested');

// Prints out all statement completion items.


e.items.forEach(function (item) {
intellisense.logMessage('[completion item] ' + item.name + ', kind:' + item.kind + ', scope:' +
item.scope + ', value:' + item.value);
});
});

3. Add the following reference directive as the first line in appCode.js. The path used here indicates that the
JavaScript files are in the same folder.

/// <reference path="exampleLib.js" />

4. In the Output window, choose JavaScript Language Ser vice in the Show output from list. (To view the
Output window, select Output from the View menu.)
5. In appCode.js, type the following code. While you type, the Output window shows messages from the
language service. The first message in the Output window indicates that statement completion for the
current scope has been requested.

some

Following is a partial view of the output you should see.


03:16:14.3113: statement completion for current scope requested
03:16:14.3113: [completion item] break, kind:reserved, scope:undefined, value:undefined
03:16:14.3113: [completion item] case, kind:reserved, scope:undefined, value:undefined
03:16:14.3113: [completion item] catch, kind:reserved, scope:undefined, value:undefined

6. Choose the Clear All button in the Output window.


7. Type the following code. The first message in the output window indicates that a member list has been
requested.

someVar.

Following is a partial view of the output you should see:

03:17:43.4032: member list requested, target: someVar


03:17:43.4032: [completion item] a, kind:field, scope:member, value:1
03:17:43.4032: [completion item] b, kind:field, scope:member, value:hello
03:17:43.4032: [completion item] constructor, kind:method, scope:member, value:

Changing the IntelliSense icons


The following procedure shows how to change the icons displayed by IntelliSense by default. This might be useful
when you provide IntelliSense information about library-specific concepts such as namespaces, classes, interfaces,
and enumerations.
For available icon values, see StandardGlyphGroup.
For this example to work, you need the following JavaScript files in your project:
exampleLib.js, which is a project file that represens a third-party library.
exampleLib.intellisense.js, which is the IntelliSense extension. This file doesn't need to be included in the
project, but it does need to be in the same folder as exampleLib.js.
appCode.js, which is a project file that represents app code.
To c h a n g e t h e i c o n s

1. Add the following code to exampleLib.js.

function Namespace(name) {
this._isNamespace = true;
window[name] = this;
};

function Enum(values) {
var e = Object.create(values);
e._isEnum = true;
return e;
};

var SomeNamespace = new Namespace('SomeNamespace');


// A constructor function is considered a class.
SomeNamespace.SomeClass1 = function () { }
SomeNamespace.Enum1 = new Enum({ VALUE1: 0, VALUE2: 1 });

2. Add the following code to exampleLib.intellisense.js.


intellisense.addEventListener('statementcompletion', function (e) {
e.items.forEach(function (item) {
// Detect a namespace by using the _isNamespace flag.
if (item.value && item.value._isNamespace) {
item.glyph = 'vs:GlyphGroupNamespace';
}

if (item.parentObject && item.parentObject._isNamespace) {


// The item is a member of a namespace.

// All constructor functions that are part of a namespace


// are considered classes.
// A constructor function starts with
// an uppercase letter by convention.
if (typeof item.value == 'function' && (item.name[0].toUpperCase()
== item.name[0])) {
item.glyph = 'vs:GlyphGroupClass';
}

// Detect an enumeration by using the _isEnum flag.


if (item.value && item.value._isEnum) {
item.glyph = 'vs:GlyphGroupEnum';
}
}
});
});

intellisense.addEventListener('statementcompletionhint', function (e) {


if (e.completionItem.value) {
if (e.completionItem.value._isNamespace) {
e.symbolHelp.symbolDisplayType = 'Namespace';
}
if (e.completionItem.value._isEnum) {
e.symbolHelp.symbolDisplayType = 'Enum';
}
}
});

3. Add the following reference directive as the first line in appCode.js. The path used here indicates that the
JavaScript files are in the same folder.

/// <reference path="exampleLib.js" />

4. In appCode.js, type the following code. While you type, you'll see that the icon for the namespace has
changed to "{}", as is used in C#.

5. In appCode.js, type the following code. While you type, you'll see a new enumeration icon for the Enum1
member, and a new class icon for the SomeClass1 member.
Avoiding run-time effects on IntelliSense results
The JavaScript language service runs code to dynamically provide IntelliSense information. As a result, run-time
behavior can occasionally interfere with desired results. The following procedure shows how to override
IntelliSense results when run-time behavior results in incorrect IntelliSense.
For this example to work, you need the following JavaScript files in your project:
exampleLib.js, which is a project file that represents a third-party library.
exampleLib.intellisense.js, which is the IntelliSense extension. This file doesn't need to be included in the
project, but it does need to be in the same folder as exampleLib.js.
appCode.js, which is a project file that represents app code.
To a v o i d r u n - t i m e e ffe c t s o n I n t e l l i Se n se r e su l t s

1. Add the following code to exampleLib.js.

function after(count, func) {


return function () {
if (--times < 1) {
return func.apply(this, arguments);
}
};
};

In the preceding code, the wrapped function ignores initial calls, based on the value of count , and doesn't
return results.
2. Add the following reference directive as the first line in appCode.js. The path used here indicates that the
JavaScript files are in the same folder.

/// <reference path="exampleLib.js" />

3. In appCode.js, type the following code. The identifier list appears instead of IntelliSense because the
wrapped function is never called, which means that the throttled function doesn't return any results.

4. Add the following code to exampleLib.intellisense.js. This will change the design-time behavior so that
IntelliSense is shown for the wrapped function, as expected.
window.after = function (count, func) {
// Just return func.
return func;
};

5. In appCode.js, test the results by typing the same code that you typed previously. This time, IntelliSense
provides the desired information.

See Also
JavaScript IntelliSense Statement Completion for Identifiers
Statement Completion for Identifiers
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

JavaScript doesn't allow explicit typing for variable declarations. As a result, IntelliSense can't always provide
completion lists for objects. This can occur in various situations. Following are a few common ones.
A parameter is declared, but it has not been called elsewhere in the active document, as shown in the
following example.

function illuminate(light) {
light. // Accurate statement completion is not available
// unless illuminate is called elsewhere with a
// parameter that has a value. If it is called only
// in a function that is a sibling to
// illuminate(light) in the call hierarchy, the
// IntelliSense engine also cannot determine the
// parameter type.
}

// Sibling function. No statement completion for light


// object in preceding code.
function lightLamp() {
var x = illuminate(1);
}

// Uncomment the next line to obtain statement completion for


// light object in preceding code.
// var x = illuminate(1);

An object is in a function that is called in response to an event. At design time, the IntelliSense engine
cannot determine the type of the objects used in this situation.
If the IntelliSense engine can determine that the event should be called, typically through the use of
addEventListener for the event in the active document, more accurate IntelliSense information is provided.

When IntelliSense is unable to identify an object, the IntelliSense engine populates the completion list with
named entities, or identifiers, that are present in the active document. When the completion list contains
these identifiers, information icons appear next to them. In addition, a tooltip for each identifier indicates
that the expression is unknown. The following illustration shows statement completion options for an
object of type light that can't be identified because the object and its properties are undefined. However,
the intensity property is available in the identifier list because it has been used in the illuminate
function.
Completion options for an object that can't be identified
You can override the completion list for an object by using XML documentation comments or JavaScript
IntelliSense extensibility features. Using these features, you can provide type information and more
descriptive IntelliSense information when it might not otherwise be available. For more information, see
Extending JavaScript IntelliSense and Create XML Documentation Comments.

See Also
JavaScript IntelliSense
Customizing IntelliSense for RequireJS
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Starting with Visual Studio 2013 Update 4, support for the popular RequireJS JavaScript file and modular loader is
supported. RequireJS makes it easier to define dependencies between code modules and to dynamically load
modules only when needed. When writing JavaScript code that uses RequireJS, IntelliSense suggestions will be
provided for modules that you’ve referenced from your module definition or referenced using calls to require()
from within your code.
By default, Visual Studio supports a very basic configuration to support RequireJS, but it is common practice to
setup your own custom configuration settings (that is, to define aliases for libraries). This topic describes the
different ways that you can customize Visual Studio to work with your project’s unique setup.
This topic describes how to:
Customize RequireJS in ASP.NET projects
Customize RequireJS in JSProj projects, which are used to build Apache Cordova apps, Windows Store apps,
and LightSwitch HTML apps

Customize RequireJS in ASP.NET projects


Support for RequireJS is automatically enabled when a file named require.js is referenced by your current
JavaScript file (For more information, see the Determining IntelliSense Context section in JavaScript IntelliSense). In
ASP.NET projects, referencing require.js is typically done using a /// <reference/> directive within a _references.js
file.
Configure the data-main attribute in an ASP.NET project
To accurately simulate how your app will work when you run it, the JavaScript editor needs to know what file to
load first when setting up require.js. This is typically configured in your application HTML file using the data-main
attribute on the script element that references require.js, as shown here.

<script src="js/require.js" data-main="js/app.js"></script>

In this example, the script referenced by data-main ( js/app.js) is loaded immediately after require.js. The file that is
loaded immediately is the best place to first configure RequireJS usage (using require.config() ).To tell the
JavaScript editor what file to use for data-main in your application, add a data-main attribute, and then modify a
/// <reference/> directive that references require.js in your application. For example, you can use this directive:

/// <reference path="js/require.js" data-main="js/app.js" />

Configure the application start page in an ASP.NET project


When the app runs, RequireJS assumes that relative paths to files (for example, "..\" paths) are relative to the HTML
file that loaded the require.js library. As you write code in the Visual Studio editor for an ASP.NET project, this start
page is unknown and you’ll need to tell the editor what start page to use when using relative file paths. To do this,
add a start-page attribute to your /// <reference/> directive.

/// <reference path="js/require.js" data-main="js/app.js" start-page="/app/index.html" />

The start-page attribute specifies the URL of the page as you would see it in a browser when running your app.

Customize RequireJS in JSProj projects


JSProj projects (project files ending in a .jsproj extension) are used when building apps for Apache Cordova, HTML-
based Windows Store Apps, or LightSwitch HTML apps. Unlike ASP.NET projects, these projects read references to
.js files from the HTML files that exist in the project. Because of this, when editing JavaScript in a JSProj project, you
will see support for RequireJS is enabled if the JavaScript file currently being edited is referenced in another HTML
file that also references require.js.
The customization steps needed for ASP.NET projects are not needed in a JSProj project file. That is, script files used
by the data-main attribute on the script tag that references require.js are loaded automatically to configure
require.js. The HTML file referencing require.js is also used as the start page for the application.

See Also
JavaScript IntelliSense
XML Documentation Comments (JavaScript)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In JavaScript you can create documentation for your code by including XML tags in special comment fields in the
source code. These XML tags are used by IntelliSense to provide information about JavaScript objects.
The location of the code comments varies depending on the specific tag.
The following tags are supported:
<deprecated>
<field>
<loc>
<param>
<returns>
<signature>
<summary>
<value>
<var>

See Also
JavaScript IntelliSense
<deprecated> (JavaScript)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Specifies a deprecated function or method.

Syntax
<deprecated
type="deprecate|remove"
locid="descriptionID">description
</deprecated>

Parameters
type Optional. Specifies whether the function or method will be removed in a future release, or whether the
function or method has already been removed and that its use may result in an error. Set to deprecate to specify
that the function or method will be removed in a future release. Set to remove to specify that the function or
method has already been removed.
locid Optional. The identifier for localization information about the function or method. The identifier is either a
member ID or it corresponds to the name attribute value in a message bundle defined by OpenAjax metadata. The
identifier type depends on the format specified in the <loc> element.
description Optional. A description of the function or method that is being deprecated.

Remarks
The elements used to annotate functions, which include <deprecated> , must be placed in the function body before
any statements. When you mark a function as deprecated, we recommend that you replace its <summary>
element with the <deprecated> element.

Example
The following code shows how to use the <deprecated> element.

function areaFunction(radiusParam) {
/// <deprecated type="deprecate" >Determines the area of a circle when supplied a radius parameter.
</deprecated>
/// <param name="radiusParam" type="Number">The radius of the circle.</param>
/// <returns type="Number">The area.</returns>
var areaVal;
areaVal = Math.PI * radiusParam * radiusParam;
return areaVal;
}
See Also
XML Documentation Comments
<field> (JavaScript)
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Specifies documentation information, including a description, for either a field or member that's defined on an
object.

Syntax
<field name="fieldName" static="true|false"
type="FieldType" integer="true|false"
domElement="true|false" mayBeNull="true|false"
elementType="ArrayElementType" elementInteger="true|false"
elementDomElement="true|false" elementMayBeNull="true|false"
helpKeyword="keyword" locid="descriptionID"
value="code">description
</field>

Parameters
name The name of the field or member. When the <field> element is used in a constructor function, name is
required and defines the member to which the tag applies. When the <field> element is directly annotating a
field, this attribute is ignored, and the name used by Visual Studio is the name of the actual field in the source
code.
static Optional. Specifies whether the field is a member of the constructor function or a member of the object
returned by the constructor function. Set to true to treat the field as a member of the constructor function. Set to
false to treat the field as a member of the object returned by the constructor function.

type Optional. The data type of the field. The type can be one of the following:
An ECMAScript language type in the ECMAScript 5 specification, such as Number and Object .
A DOM object, such as HTMLElement , Window , and Document .
A JavaScript constructor function.
integer Optional. If type is Number , specifies whether the field is an integer. Set to true to indicate that
the field is an integer; otherwise, set to false . This attribute is not used by Visual Studio to provide
IntelliSense information.
domElement Optional. This attribute is deprecated; the type attribute takes precedence over this attribute.
This attribute specifies whether the documented field is a DOM element. Set to true to specify that the
field is a DOM element; otherwise, set to false . If the type attribute is not set and domElement is set to
true , IntelliSense treats the documented field as an HTMLElement when performing statement completion.

mayBeNull Optional. Specifies whether the documented field can be set to null. Set to true to indicate that
the field can be set to null; otherwise, set to false . The default value is false . This attribute is not used by
Visual Studio to provide IntelliSense information.
elementType Optional. If type is Array , this attribute specifies the type of the elements in the array.
elementInteger Optional. If type is Array and elementType is Number , this attribute specifies whether the
elements in the array are integers. Set to true to indicate that the elements in the array are integers;
otherwise, set to false . This attribute is not used by Visual Studio to provide IntelliSense information.
elementDomElement Optional. This attribute is deprecated; the elementType attribute takes precedence over
this attribute. If type is Array , this attribute specifies whether the elements in the array are DOM
elements. Set to true to specify that the elements are DOM elements; otherwise, set to false . If the
elementType attribute is not set and elementDomElement is set to true , IntelliSense treats each element in
the array as an HTMLElement when performing statement completion.
elementMayBeNull Optional. If type is Array , specifies whether the elements in the array can be set to null.
Set to true to indicate that the elements in the array can be set to null; otherwise, set to false . The default
value is false . This attribute is not used by Visual Studio to provide IntelliSense information.
helpKeyword Optional. The keyword for F1 help.
locid Optional. The identifier for localization information about the field. The identifier is either a member
ID or it corresponds to the name attribute value in a message bundle defined by OpenAjax metadata. The
identifier type depends on the format specified in the <loc> tag.
value Optional. Specifies code that should be evaluated for use by IntelliSense instead of the function code
itself. For <field> , this attribute is supported for constructor functions, but is not supported for object
literals. You can use this attribute is to provide type information when the field type is undefined. For
example, you can use value=’1’ to treat the field type as a number.
description Optional. A description for the field.

Remarks
The name attribute is required when you're documenting a field in a constructor function. For all other scenarios,
all attributes for the <field> element are optional.
When you're documenting a constructor function, the <field> element must appear immediately before the field
declaration. The name attribute must match the field name that's used in the source code. For object members, the
name attribute can be omitted if the <field> element appears immediately before the object member declaration.

Example
The following code example shows how to use the <field> element.
// Use of <field> in an object definition.
var Rectangle = {
/// <field type='Number'>The width of the rectangle.</field>
wid: 5,
/// <field type='Number'>The length of the rectangle.</field>
len: 0,
/// <field type='Number'>Returns the area of the rectangle.</field>
getArea: function (wid, len) {
return len * wid;
}
}

// Use of <field> in a constructor function.


// The name attribute is required.
function Engine() {
/// <field name='HorsePower' type='Number'>The engine's horsepower.</field>
this.HorsePower = 150;
}

Example
The following example shows how to use the <field> element with the static attribute set to true .

function Engine() {
/// <field name='HorsePower' static='true' type='Number'>static field desc.</field>
}

Engine.HorsePower = 140;
// IntelliSense on the field is available here.
Engine.

Example
The following example shows how to use the <field> element with the static attribute set to false .

function Engine() {
/// <field name='HorsePower' static='false' type='Number'>Non-static field desc.</field>
}

Engine.HorsePower = 140;
var eng = new Engine();
// IntelliSense on the field is available here.
eng.

Example
The following example shows how to use the <field> element with the value attribute.

function calculator(a) {
/// <field name='f' value='1'/>
}
new calculator().f. // Completion list for a Number.
See Also
XML Documentation Comments
<loc> (JavaScript)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Specifies the location and type of the sidecar file that provides localized IntelliSense information.

Syntax
<loc filename="filename"
format="vsdoc|messagebundle" />

Parameters
filename Optional. The root name of the sidecar file that contains localization information for the neutral culture.
When Visual Studio searches for localization information, it attempts to find a culture-specific version of this file.
For example, if filename is jquery.xml, Visual Studio searches for the correct culture-specific folder (like JA) in
the same location as the .js file that contains the <loc> element. If it locates the culture-specific folder, it checks
whether a jquery.xml file exists in it. If it cannot locate the correct file, it instead uses managed resource location
rules. The default value for filename is the name of the current file, but with an .xml extension instead of .js.
format Optional. The type of sidecar file used for localization. Use messagebundle to specify the use of message
bundles defined by Open Ajax metadata. messagebundle is the recommended format. However, this format is not
supported in Microsoft Ajax or in .winmd files. Use vsdoc to specify the standard .NET Framework localization
format that is used by Microsoft Ajax and Windows Runtime. This attribute is optional. vsdoc is the default
format.

Remarks
The <loc> element must appear at the top of the file in the same section as the <reference> element. Usage
rules for the <loc> element are the same as the <reference> element. For more information, see the
“References Directives” section in JavaScript IntelliSense.
Visual Studio processes a single <loc> element for each .js file. If multiple <loc> elements are present, only a
single <loc> element is used. Behavior for determining which <loc> element to use is not defined.
When using message bundle format, use the locid attribute in XML documentation comments to specify the
name attribute value.

Example
The following example shows how to use the <loc> element with messagebundle format. Add the following
XML to a file named messageFilename.xml and place the file in the correct culture-specific folder, as specified in
the description of the filename parameter.
<?xml version="1.0" encoding="utf-8" ?>
<messagebundle>
<msg name="1">A class that represents a rectangle</msg>
<msg name="2">The height of a rectangle</msg>
<msg name="3">The width of a rectangle</msg>
</messagebundle>

For the messagebundle example, add the following code to a JavaScript file in your project. The <loc> element
must appear as the first line in the JavaScript file. The descriptions in this code will be replaced by localized
descriptions, if available.

/// <loc filename="messageFilename.xml" format="messagebundle"/>

function doSomething(a,b)
{
/// <summary locid='1'>description</summary>
/// <param name='a' locid='2'>parameter a description</param>
/// <param name='b' locid='3'>parameter b description</param>
}

The following example uses VSDoc format. Add the following XML to a file named scriptFilename.xml and place
the file in the correct culture-specific folder.

<?xml version="1.0" encoding="utf-8" ?>


<doc>
<assembly>
<name>Lights</name>
</assembly>
<members>
<member name="M:illuminate">
<summary>Activates a light. </summary>
<param name='a'>The light to activate. </param>
</member>
</members>
</doc>

For the VSDoc example, add the following code to a JavaScript file in your project. The descriptions in this code
will be replaced by localized descriptions, if available.

/// <loc filename="scriptFilename.xml" format="vsdoc" />

function illuminate(a)
{
/// <summary locid='M:illuminate'>description</summary>
/// <param name='a' type='Number'>parameter a description</param>
}

See Also
XML Documentation Comments
<param> (JavaScript)
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Specifies documentation information for a parameter in a function or method.

Syntax
<param name="parameterName" type="ParameterType"
integer="true|false" domElement="true|false"
mayBeNull="true|false" elementType="ArrayElementType"
elementInteger="true|false" elementDomElement="true|false"
elementMayBeNull="true|false" locid="descriptionID"
parameterArray="true|false" optional="true|false"
value="code">description
</param>

Parameters
name Required. The name of the parameter.
type Optional. The data type of the parameter. The type can be one of the following:
An ECMAScript language type in the ECMAScript 5 specification, such as Number and Object .
A DOM object, such as HTMLElement , Window , and Document .
A JavaScript constructor function.
integer Optional. If type is Number , specifies whether the parameter is an integer. Set to true to indicate
that the parameter is an integer; otherwise, set to false . This attribute is not used by Visual Studio to
provide IntelliSense information.
domElement Optional. This attribute is deprecated; the type attribute takes precedence over this attribute.
This attribute specifies whether the documented parameter is a DOM element. Set to true to specify that
the parameter is a DOM element; otherwise, set to false . If the type attribute is not set and domElement
is set to true , IntelliSense treats the documented parameter as an HTMLElement when performing
statement completion.
mayBeNull Optional. Specifies whether the documented parameter can be set to null. Set to true to
indicate that the parameter can be set to null; otherwise, set to false . The default value is false . This
attribute is not used by Visual Studio to provide IntelliSense information.
elementType Optional. If type is Array , this attribute specifies the type of the elements in the array.
elementInteger Optional. If type is Array and elementType is Number , this attribute specifies whether the
elements in the array are integers. Set to true to indicate that the elements in the array are integers;
otherwise, set to false . This attribute is not used by Visual Studio to provide IntelliSense information.
elementDomElement Optional. This attribute is deprecated; the elementType attribute takes precedence over
this attribute. If type is Array , this attribute specifies whether the elements in the array are DOM
elements. Set to true to specify that the elements are DOM elements; otherwise, set to false . If the
elementType attribute is not set and elementDomElement is set to true , IntelliSense treats each element in
the array as an HTMLElement when performing statement completion.
elementMayBeNull Optional. If type is Array , specifies whether the elements in the array can be set to null.
Set to true to indicate that the elements in the array can be set to null; otherwise, set to false . The
default value is false . This attribute is not used by Visual Studio to provide IntelliSense information.
locidOptional. The identifier for localization information about the parameter. The identifier is either a
member ID or it corresponds to the name attribute value in a message bundle defined by OpenAjax
metadata. The identifier type depends on the format specified in the <loc> element.
parameterArray Optional. Specifies whether the documented parameter can be repeated in the function
call, similar to repeating parameters supported in the String.format function. Set to true to indicate that
the parameter can be repeated; otherwise, set to false . This attribute is not used by Visual Studio to
provide IntelliSense information.
optional Optional. Specifies whether the documented parameter is optional in the calling function. Set to
true to indicate that the parameter is optional; otherwise, set to false .
value Optional. Specifies code that should be evaluated for use by IntelliSense instead of the function code
itself. You can use this attribute is to provide type information when the parameter type is undefined. For
example, you can use value=’1’ to treat the parameter type as a number.
description Optional. A description of the parameter.

Remarks
The only required attribute is name . All other attributes are optional.
Elements used to annotate functions, such as <summary>, <param>, and <returns>, must be placed in the
function body before any statements.
If there are multiple <param> elements that have the same name, one of the <param> elements is used and the
redundant elements are ignored. The behavior that determines which element is used is not defined. If name
refers to a nonexistent parameter, the element is ignored.

Example
The following code example shows how to use the <param> element.
function areaFunction(radiusParam)
{
/// <summary>Determines the area of a circle when provided a radius parameter.</summary>
/// <param name="radiusParam" type="Number">The radius of the circle.</param>
/// <returns type="Number">The area.</returns>
var areaVal;
areaVal = Math.PI * radiusParam * radiusParam;
return areaVal;
}

// Uses of <param> with the value attribute.

function calculate(a) {
/// <param name='a' value='1'/>
a. // Completion list for a Number.
}

function calculate(a) {
/// <param name='a' value='{x:0,y:0}'/>
a. // x and y appear in the completion list.
}

See Also
XML Documentation Comments
<returns> (JavaScript)
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Specifies documentation information for the result of a function or method call.

Syntax
<returns type="ValueType" integer="true|false"
domElement="true|false" mayBeNull="true|false"
elementType="ArrayElementType" elementInteger="true|false"
elementDomElement="true|false" elementMayBeNull="true|false"
locid="descriptionID" value="code">description
</returns>

Parameters
type Optional. The data type of the return value. The type can be one of the following:
An ECMAScript language type in the ECMAScript 5 specification, such as Number and Object .
A DOM object, such as HTMLElement , Window , and Document .
A JavaScript constructor function.
integer Optional. If type is Number , specifies whether the return value is an integer. Set to true to
indicate that the return value is an integer; otherwise, set to false . This attribute is not used by Visual
Studio to provide IntelliSense information.
domElement Optional. This attribute is deprecated; the type attribute takes precedence over this attribute.
This attribute specifies whether the documented return value is a DOM element. Set to true to specify
that the return value is a DOM element; otherwise, set to false . If the type attribute is not set and
domElement is set to true , IntelliSense treats the documented return value as an HTMLElement when
performing statement completion.
mayBeNull Optional. Specifies whether the documented return value can be set to null. Set to true to
indicate that the return value can be set to null; otherwise, set to false . The default value is false . This
attribute is not used by Visual Studio to provide IntelliSense information.
elementType Optional. If type is Array , this attribute specifies the type of the elements in the array.
elementInteger Optional. If type is Array and elementType is Number , this attribute specifies whether
the elements in the array are integers. Set to true to indicate that the elements in the array are integers;
otherwise, set to false . This attribute is not used by Visual Studio to provide IntelliSense information.
elementDomElement Optional. This attribute is deprecated; the elementType attribute takes precedence over
this attribute. If type is Array , this attribute specifies whether the elements in the array are DOM
elements. Set to true to specify that the elements are DOM elements; otherwise, set to false . If the
elementType attribute is not set and elementDomElement is set to true , IntelliSense treats each element in
the array as an HTMLElement when performing statement completion.
Optional. If type is Array , specifies whether the elements in the array can be set to
elementMayBeNull
null. Set to true to indicate that the elements in the array can be set to null; otherwise, set to false . The
default value is false . This attribute is not used by Visual Studio to provide IntelliSense information.
Optional. The identifier for localization information about the return value. The identifier is either a
locid
member ID or it corresponds to the name attribute value in a message bundle defined by OpenAjax
metadata. The identifier type depends on the format specified in the <loc> tag.
Optional. Specifies code that should be evaluated for use by IntelliSense instead of the function
value
code itself. For example, you can use this attribute to provide IntelliSense for asynchronous callbacks, such
as a Promise . Using the value attribute with the <returns> element can improve IntelliSense
performance by bypassing lengthy code execution.
description Optional. A description of the return value.

Remarks
The <returns> element must be placed in the function body before any statements.

Example
The following code example shows how to use the <returns> element.

function areaFunction(radiusParam)
{
/// <summary>Determines the area of a circle when provided a radius parameter.</summary>
/// <param name="radiusParam" type="Number">The radius of the circle.</param>
/// <returns type="Number">The area.</returns>
var areaVal;
areaVal = Math.PI * radiusParam * radiusParam;
return areaVal;
}

// The following examples use the <remarks> element with a value attribute.

function getJson(complete) {
/// <returns value='complete("")' ></returns>
var r = new XMLHttpRequest();
// . . .
}

getJson(function (json) {
json. // IntelliSense for a String object is
// available here.
});

function calculate(x) {
/// <returns value='1'/>
}
calculate(). // Completion list for a Number.

See Also
XML Documentation Comments
<signature> (JavaScript)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Groups a set of related elements for a function or method to provide documentation for overloaded functions.

Syntax
<signature externalid="id" externalFile="filename"
helpKeyword="keyword" locid="descriptionID">
</signature>

Parameters
externalid Optional. If the format attribute for the <loc> element is vsdoc , this attribute specifies the member
ID used to locate the XML code that's associated with the signature. Unlike the locid attribute, this attribute
specifies that all elements in the member that has this ID should be loaded. Any associated description information
present in the XML code will also be merged with the elements specified in the signature. This enables you to
specify additional elements, such as <capability> , in the sidecar file without specifying them in the source file.
externalid is an optional attribute.

externalFile Optional. Specifies the name of the file in which to find the externalid . This attribute is ignored if
no externalid is present. This is an optional attribute. The default value is the name of the current file but with a
file extension of .xml instead of .js. By default, managed resource lookup rules for localization are used to locate the
file.
helpKeyword Optional. The keyword for F1 help.
locid Optional. The identifier for localization information about the field. The identifier is either a member ID or it
corresponds to the name attribute value in a message bundle defined by OpenAjax metadata. The identifier type
depends on the format specified in the <loc> tag.

Remarks
Use one <signature> element for each overloaded function description in the .js file, or use one <signature>
element for each external member ID specified.
The <signature> element must be placed in the function body before any statements. When using <summary>,
<param>, or <returns> elements with the <signature> element, place the other elements inside the <signature>
block.

Example
The following code example shows how to use the <signature> element.
// Use of <signature> with externalid.
// Requires use of the <loc> tag to identify the external functions.
function illuminate(light) {
/// <signature externalid='M:Windows.Devices.Light.Illuminate()' />
/// <signature externalid='M:Windows.Devices.Light.Illuminate(System.Int32)'>
/// <param name='light' type='Number' />
/// </signature>
}

// Use of <signature> for overloads implemented in JavaScript.


function add(a, b) {
/// <signature>
/// <summary>function summary 1</summary>
/// <param name="a" type="Number">The first number</param>
/// <param name="b" type="Number">The second number</param>
/// <returns type="Number" />
/// </signature>
/// <signature>
/// <summary>function summary 2 – differ by number of params</summary>
/// <param name="a" type="Number">Only 1 parameter</param>
/// <returns type="Number" />
/// </signature>
/// <signature>
/// <summary>function summary 3 – differ by parameter type</summary>
/// <param name="a" type="Number">Number parameter</param>
/// <param name="b" type="String">String parameter</param>
/// <returns type="Number" />
/// </signature>
/// <signature>
/// <summary>function summary 4 – differ by return type</summary>
/// <param name="a" type="Number">The first number</param>
/// <param name="b" type="Number">The second number</param>
/// <returns type="String" />
/// </signature>

return a + b;
}

See Also
XML Documentation Comments
<summary> (JavaScript)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Specifies the description for a function or method.

Syntax
<summary locid="descriptionID">description
</summary>

Parameters
locid Optional. The identifier for localization information about the function or method. The identifier is either a
member ID or it corresponds to the name attribute value in a message bundle defined by OpenAjax metadata.
The identifier type depends on the format specified in the <loc> element.
description Optional. A description of the function or method.

Remarks
The elements used to annotate functions, which include <summary>, <param>, and <returns>, must be placed
in the function body before any statements.

Example
The following code shows how to use the <summary> element.

function areaFunction(radiusParam)
{
/// <summary>Determines the area of a circle when supplied a radius parameter.</summary>
/// <param name="radiusParam" type="Number">The radius of the circle.</param>
/// <returns type="Number">The area.</returns>
var areaVal;
areaVal = Math.PI * radiusParam * radiusParam;
return areaVal;
}

See Also
XML Documentation Comments
<value> (JavaScript)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Specifies documentation information for get and set functions for ECMAScript 3 properties.

Syntax
<value type="ValueType" integer="true|false"
domElement="true|false" mayBeNull="true|false"
elementType="ArrayElementType" elementInteger="true|false"
elementDomElement="true|false" elementMayBeNull="true|false"
locid="descriptionID">description
</value>

Parameters
type Optional. The data type of the property. The type can be one of the following:
An ECMAScript language type that's in the ECMAScript 5 specification, such as Number and Object .
A DOM object, such as HTMLElement , Window , and Document .
A JavaScript constructor function.
integer Optional. If type is Number , specifies whether the property is an integer. Set to true to indicate
that the property is an integer; otherwise, set to false . This attribute is not used by Visual Studio to
provide IntelliSense information.
domElement Optional. This attribute is deprecated; the type attribute takes precedence over this attribute.
This attribute specifies whether the documented property is a DOM element. Set to true to specify that the
property is a DOM element; otherwise, set to false . If the type attribute is not set and domElement is set
to true , IntelliSense treats the documented property as an HTMLElement when performing statement
completion.
mayBeNull Optional. Specifies whether the documented property can be set to null. Set to true to indicate
that the property can be set to null; otherwise, set to false . The default value is false . This attribute is not
used by Visual Studio to provide IntelliSense information.
elementType Optional. If type is Array , this attribute specifies the type of the elements in the array.
elementInteger Optional. If type is Array and elementType is Number , this attribute specifies whether the
elements in the array are integers. Set to true to indicate that the elements in the array are integers;
otherwise, set to false . This attribute is not used by Visual Studio to provide IntelliSense information.
elementDomElement Optional. This attribute is deprecated; the elementType attribute takes precedence over
this attribute. If type is Array , this attribute specifies whether the elements in the array are DOM elements.
Set to true to specify that the elements are DOM elements; otherwise, set to false . If the elementType
attribute is not set and elementDomElement is set to true , IntelliSense treats each element in the array as an
HTMLElement when performing statement completion.
elementMayBeNull Optional. If type is Array , specifies whether the elements in the array can be set to null.
Set to true to indicate that the elements in the array can be set to null; otherwise, set to false . The default
value is false . This attribute is not used by Visual Studio to provide IntelliSense information.
locidOptional. The identifier for localization information about the property. The identifier is either a
member ID or it corresponds to the name attribute value in a message bundle defined by OpenAjax
metadata. The identifier type depends on the format specified in the <loc> element.
description Optional. A description of the property.

Remarks
ECMAScript 5 properties use the <summary> element.
Use the <value> element immediately before the get or set function.

Example
The following code example shows how to use the <value> element on a get function.

function Sys$CancelEventArgs$get_cancel() {
/// <value type="Boolean" locid="P:J#Sys.CancelEventArgs.cancel"></value>
if (arguments.length !== 0) throw Error.parameterCount();
return this._cancel();
}

See Also
XML Documentation Comments
<var> (JavaScript)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Specifies documentation information for a variable.

Syntax
<var type="ValueType" integer="true|false"
domElement="true|false" mayBeNull="true|false"
elementType="ArrayElementType" elementInteger="true|false"
elementDomElement="true|false" elementMayBeNull="true|false"
helpKeyword="keyword" locid="descriptionID">description
</var>

Parameters
type Optional. The data type of the variable. The type can be one of the following:
An ECMAScript language type that's in the ECMAScript 5 specification, such as Number and Object .
A DOM object, such as HTMLElement , Window , and Document .
A JavaScript constructor function.
integer Optional. If type is Number , specifies whether the variable is an integer. Set to true to indicate
that the variable is an integer; otherwise, set to false . This attribute is not used by Visual Studio to provide
IntelliSense information.
domElement Optional. This attribute is deprecated; the type attribute takes precedence over this attribute.
This attribute specifies whether the documented variable is a DOM element. Set to true to specify that the
variable is a DOM element; otherwise, set to false . If the type attribute is not set and domElement is set to
true , IntelliSense treats the documented variable as an HTMLElement when performing statement
completion.
mayBeNull Optional. Specifies whether the documented variable can be set to null. Set to true to indicate
that the variable can be set to null; otherwise, set to false . The default value is false . This attribute is not
used by Visual Studio to provide IntelliSense information.
elementType Optional. If type is Array , this attribute specifies the type of the elements in the array.
elementInteger Optional. If type is Array and elementType is Number , this attribute specifies whether the
elements in the array are integers. Set to true to indicate that the elements in the array are integers;
otherwise, set to false . This attribute is not used by Visual Studio to provide IntelliSense information.
elementDomElement Optional. This attribute is deprecated; the elementType attribute takes precedence over
this attribute. If type is Array , this attribute specifies whether the elements in the array are DOM elements.
Set to true to specify that the elements are DOM elements; otherwise, set to false . If the elementType
attribute is not set and elementDomElement is set to true , IntelliSense treats each element in the array as an
HTMLElement when performing statement completion.
elementMayBeNull Optional. If type is Array , specifies whether the elements in the array can be set to null.
Set to true to indicate that the elements in the array can be set to null; otherwise, set to false . The default
value is false . This attribute is not used by Visual Studio to provide IntelliSense information.
helpKeyword Optional. The keyword for F1 Help.
locidOptional. The identifier for localization information about the variable. The identifier is either a
member ID or it corresponds to the name attribute value in a message bundle defined by OpenAjax
metadata. The identifier type depends on the format specified in the <loc> tag.
description Optional. A description of the variable.

Example
The following code example shows how to use the <var> element.

/// <var>A rectangle that has a width of 5.</var>


var Rectangle = {
/// <field type = 'Number'>The width of the rectangle.</field>
wid: 5,
/// <field type = 'Number'>The length of the rectangle.</field>
len: 0,
/// <field type='Number'>Returns the area of the rectangle.</field>
getArea: function (wid, len) {
return len * wid;
}
}

See Also
XML Documentation Comments
Visual C++ Intellisense
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In Visual Studio 2015, IntelliSense is available for single code files as well as for files in projects. In cross-platform
projects, some IntelliSense features are available in .cpp and .c files in the shared code project even when you are in
an Android or iOS context.

IntelliSense features in C++


IntelliSense is a name given to a set of features that make coding more convenient. Since different people have
different ideas about what is convenient, virtually all of the IntelliSense features can be enabled or disabled in the
Text Editor, C/C++, Advanced property page.

You can use the menu items and keyboard shortcuts shown in the following image to access IntelliSense.
Statement completion and member list
When you start typing a keyword, type, function, variable name, or other program element that the compiler
recognizes, the editor offers to complete the word for you
For a list of the icons and their meanings, see Class View and Object Browser Icons.

The first time member list is invoked it only shows members that are accessible for the current context. If you use
Ctrl + J after that, it shows all members regardless of accessibility. If you invoke it a third time, an even wider list
of program elements is shown. You can turn off statement completion in the C/C++ General Options page.

Parameter Help
When you type an opening brace of a function call, or angle bracket on a class template variable declaration, the
editor shows a small window with the parameter types for each overload of the function or constructor. The
"current" parameter--based on the cursor location--is in bold. You can turn off Statement completion in the C/C++
General Options page.
Quick Info
When you hover the mouse cursor over a variable, a small window appears inline that shows the type information
and the header in which the type is defined. Hover over a function call to see the function's signature. You can turn
off Quick Info in the Text Editor, C/C++, Advanced page.

Error squiggles
Squiggles under a program element (variable, keyword, brace, type name, and so on) call your attention to an error
or potential error in the code. A green squiggle appears when you write a forward declaration, to remind you that
you still need to write the implementation. A purple squiggle appears in a shared project when there is an error in
code that is not currently active, for example when you are working in the Windows context but enter something
that would be an error in an Android context. A red squiggle indicates a compiler error or warning in active code
that you need to deal with.

Code Colorization and Fonts


The default colors and fonts can be changed by using the Environment, Fonts and Colors property page. You
can change the fonts for many UI windows here, not just the editor. The settings that are specific to C++ begin with
"C++"; the other settings are for all languages.

Cross-Platform IntelliSense
In a shared code project, some IntelliSense features such as squiggles are available even when you are working in
an Android context. If you write some code that would result in an error in an inactive project, IntelliSense still
shows squiggles, but they are in a different color than squiggles for errors in the current context.
Here’s an OpenGLES Application that is configured to build for Android and iOS. The illustration shows shared code
being edited. In the first image, Android is the active project:
Notice the following:
The #else branch on line 8 is grayed out to indicate inactive region, because __ANDROID__ is defined for
Android project.
The greeting variable at line 11 is initialized with identifier HELLO, which has a purple squiggle. This is
because no identifier HELLO is defined in the currently inactive iOS project. While in Android project line 11
would compile, it won’t in iOS. Since this is shared code, that is something you should change even though
it compiles in the currently active configuration.
Line 12 has red squiggle on identifier BYE; this identifier is not defined in the currently selected active
project.
Now, change the active project to iOS.StaticLibrary and notice how the squiggles change.

Notice the following:


The #ifdef branch on line 6 is grayed out to indicate inactive region, because _ANDROID\_ is not defined for
iOS project.
The greeting variable at line 11 is initialized with identifier HELLO, which now has red squiggle. This is
because no identifier HELLO is defined in the currently active iOS project.
Line 12 has purple squiggle on identifier BYE; this identifier is not defined in currently inactive
Android.NativeActivity project.

Single File IntelliSense


When you open a single file outside of any project, you still get IntelliSense. You can enable or disable particular
features by going to Text Editor, C/C++, Advanced to turn on or off IntelliSense features. To configure
IntelliSense for single files that aren't part of a project, look for IntelliSense and Browsing for Non-Project
Files in the Advanced section. See Visual C++ Guided Tour.

By default, single file IntelliSense only uses standard include directories to find header files. To add additional
directories, open the shortcut menu on the Solution node, and add your directory to Debug Source Code list, as
the following illustration shows:

See Also
Using IntelliSense
Supplying XML Code Comments
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can make the comments in source code files available as IntelliSense. When you add the /doc switch to the
Visual Basic, C#, or C++ compiler command line, an .xml file is generated that serves as the basis for IntelliSense
documentation.
For more information about documenting code in Visual Basic, see How to: Create XML Documentation.
For more information about documenting code in C#, see XML Documentation Comments.
For more information about documenting code in C++, see Comments and XML Documentation.

See Also
Using IntelliSense
Customizing the Editor
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can customize the formatting, tabs, fonts and colors, IntelliSense, and many other features of the editor in
general or a specific language editor by changing options. For more information about these options, see Text
Editor Options Dialog Box or type Editor into QuickLaunch . You can also change how editor windows are
displayed.

In This Section
These topics explain how to adjust the appearance and behavior of the Text and Code editor.
How to: Change Text Case in the Editor Explains how to change text case in your code.
How to: Manage Editor Windows Shows how to manipulate editor windows.
How to: Manage Editor Modes Explains how to use the full screen and virtual spaces modes.

See Also
Writing Code Setting Bookmarks in Code General, Environment, Options Dialog Box Documents, Environment,
Options Dialog Box Fonts and Colors, Environment, Options Dialog Box
How to: Change Text Case in the Editor
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can use menu commands or keyboard shortcuts to convert the case of selected text to all upper case or to all
lower case.

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

Procedure
To switch text to upper case
1. Select the text you want to convert.
2. On the Edit menu, select Advanced .
3. To convert text to all upper case, choose Make Uppercase , or press CTRL +SHIFT +U .
— or —
To convert text to all lower case, choose Make Lowercase , or press CTRL +U .

TIP
To revert to the previous case formatting before this change, select Undo from the Edit menu.

See Also
Customizing the Editor Text Editor Options Dialog Box Writing Code
How to: Manage Editor Modes
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can display the Visual Studio Code Editor in various display modes.

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

Enabling Full Screen mode


You can choose to hide all tool windows and view only document windows by enabling Full Screen mode.
To enable Full Screen mode
Press ALT+SHIFT+ENTER to enter or exit Full Screen mode.
-- or --
Issue the command View.Fullscreen in the Command window.

Enabling Virtual Space mode


In Vir tual Space mode, spaces are inserted at the end of each line of code. Select this option to position
comments at a consistent point next to your code.
To enable Virtual Space mode
1. Select Options from the Tools menu.
2. Expand the Text Editor folder, and choose All Languages to set this option globally, or choose a specific
language folder. (For example, to turn on line numbers only in Visual Basic, choose the Basic, Text Editor
options.)
3. Select General options, and under Settings , select Enable Vir tual Space .

NOTE
Vir tual Space is enabled in Column Selection mode. When Vir tual Space mode is not enabled, the insertion
point moves from the end of one line directly to the first character of the next.

See Also
Customizing the Editor How to: Arrange and Dock Windows Fonts and Colors, Environment, Options Dialog Box
How to: Manage Editor Windows
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can work on code in several locations at once. Do this by splitting an Editor window, or by opening several
instances of editor windows.

NOTE
Not all editor windows support multiple instances.

Splitting an editor window


An instance of an editor window can be split into two separate views for easier editing.
To split a pane
1. Click within the editor window to give it focus.
2. From the Window menu, select Split .
The editing area divides into two panes separated by a splitter bar. You can scroll these panes independently
to view and edit different parts of the active document at the same time. Any changes made in one pane are
reflected in the other.

TIP
To make one pane larger than the other, drag the splitter bar upward or downward.

To return to single-pane view


From the Window menu, select Remove Split .

Creating New Windows


You can also create multiple instances of an editor window. This feature allows you to open a lengthy document in
more than one instance of an editor, so that you can view and edit different sections simultaneously in separate,
full-sized editor windows.
To create a new window
On the Window menu, click New Window .
A new tabbed instance of the editor is added.

See Also
Customizing the Editor Writing Code Customizing window layouts
How to: Track Your Code by Customizing the
Scrollbar
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

When you are working with long code files, it can be hard to keep everything in mind. You can customize the scroll
bar of the code window to give you a bird's eye view of what's happening in your code.
To show annotations on the scroll bar
1. You can set up the scroll bar to show code changes, breakpoints, errors, and bookmarks.
Open the Scroll Bar options page (Tools, Options Text Editor. All Languages or a specific language, or
type scroll bar in the Quick Launch window).
2. Select Show Annotations over ver tical scroll bar , then select the annotations you want to see. (The
Marks option includes breakpoints and bookmarks.)
3. Now try it out. Open a large code file and replace something that occurs in several places in the file. The
scroll bar shows you the effect of the replacements, so you can back out your changes if you replaced
something you shouldn't have.
Here's how the scroll bar looks after a search for a string. Notice that all instances of the string appear.

Here's the scroll bar after replacing all the instances of the string. You can see immediately that the
operation caused some problems.
To set the display mode for the scroll bar
1. The scroll bar has two modes, bar mode (the default) and map mode. Bar mode just displays annotation
indicators on the scroll bar. In map mode the lines of code are represented on the scroll bar. You can choose
how wide they are and whether they show the underlying code when you rest the pointer on them. When
you click a location on the scroll bar, the cursor moves to that location in the code. Collapsed regions are
shaded differently; they are expanded when you double-click them.
On the Scroll Bar options page, select either Use Bar mode for ver tical scroll bar or Use Map mode
for ver tical scroll bar . You can choose the width in the Source Over view dropdown.
Here's how the search example looks when map mode is on and the width is set to Medium:

2. In map mode, to enable previews of the code when you move the cursor up and down the scroll bar, select
the Show Preview Tooltip option. Here's how it looks:
If you want to keep the map mode scrolling behavior and the preview tooltip but don't want to see the
source code overview, you can set Source Over view to Off .
How to: View and Edit Code by Using Peek Definition
(Alt+F12)
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can use the Peek Definition command to view and edit code without switching away from the code that
you're writing. Peek Definition and Go To Definition show the same information, but Peek Definition shows it
in a pop-up window, and Go To Definition shows the code in a separate code window. Go To Definition causes
your context (that is, the active code window, current line, and cursor position) to switch to the definition code
window. By using Peek Definition , you can view and edit the definition and move around inside the definition file
while keeping your place in the original code file.
You can use Peek Definition with C#, Visual Basic, and C++ code. In Visual Basic, Peek Definition shows a link to
the Object Browser for symbols that don’t have definition metadata (for example, .NET Framework types that are
built in).

IMPORTANT
You can't use this command in any Express version of Visual Studio 2013.

Working with Peek Definition


To open a Peek Definition window
1. You can find Peek Definition by opening the shortcut menu for a method that you want to explore.
(Keyboard: Alt+F12)
This illustration shows the Peek Definition window for a method that's named Print() :

The definition window appears below the printer.Print(“Hello World!”) line in the original file. The
window doesn't hide any of the code in your original file. The lines that follow the
printer.Print(“Hello World!”) call appear under the definition window.
2. You can move the cursor to different locations in the code definition window. You can still move around in
the original code window above or below the definition window.
3. You can copy a string from the definition window and paste it in the original code. You can also drag and
drop the string from the definition window to the original code without deleting it from the definition
window.
4. You can close the definition window by choosing the Esc key or the Close button on the definition window
tab.
To open a Peek Definition window from within a Peek Definition window
If you already have a Peek Definition window open, you can call Peek Definition again on the code in
that window. Another definition window opens. A set of breadcrumb dots appears next to the definition
window tab, which you can use to navigate between definition windows. The tooltip on each dot shows the
file name and path of the definition file that the dot represents.

To use Peek Definition with multiple results


If you use Peek Definition on code that has more than one definition (for example, partial classes), a result
list appears to the right of the code definition view. You can choose any result in the list to display its
definition.

To edit inside the Peek Definition window


When you start to edit inside a Peek Definition window, the file that you're modifying automatically opens
as a separate tab in the code editor and reflects the changes that you've already made. You can continue to
make, undo, and save changes in the Peek Definition window, and the tab will continue to reflect those
changes. Even if you close the window without saving your changes, you can make, undo, and save more
changes in the tab, picking up exactly where you left off in the window.

To use keyboard shortcuts for Peek Definition


You can use these keyboard shortcuts with the Peek Definition window:

F UN C T IO N A L IT Y K EY B O A RD SH O RTC UT

Open the definition window Alt+F12

Close the definition window Esc

Promote the definition window to a regular document tab Shift+Alt+Home

Navigate between definition windows Ctrl+Alt+- and Ctrl+Alt+=

Navigate between multiple results F8 and Shift+F8

Toggle between the code editor window and the definition Shift+Esc
window

NOTE
You can also use the same keyboard shortcuts to edit code in a Peek Definition window as you use elsewhere in
Visual Studio.

See Also
Productivity Tips
Perform quick actions with light bulbs
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Light bulbs are a new productivity feature in Visual Studio 2015. They are icons that appear in the Visual Studio
editor and that you can click to perform quick actions including refactoring fixing errors. Light bulbs bring error-
fixing and refactoring assistance into a single focal point, often right on the line where you are typing.

In C# and Visual Basic, you will see a light bulb if there is a red squiggle and Visual Studio has a suggestion for
how to fix the issue. For instance if you have an error indicated by a red squiggle, a light bulb will appear when
fixes are available for that error. In C++, when you add a new function to a header file, you’ll see a light bulb that
offers to create a stub implementation of that function. For any language, third parties can provide custom
diagnostics and suggestions, for example as part of an SDK, and Visual Studio light bulbs will light up based on
those rules.

To see a light bulb


1. In many cases, light bulbs spontaneously appear when you hover the mouse at the point of an error, or in
the left margin of the editor when you move the caret into a line that has an error in it. When you see a red
squiggle, you can hover over it to display the light bulb. You can also cause a light bulb to display when you
use the mouse or keyboard to go to anywhere in the line where the issue occurs.
2. Press Ctrl + . anywhere on a line to invoke the light bulb and go directly to the list of potential fixes.

To see potential fixes


Either click on the down arrow or the Show potential fixes link to display a list of quick actions that the light bulb
can take for you.
To do a refactoring
You can still perform refactorings by right clicking to bring up the context menu, but you can also press Ctrl + . to
display refactoring options. In the following illustration, the Extract Method refactoring is offered after pressing
Ctrl + . somewhere on the line that contains the Math.Abs call:
Code Snippets
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Code snippets are small blocks of reusable code that can be inserted in a code file using a context menu
command or a combination of hotkeys. They typically contain commonly-used code blocks such as try-finally or
if-else blocks, but they can be used to insert entire classes or methods.

Expansion Snippets and Surround-With Snippets


In Visual Studio there are two kinds of code snippet: expansion snippets, which are added at a specified insertion
point and may replace a snippet shortcut, and surround-with snippets (C# and C++ only), which are added
around a selected block of code.
An example of an insertion snippet: in C# the shortcut tryf is used to insert a try-finally block:

try
{

}
finally
{

You can insert this snippet by clicking Inser t Snippet in the context menu of the code window, then Visual C# ,
then type tryf , then TAB, or you can type tryf and press TAB + TAB.
An example of a surround-with snippet: in C++ the shortcut if can be used either as an insertion snippet or as
a surround-with snippet. If you select a line of code (for example return FALSE; ), and then click Surround With ,
then if , the snippet is expanded around the line:

if (true)
{
return FALSE;
}

Snippet Replacement Parameters


Snippets can contain replacement parameters, which are placeholders that you must replace to fit the precise
code you are writing. In the previous example true is a replacement parameter, which you would replace with
the appropriate condition. The replacement you make is repeated for every instance of the same replacement
parameter in the snippet.
For example, in Visual Basic there is a code snippet that inserts a property. Click Inser t Snippet on the context
menu of the code window, then Code Patterns , then Proper ties, Procedures, Events , then Define a property.
The following code is inserted:

Private newPropertyValue As String


Public Property NewProperty() As String
Get
Return newPropertyValue
End Get
Set(ByVal value As String)
newPropertyValue = value
End Set
End Property

If you change newPropertyValue to m_property , then every instance of newPropertyValue is changed. If you
change String to Int in the property declaration, then the value in the set method is also changed to Int .

Code Snippet Manager


You can see all the code snippets that are currently installed, plus their location on disk, by clicking Tools/Code
Snippets Manager . Snippets are displayed by language.
You can add and remove snippet directories with the Add and Remove buttons in the Code Snippets Manager
dialog. To add individual code snippets, use the Impor t button.

See Also
Walkthrough: Creating a Code Snippet How to: Distribute Code Snippets Best Practices for Using Code Snippets
Troubleshooting Snippets Visual C# Code Snippets Visual C++ Code Snippets Code Snippets Schema Reference
Walkthrough: Creating a Code Snippet
1/10/2020 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can create a code snippet with only a few steps. All you need to do is create an XML file, fill in the appropriate
elements, and add your code to it. You can also add references and replacement parameters to your code. You can
add the snippet to your Visual Studio installation by using the Import button on the Code Snippets Manager
(Tools/Code Snippets Manager ).

TIP
For information about how to write code snippets more easily, search the CodePlex website for community tools such as
Snippet Editor.

Snippet Template
The following is the basic snippet template:

<?xml version="1.0" encoding="utf-8"?>


<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title></Title>
</Header>
<Snippet>
<Code Language="">
<![CDATA[]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>

To Create a Code Snippet


1. Create a new XML file in Visual Studio and add the template shown above.
2. Fill in the title of the snippet, e.g. "Hello World VB", in the Title element.
3. Fill in the language of the snippet in the Languages attribute of the Code element. For this example, use
"VB".
4. Add some code in the CDATA section inside the Code element, for example:
<Code Language="VB">
<![CDATA[Console.WriteLine("Hello, World!")]]>
</Code>

5. Save the snippet as VBCodeSnippet.snippet.


To Add a Code Snippet to Visual Studio
1. You can add your own snippets to your Visual Studio installation by using the Code Snippets Manager.
Open the Code Snippets Manager (Tools/Code Snippets Manager ).
2. Click the Impor t button.
3. Go to the location where you saved the code snippet in the previous procedure, select it, and click Open .
4. The Impor t Code Snippet dialog opens, asking you to choose where to add the snippet from the choices
in the right pane. One of the choices should be My Code Snippets . Select it and click Finish , then OK .
5. The snippet is copied to the following location:
%USERPROFILE%\Documents\Visual Studio 2013\Code Snippets\Visual Basic\My Code Snippets

6. Test your snippet by opening a Visual Basic project and opening a code file. In the file click Inser t Snippet
on the context menu, then My Code Snippets . You should see a snippet named My Visual Basic Code
Snippet . Double-click it.
7. You should see Console.WriteLine("Hello, World!") inserted in the code.
Adding Description and Shortcut Fields
1. Description fields give more information about your code snippet when viewed in the Code Snippets
Manager. The shortcut is a tag that users can type in order to insert your snippet. Edit the snippet you have
added by opening the file
%USERPROFILE%\Documents\Visual Studio 2013\Code Snippets\Visual Basic\My Code
Snippet\VBCodeSnippet.snippet
.
2. Add Author and Description elements to the Header element, and fill them in.
3. The Header element should look something like this:

<Header>
<Title>Hello World VB</Title>
<Author>Myself</Author>
<Description>Says Hello to the world.</Description>
</Header>

4. Open the Code Snippets Manager and select your code snippet. In the right pane you should see that the
Description and Author fields are now populated.
5. To add a shortcut, add a Shortcut element alongside the Author and Description element:
<Header>
<Title>Hello World VB</Title>
<Author>Myself</Author>
<Description>Says Hello to the world.</Description>
<Shortcut>hello</Shortcut>
</Header>

6. Save the snippet file again.


7. To test the shortcut, open a Visual Basic project and open a code file. Type hello in the file and press TAB.
The snippet code should be inserted.
To Add References and Imports
1. With Visual Basic snippets you can add a reference to a project by using the References element, and add an
Imports declaration by using the Imports element. (Snippets in other languages do not have this feature.)
For example, if you change Console.WriteLine in the code example to MessageBox.Show , you may need to
add the System.Windows.Forms.dll assembly to the project.
2. Open your snippet.
3. Add the References element under the Snippet element:

<References>
<Reference>
<Assembly>System.Windows.Forms.dll</Assembly>
</Reference>
</References>

4. Add the Imports element under the Snippet element:

<Imports>
<Import>
<Namespace>System.Windows.Forms</Namespace>
</Import>
</Imports>

5. Change the CDATA section to the following:

<![CDATA[MessageBox.Show("Hello, World!")]]>

6. Save the snippet.


7. Open a Visual Basic project and add the snippet.
8. You will see an Imports statement at the top of the code file:

Imports System.Windows.Forms

9. Look at the project's properties. The References tab includes a reference to System.Windows.Forms.dll.
Adding Replacements
1. You may want parts of your code snippets to be replaced by the user, for example if you add a variable and
want the user to replace the variable with one in the current project. You can provide two types of
replacements: literals and objects. Literals are strings of some type (string literals, variable names, or string
representations of numeric values). Objects are instances of some type other than a string. In this procedure
you will declare a literal replacement and an object replacement, and change the code to reference these
replacements.
2. Open your snippet.
3. This example uses a SQL connection string, so you need to change the Imports and References elements to
add the appropriate references:

<References>
<Reference>
<Assembly>System.Data.dll</Assembly>
</Reference>
<Reference>
<Assembly>System.Xml.dll</Assembly>
</Reference>
</References>
<Imports>
<Import>
<Namespace>System.Data</Namespace>
</Import>
<Import>
<Namespace>System.Data.SqlClient</Namespace>
</Import>
</Imports>

4. To declare a literal replacement for the SQL connection string, add a Declarations element under the
Snippet element, and in it add a Literal element with subelements for the ID, the tooltip, and the default
value for the replacement:

<Declarations>
<Literal>
<ID>SqlConnString</ID>
<ToolTip>Replace with a SQL connection string.</ToolTip>
<Default>"SQL connection string"</Default>
</Literal>
</Declarations>

5. To declare an object replacement for the SQL connection, add an Object element inside the Declarations
element, and add sub-elements for the ID, the type of the object, the tooltip, and the default value. The
resulting Declarations element should look like this:

<Declarations>
<Literal>
<ID>SqlConnString</ID>
<ToolTip>Replace with a SQL connection string.</ToolTip>
<Default>"SQL connection string"</Default>
</Literal>
<Object>
<ID>SqlConnection</ID>
<Type>System.Data.SqlClient.SqlConnection</Type>
<ToolTip>Replace with a connection object in your application.</ToolTip>
<Default>dcConnection</Default>
</Object>
</Declarations>
6. In the code section, you reference the replacements with surrounding $ signs, for example $replacement$ :

<Code Language="VB" Kind="method body">


<![CDATA[Dim daCustomers As SqlDataAdapter
Dim selectCommand As SqlCommand

daCustomers = New SqlClient.SqlDataAdapter()


selectCommand = new SqlClient.SqlCommand($SqlConnString$)
daCustomers.SelectCommand = selectCommand
daCustomers.SelectCommand.Connection = $SqlConnection$]]>
</Code>

7. Save the snippet.


8. Open a Visual Basic project and add the snippet.
9. The code should look like the following, where the replacements SQL connection string and dcConnection
are highlighted in light orange. Press TAB to navigate from one to the other.

Dim daCustomers As SqlDataAdapter


Dim selectCommand As SqlCommand

daCustomers = New SqlClient.SqlDataAdapter()


selectCommand = New SqlClient.SqlCommand("SQL connection string")
daCustomers.SelectCommand = selectCommand
daCustomers.SelectCommand.Connection = dcConnection

See Also
Code Snippets Schema Reference
How to: Distribute Code Snippets
2/19/2020 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can simply give your code snippets to your friends and have them install the snippets on their own computers
by using the Code Snippets Manager. However, if you have several snippets to distribute or would like to distribute
them more widely, you include your snippet file in a Visual Studio extension, which Visual Studio users can install.
You must install the Visual Studio SDK in order to create Visual Studio extensions. Find the version of the VSSDK
that matches your Visual Studio installation at Visual Studio 2015 Downloads.

Setting up the Extension


In this procedure we will use the same Hello World code snippet created in Walkthrough: Creating a Code Snippet.
We will supply the .snippet text, so you don’t have to go back and make one.
1. Create a new VSIX project named TestSnippet . (File / New / Project / Visual C# (or Visual Basic /
Extensibility )
2. In the TestSnippet project, add a new XML file and call it VBCodeSnippet.snippet . Replace the content
with the following:

<?xml version="1.0" encoding="utf-8"?>


<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Hello World VB</Title>
<Shortcut>HelloWorld</Shortcut>
<Description>Inserts code</Description>
<Author>MSIT</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="VB">
<![CDATA[Console.WriteLine("Hello, World!")]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>

Setting up the Directory Structure


1. In the Solution Explorer, select the project node and add a folder that has the name you want the snippet to
have in the Code Snippets Manager. In this case it should be HelloWorldVB .
2. Move the .snippet file to the HelloWorldVB folder.
3. Select the .snippet file in the Solution Explorer, and in the Proper ties window make sure Build Action is
set to Content , Copy to Output Director y is set to Copy always , and Include in VSIX is set to true .
Adding the .pkgdef file
1. Add a text file to the HelloWorldVB folder and name it HelloWorldVB.pkgdef . This file is used to add
certain keys to the registry. In this case it adds a new key to
HKCU\Software\Microsoft\VisualStudio\14.0\Languages\CodeExpansions\Basic .
2. Add the following lines to the file.

// Visual Basic
[$RootKey$\Languages\CodeExpansions\Basic\Paths]
"HelloWorldVB"="$PackageFolder$"

If you examine this key, you can see how to specify different languages.
3. Select the .pkgdef file in the Solution Explorer, and in the Proper ties window make sure Build Action is set
to Content , Copy to Output Director y is set to Copy always , and Include in VSIX is set to true .
4. Add the .pkgdef file as an asset in the VSIX manifest. In the source.extension.vsixmanifest file, go to the
Assets tab and click New .
5. In the Add New Asset dialog, set the Type to Microsoft.VisualStudio.VsPackage , the Type to File on
filesystem , and the Path to HelloWorldVB.pkgdef (which should appear in the dropdown).
Testing the Snippet
1. Now you can make sure that the code snippet works in the experimental instance of Visual Studio. The
experimental instance is a second copy of Visual Studio that is separate from the one you use to write code.
It allows you to work on an extension without affecting your development environment.
2. Build the project and start debugging. A second instance of Visual Studio should appear.
3. In the experimental instance, go to Tools / Code Snippets Manager and set the Language to Basic . You
should see HelloWorldVB as one of the folders, and you should be able to expand the folder to see the
HelloWorldVB snippet.
4. Test the snippet. In the experimental instance, open a Visual Basic project and open one of the code files.
Place your cursor somewhere in the code, right-click, and on the context menu select Inser t Snippet .
5. You should see HelloWorldVB as one of the folders. Double-click it. You should see a pop-up Inser t
Snippet: HellowWorldVB > that has a dropdown HelloWorldVB . Click the HelloWorldVB dropdown. You
should see the following line added to the file:

Console.WriteLine("Hello, World!")

See Also
Code Snippets
Visual C# Code Snippets
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Code snippets are ready-made snippets of code you can quickly insert into your code. For example, the for code
snippet creates an empty for loop. Some code snippets are surround-with code snippets, which enable you to
select lines of code, and then choose a code snippet which incorporates the selected lines of code. For example,
when you select lines of code and then activate the for code snippet, it creates a for loop with those lines of
code inside the loop block. Code snippets can make writing program code quicker, easier, and more reliable.
You can insert a code snippet at the cursor location, or insert a surround-with code snippet around the currently
selected code. The Code Snippet Inserter is invoked through the Inser t Code Snippet or Surround With
commands on the IntelliSense menu, or by using the keyboard shortcuts CTRL+K and then X or CTRL+K and
then S respectively.
The Code Snippet Inserter displays the code snippet name for all available code snippets. The Code Snippet
Inserter also includes an input dialog box where you can type the name of the code snippet, or part of the code
snippet name. The Code Snippet Inserter highlights the closest match to a code snippet name. Pressing TAB at any
time will dismiss the Code Snippet Inserter and insert the currently selected code snippet. Typing ESC or clicking
the mouse in the Code Editor will dismiss the Code Snippet Inserter without inserting a code snippet.

Default Code Snippets


By default the following code snippets are included in Visual Studio.

N A M E ( O R SH O RTC UT ) DESC RIP T IO N VA L ID LO C AT IO N S TO IN SERT SN IP P ET

#if Creates a #if directive and a #endif Anywhere.


directive.

#region Creates a #region directive and a Anywhere.


#endregion directive.

~ Creates a destructor for the containing Inside a class.


class.

attribute Creates a declaration for a class that Inside a namespace (including the
derives from Attribute. global namespace), a class, or a struct.

checked Creates a checked block. Inside a method, an indexer, a property


accessor, or an event accessor.

class Creates a class declaration. Inside a namespace (including the


global namespace), a class, or a struct.
N A M E ( O R SH O RTC UT ) DESC RIP T IO N VA L ID LO C AT IO N S TO IN SERT SN IP P ET

ctor Creates a constructor for the Inside a class.


containing class.

cw Creates a call to WriteLine. Inside a method, an indexer, a property


accessor, or an event accessor.

do Creates a do while loop. Inside a method, an indexer, a property


accessor, or an event accessor.

else Creates an else block. Inside a method, an indexer, a property


accessor, or an event accessor.

enum Creates an enum declaration. Inside a namespace (including the


global namespace), a class, or a struct.

equals Creates a method declaration that Inside a class or a struct.


overrides the Equals method defined in
the Object class.

exception Creates a declaration for a class that Inside a namespace (including the
derives from an exception (Exception by global namespace), a class, or a struct.
default).

for Creates a for loop. Inside a method, an indexer, a property


accessor, or an event accessor.

foreach Creates a foreach loop. Inside a method, an indexer, a property


accessor, or an event accessor.

forr Creates a for loop that decrements the Inside a method, an indexer, a property
loop variable after each iteration. accessor, or an event accessor.

if Creates an if block. Inside a method, an indexer, a property


accessor, or an event accessor.

indexer Creates an indexer declaration. Inside a class or a struct.

interface Creates an interface declaration. Inside a namespace (including the


global namespace), a class, or a struct.

invoke Creates a block that safely invokes an Inside a method, an indexer, a property
event. accessor, or an event accessor.

iterator Creates an iterator. Inside a class or a struct.

iterindex Creates a "named" iterator and indexer Inside a class or a struct.


pair by using a nested class.

lock Creates a lock block. Inside a method, an indexer, a property


accessor, or an event accessor.
N A M E ( O R SH O RTC UT ) DESC RIP T IO N VA L ID LO C AT IO N S TO IN SERT SN IP P ET

mbox Creates a call to Inside a method, an indexer, a property


System.Windows.Forms.MessageBox.Sh accessor, or an event accessor.
ow. You may have to add a reference to
System.Windows.Forms.dll.

namespace Creates a namespace declaration. Inside a namespace (including the


global namespace).

prop Creates an auto-implemented property Inside a class or a struct.


declaration.

propfull Creates a property declaration with get Inside a class or a struct.


and set accessors.

propg Creates a read-only auto-implemented Inside a class or a struct.


property with a private "set" accessor.

sim Creates a staticint Main method Inside a class or a struct.


declaration.

struct Creates a struct declaration. Inside a namespace (including the


global namespace), a class, or a struct.

svm Creates a staticvoid Main method Inside a class or a struct.


declaration.

switch Creates a switch block. Inside a method, an indexer, a property


accessor, or an event accessor.

try Creates a try-catch block. Inside a method, an indexer, a property


accessor, or an event accessor.

tryf Creates a try-finally block. Inside a method, an indexer, a property


accessor, or an event accessor.

unchecked Creates an unchecked block. Inside a method, an indexer, a property


accessor, or an event accessor.

unsafe Creates an unsafe block. Inside a method, an indexer, a property


accessor, or an event accessor.

using Creates a using directive. Inside a namespace (including the


global namespace).

while Creates a while loop. Inside a method, an indexer, a property


accessor, or an event accessor.

See Also
Code Snippet Functions Code Snippets How to: Create a New Snippet with Replacements Template Parameters
How to: Use Surround-with Code Snippets How to: Restore C# Refactoring Snippets
Visual C++ Code Snippets
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In Visual Studio, you can use code snippets to add commonly-used code to your C++ code files. In general, you can
use code snippets in much the same way as in C#, but the set of default code snippets is different.
You can either add a code snippet at a particular location in your code (insertion) or surround some selected code
with a code snippet.

Inserting a Code Snippet


To insert a code snippet, open a C++ code file (.cpp or .h), click somewhere inside the file, and do one of the
following:
Right-click to get the context menu and select Inser t Snippet
In the Edit / IntelliSense menu, select Inser t Snippet
Use the hotkeys: CTRL + K + X
You should see a list of choices beginning with #if . When you select #if , you should see the following code
added to the file:

#if 0

#endif // 0

You can then replace the 0 with the correct condition.

Using a Code Snippet to Surround Selected Code


To use a code snippet to surround selected code, select a line (or multiple lines) and do one of the following:
1. Right-click to get the context menu and select Surround With
2. In the Edit / IntelliSense menu, select Surround With
3. Use the hotkeys: CTRL + K + S
Select #if . You should see something like this:

#if 0
#include "pch.h" // or whatever line you had selected
#endif // 0

You can then replace the 0 with the correct condition.


Where can I find a complete list of the C++ code snippets?
You can find the complete list of C++ code snippets by going to the Code Snippets Manager (on the Tools
menu) and setting the Language to Visual C++ . In the window below, expand Visual C++ . You should see the
names of all the C++ code snippets in alphabetical order.
The names of most code snippets are self-explanatory, but some names might be confusing.

Class vs. classi


The class snippet provides the definition of a class named MyClass, with the appropriate default constructor and
destructor, where the definitions of the constructor and destructor are located outside the class:

class MyClass
{
public:
MyClass();
~MyClass();

private:

};

MyClass::MyClass()
{
}

MyClass::~MyClass()
{
}

The classi code snippet also provides the definition of a class named MyClass, but the default constructor and
destructor are defined inside the class definition:

class MyClass
{
public:
MyClass()
{
}

~MyClass()
{
}

private:

};

For vs. foreach vs. forr vs rfor


There are four different for snippets that provide different kinds of for loops.
The for snippet provides a for loop in which the condition is based on the length (in size_t ) of an object:

for (size_t i = 0; i < length; i++)


{

}
The foreach snippet provides a for each loop that iterates over the members of a collection:

for each (object var in collection_to_loop)


{

The forr snippet provides a reverse for loop in which the condition is based on the length (in integers) of an
object:

for (int i = length - 1; i >= 0; i--)


{

The rfor snippet provides a range-based for loop (link):

for (auto& i : v)
{

The destructor snippet (~)


The destructor snippet (~ ) shows different behavior in different contexts. If you insert this snippet inside a class, it
provides a destructor for that class. For example, given the following code:

class SomeClass {

};

If you insert the destructor snippet, it provides a destructor for SomeClass:

class SomeClass {
~SomeClass()
{

}
};

If you try to insert the destructor snippet outside a class, it provides a destructor with a placeholder name:

~TypeNamePlaceholder()
{
Code Snippet Functions
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

There are three functions available to use with Visual C# code snippets. Functions are specified in the Function
element of the code snippet. For information on creating code snippets, see Code Snippets.

Functions
The following table describes the functions available for use with the Function element in code snippets.

F UN C T IO N DESC RIP T IO N L A N GUA GE

GenerateSwitchCases( Generates a switch statement and a set Visual C#


EnumerationLiteral ) of case statements for the members of
the enumeration specified by the
EnumerationLiteral parameter. The
EnumerationLiteral parameter must
be either a reference to an enumeration
literal or an enumeration type.

ClassName() Returns the name of the class that Visual C#


contains the inserted snippet.

SimpleTypeName( TypeName ) Reduces the TypeName parameter to its Visual C#


simplest form in the context in which
the snippet was invoked.

Example
The following example shows how to use the GenerateSwitchCases function. When this snippet is inserted and an
enumeration is entered into the $switch_on$ literal, the $cases$ literal generates a case statement for every
value in the enumeration.
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>switch</Title>
<Shortcut>switch</Shortcut>
<Description>Code snippet for switch statement</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>expression</ID>
<ToolTip>Expression to switch on</ToolTip>
<Default>switch_on</Default>
</Literal>
<Literal Editable="false">
<ID>cases</ID>
<Function>GenerateSwitchCases($expression$)</Function>
<Default>default:</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
switch ($expression$)
{
$cases$
}
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>

Example
The following example shows how to use the ClassName function. When this snippet is inserted, the $classname$
literal is replaced with the name of the enclosing class at that location in the code file.
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Common constructor pattern</Title>
<Shortcut>ctor</Shortcut>
<Description>Code Snippet for a constructor</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<Default>int</Default>
</Literal>
<Literal>
<ID>name</ID>
<Default>field</Default>
</Literal>
<Literal default="true" Editable="false">
<ID>classname</ID>
<ToolTip>Class name</ToolTip>
<Function>ClassName()</Function>
<Default>ClassNamePlaceholder</Default>
</Literal>
</Declarations>
<Code Language="vjsharp" Format="CData">
<![CDATA[
public $classname$ ($type$ $name$)
{
this._$name$ = $name$;
}
private $type$ _$name$;
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>

Example
This example shows how to use the SimpleTypeName function. When this snippet is inserted into a code file, the
$SystemConsole$ literal will be replaced with the simplest form of the Console type in the context in which the
snippet was invoked.
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Console_WriteLine</Title>
<Shortcut>cw</Shortcut>
<Description>Code snippet for Console.WriteLine</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal Editable="false">
<ID>SystemConsole</ID>
<Function>SimpleTypeName(global::System.Console)</Function>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
$SystemConsole$.WriteLine();
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>

See Also
Function Element (Intellisense Code Snippets) Code Snippets Schema Reference
How to: Restore C# Refactoring Snippets
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

C# refactoring operations rely on code snippets found in the following directory:


Installation directory\Microsoft Visual Studio 14.0\VC#\Snippets\language ID\Refactoring
If this Refactoring directory, or any files in this directory are deleted or corrupted, then C# refactoring operations
may not work in the IDE. The following procedures can help you restore C# refactoring code snippets.
To verify C# refactoring snippets are available through the Code Snippet Manager
1. In the Tools menu, select Code Snippet Manager .
2. In the Code Snippet Manager dialog box, select Visual C# from the Language drop-down list.
A Refactoring folder should appear in the tree view folder list.
To restore refactoring see comment in Code Snippet Manager
1. If the Refactoring folder does not appear in the tree view folder list of the Code Snippet Manager, then use
this procedure to add refactoring snippets back into Code Snippet Manager.
2. In the Tools menu, select Code Snippet Manager .
3. In the Code Snippet Manager dialog box, select Visual C# from the Language drop-down list.
4. Click Add . The Code Snippets Director y dialog box, which helps you locate and specify the directory to
add back into the Code Snippet Manager, appears.
5. Locate the Refactoring folder whose directory path is:
Installation directory\Microsoft Visual Studio 14.0\VC#\Snippets\language ID\Refactoring
The actual path is similar to the following for a default installation:
C:\Program Files\Microsoft Visual Studio 14.0\VC#\Snippets\1033\Refactoring.
6. Click Open in the Code Snippets Director y dialog box, and then click OK in the Code Snippets Manager.

See Also
Visual C# Code Snippets Refactoring (C#) Code Snippets
How to: Use Surround-with Code Snippets
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The following procedures describe how to use surround-with code snippets. Surround-with code snippets are
available three ways: through a keyboard shortcut, through the Edit menu, and through the context menu.
To use surround-with code snippets through keyboard shortcut
1. In the Visual Studio IDE, open the file that you intend to edit.
2. In the Code Editor, select text to surround.
3. Type CTRL+K, CTRL+S.
4. Select the code snippet from the code snippet list using the mouse, or by typing the name of the code
snippet and pressing TAB or ENTER.
To use surround-with code snippets through the Edit menu
1. In the Visual Studio IDE, open the file that you intend to edit.
2. In the Code Editor, select text to surround.
3. From the Edit menu, select IntelliSense and then select the Surround With command.
4. Select the code snippet from the code snippet inserter and then press TAB or ENTER.
Alternatively, you can type the name of the code snippet, and then press TAB or ENTER.
To use surround-with code snippets through the context menu
1. In the Visual Studio IDE, open the file that you intend to edit.
2. In the Code Editor, select text to surround.
3. Right-click the selected text and then select the Surround With command from the context menu.
4. Select the code snippet from the code snippet inserter and then press TAB or ENTER.
Alternatively, you can type the name of the code snippet, and then press TAB or ENTER.

See Also
Visual C# Code Snippets Code Snippet Picker
Best Practices for Using Code Snippets
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The code in a code snippet shows only the most basic way to do something. For most applications, the code must
be modified to suit the application.

Handling Exceptions
Typically, code snippet Try…Catch blocks catch and rethrow all exceptions. That may not be the right choice for your
project. For each exception, there are several ways to respond. For examples, see How to: Handle an Exception
Using try/catch (C# Programming Guide) and Try...Catch...Finally Statement.

File Locations
When you adapt file locations to your application, you should think about the following:
Finding an accessible location. Users may not have access to the Program Files folder of the computer, so
storing files with the application files may not work.
Finding a secure location. Storing files in the root folder (C:\) is not secure. For application data, we
recommend the \Application Data folder. For individual user data, the application can create a file for each
user in the \My Documents folder.
Using a valid file name. You can use the OpenFileDialog and SaveFileDialog controls to reduce the likelihood
of invalid file names. Be aware that between the time the user selects a file and the time your code
manipulates the file, the file may be deleted. In addition, the user may not have permissions to write to the
file.

Security
How secure a snippet is depends on where it is used in the source code and how it is modified once it is in the
code. The following list contains a few of the areas that must be considered.
File and database access
Code access security
Protecting resources (such as event logs, registry)
Storing secrets
Verifying inputs
Passing data to scripting technologies
For more information, see Securing Applications.
Downloaded Code Snippets
IntelliSense code snippets installed by Visual Studio are not in themselves a security hazard. However, they can
create security risks in your application. Snippets downloaded from the Internet should be treated like any other
downloaded content - with extreme caution.
Download snippets only from sites you trust, and use up-to-date virus software.
Open all downloaded snippet files in Notepad or the XML editor of Visual Studio and review them carefully
before installing them. Look for the following issues:
The snippet code could damage your system if you execute it. Read the source code carefully before
running it.
The Help URL block of the snippet file can contain URLs that execute a malicious script file or display
an offensive Web site.
The snippet may contain references that are added silently to your project and may be loaded from
anywhere on your system. These references may have been downloaded to your computer from
where you downloaded the snippet. The snippet may then make a call to a method in the reference
that executes malicious code. To protect yourself against such an attack, review the Imports and
References blocks of the snippet file.

See Also
Visual Basic IntelliSense Code Snippets Securing Applications Code Snippets
Troubleshooting Snippets
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Problems with IntelliSense code snippets are typically caused by two problems: a corrupt snippet file or bad
content in the snippet file.

Common Problems
The Snippet Cannot Be Dragged from File Explorer to a Visual Studio Source File
The XML in the snippet file may be corrupt. The XML Editor in Visual Studio can locate problems in the XML
structure.
The snippet file may not conform to the snippet schema. The XML Editor in Visual Studio can locate
problems in the XML structure.
The Code Has Compiler Errors That Are Not Highlighted
You may be missing a project reference. Examine the documentation about the snippet. If the reference is
not found on the computer, you will need to install it. Inserting a snippet should add to the project any
references needed. If the snippet is missing the reference information, that can be reported to the snippet
creator as an error.
A variable may be undefined. Undefined variables in a snippet should be highlighted. If not, that can be
reported to the snippet creator as an error.

See Also
Code Snippets
Code Snippets Schema Reference
10/16/2020 • 17 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

IntelliSense Code Snippets are pre-authored pieces of code that are ready to be inserted into your application with
Visual Studio. You can increase productivity by providing code snippets that reduce the amount of time spent
typing repetitive code or searching for samples. You can use the IntelliSense Code Snippet XML schema to create
your own code snippets and add them to the code snippets that Visual Studio already includes.

IntelliSense Code Snippets Schema Elements


EL EM EN T EL EM EN T EL EM EN T

Assembly Element HelpUrl Element References Element

Author Element ID Element Shortcut Element

Code Element Import Element Snippet Element

CodeSnippet Element Imports Element SnippetType Element

CodeSnippets Element Keyword Element SnippetTypes Element

Declarations Element Keywords Element Title Element

Default Element Literal Element ToolTip Element

Description Element Namespace Element Type Element

Function Element Object Element Url Element

Header Element Reference Element

Assembly Element
Specifies the name of the assembly referenced by the code snippet.

NOTE
The Assembly element is only supported by Visual Basic code snippets.

The text value of the Assembly element is either the friendly text name of the assembly, such as System.dll , or its
strong name, such as System,Version=1.0.0.1,Culture=neutral,PublicKeyToken=9b35aa323c18d4fb1 .
<Assembly>
AssemblyName
</Assembly>

PA REN T EL EM EN T DESC RIP T IO N

Reference Element Contains information about assembly references required by


the code snippet.

A text value is required. This text specifies the assembly that the code snippet references.

Author Element
Specifies the name of the snippet author. The Code Snippets Manager displays the name stored in the Author
element of the code snippet.

<Author>
Code Snippet Author
</Author>

PA REN T EL EM EN T DESC RIP T IO N

Header Element Contains general information about the code snippet.

A text value is required. This text specifies the author of the code snippet.

Code Element
Provides a container for short code blocks.
Two reserved words are available for use in the text of the Code element: $end$ and $selected$ . $end$ marks
the location to place the cursor after the code snippet is inserted. $selected$ represents text selected in the
document that is to be inserted into the snippet when it is invoked. For example, given a snippet that includes:

$selected$ is a great color.

If the word "Blue" is selected when the user invokes the template, the result is:

Blue is a great color.

You may not use either $end$ or $selected$ more than once in a code snippet. If you do, only the second
instance is recognized. Given a snippet that includes:

$selected$ is a great color. I love $selected$.

If the word "Blue" is selected, the result is:

is a great color. I love Blue.

The initial space appears because there is a space between $selected$ and is .
All other $ keywords are dynamically defined in the <Literal> and <Object> tags.

<Code Language="Language"
Kind="method body/method decl/type decl/page/file/any"
Delimiter="Delimiter">
Code to insert
</Code>

AT T RIB UT E DESC RIP T IO N

Delimiter Optional attribute. Specifies the delimiter used to describe


literals and objects in the code. By default, the delimiter is $ .

Kind Optional attribute. Specifies the kind of code that the snippet
contains and the location at which a code snippet must be
inserted for the code snippet to compile. The values available
are method body , method decl , type decl , file , and
any .

Language Required attribute. Specifies the language of the code snippet.

K IN D AT T RIB UT E VA L UE DESC RIP T IO N

method body Specifies that the code snippet is a method body, and
therefore, must be inserted inside a method declaration.

method decl Specifies that the code snippet is a method, and therefore,
must be inserted inside a class or module.

type decl Specifies that the code snippet is a type, and therefore, must
be inserted inside a class, module, or namespace.

file Specifies that the snippet is a full code file. These code
snippets can be inserted alone into a code file, or inside a
namespace.

any Specifies that the snippet can be inserted anywhere. This tag
is used for code snippets that are context-independent, such
as comments.

L A N GUA GE AT T RIB UT E VA L UE DESC RIP T IO N

VB Identifies a Visual Basic code snippet.

CSharp Identifies a C# code snippet.

CPP Identifies a C++ code snippet.

XML Identifies an XML code snippet.

JavaScript Identifies a JavaScript code snippet.

SQL Identifies a SQL code snippet.


L A N GUA GE AT T RIB UT E VA L UE DESC RIP T IO N

HTML Identifies an HTML code snippet.

PA REN T EL EM EN T DESC RIP T IO N

Snippet Element Contains the references, imports, declarations, and code for
the code snippet.

A text value is required. This text specifies the code, along with the literals and objects, that you can use when this
code snippet is inserted into a project.

CodeSnippet Element
Allows you to specify a heading and multiple IntelliSense Code Snippets, which you can insert into Visual Studio
code files.

<CodeSnippet Format="x.x.x">
<Header>... </Header>
<Snippet>... </Snippet>
</CodeSnippet>

AT T RIB UT E DESC RIP T IO N

Format Required attribute. Specifies the schema version of the code


snippet. The Format attribute must be a string in the syntax
of x.x.x, where each "x" represents a numerical value of the
version number. Visual Studio will ignore code snippets with
Format attributes that it does not understand.

C H IL D EL EM EN T DESC RIP T IO N

Header Element Required element. Contains general information about the


code snippet. There must be exactly one Header element in
a code snippet.

Snippet Element Required element. Contains the code that will be inserted by
Visual Studio. There must be exactly one Snippet element in
a code snippet.

PA REN T EL EM EN T DESC RIP T IO N

CodeSnippets Element Root element of the code snippet XML schema.

CodeSnippets Element
Groups CodeSnippet Elementelements. The CodeSnippets element is the root element of the code snippet XML
schema.
<CodeSnippets>
<CodeSnippet>... </CodeSnippet>
</CodeSnippets>

C H IL D EL EM EN T DESC RIP T IO N

CodeSnippet Element Optional element. Parent element for all code snippet data.
There may be zero or more CodeSnippet elements in a
CodeSnippets element.

Declarations Element
Specifies the literals and objects that make up the parts of a code snippet that you can edit.

<Declarations>
<Literal>... </Literal>
<Object>... </Object>
</Declarations>

C H IL D EL EM EN T DESC RIP T IO N

Literal Element Optional element. Defines the literals of the code snippet that
you can edit. There may be zero or more Literal elements
in a Declarations element.

Object Element Optional element. Defines the objects of the code snippet that
you can edit. There may be zero or more Object elements in
a Declarations element.

PA REN T EL EM EN T DESC RIP T IO N

Snippet Element Contains the references, imports, declarations, and code for
the code snippet.

Default Element
Specifies the default value of the literal or object for an IntelliSense Code Snippet.

<Default>
Default value
</Default>

PA REN T EL EM EN T DESC RIP T IO N

Literal Element Defines the literal fields of the code snippet that you can edit.

Object Element Defines the object fields of the code snippet that you can edit.

A text value is required. This text specifies the default value of the literal or object that fills the fields of the code
snippet that you can edit.

Description Element
Specifies descriptive information about the contents of an IntelliSense Code Snippet.

<Description>
Code Snippet Description
</Description>

PA REN T EL EM EN T DESC RIP T IO N

Header Element Contains general information about the code snippet.

A text value is required. This text describes the code snippet.

Function Element
Specifies a function to execute when the literal or object receives focus in Visual Studio.

NOTE
The Function element is only supported in Visual C# code snippets.

<Function>
FunctionName
</Function>

PA REN T EL EM EN T DESC RIP T IO N

Literal Element Defines the literal fields of the code snippet that you can edit.

Object Element Defines the object fields of the code snippet that you can edit.

A text value is required. This text specifies a function to execute when the literal or object field receives focus in
Visual Studio.
Specifies general information about the IntelliSense Code Snippet.

<Header>
<Title>... </Title>
<Author>... </Author>
<Description>... </Description>
<HelpUrl>... </HelpUrl>
<SnippetTypes>... </SnippetTypes>
<Keywords>... </Keywords>
<Shortcut>... </Shortcut>
</Header>

C H IL D EL EM EN T DESC RIP T IO N
C H IL D EL EM EN T DESC RIP T IO N

Author Element Optional element. The name of the person or company that
authored the code snippet. There may be zero or one
Author elements in a Header element.

Description Element Optional element. A description of the code snippet. There


may be zero or one Description elements in a Header
element.

HelpUrl Element Optional element. A URL that contains more information


about the code snippet. There may be zero or one HelpURL
elements in a Header element. Note: Visual Studio does not
use the HelpUrl element. The element is part of the
IntelliSense Code Snippet XML schema and any code snippet
containing the element will validate, but the value of the
element is never used.

Keywords Element Optional element. Groups Keyword elements. There may be


zero or one Keywords elements in a Header element.

Shortcut Element Optional element. Specifies the shortcut text that can be used
to insert the snippet. There may be zero or one Shortcut
elements in a Header element.

SnippetTypes Element Optional element. Groups SnippetType elements. There


may be zero or one SnippetTypes elements in a Header
element. If there are no SnippetTypes elements, the code
snippet is always valid.

Title Element Required element. The friendly name of the code snippet.
There must be exactly one Title element in a Header
element.

PA REN T EL EM EN T DESC RIP T IO N

CodeSnippet Element Parent element for all code snippet data.

HelpUrl Element
Specifies a URL that provides more information about a code snippet.

NOTE
Visual Studio does not use the HelpUrl element. The element is part of the IntelliSense Code Snippet XML schema and any
code snippet containing the element will validate, but the value of the element is never used.

<HelpUrl>
www.microsoft.com
</HelpUrl>
PA REN T EL EM EN T DESC RIP T IO N

Header Element Contains general information about the code snippet.

A text value is optional. This text specifies the URL to visit for more information about a code snippet.

ID Element
Specifies a unique identifier for a Literal or Object element. No two literals or objects in the same code snippet
can have the same text value in their ID elements.Literals and objects cannot contain an ID element with a value
of end. The value $end$ is reserved, and is used to mark the location to place the cursor after the code snippet is
inserted.

<ID>
Unique Identifier
</ID>

PA REN T EL EM EN T DESC RIP T IO N

Literal Element Defines the literal fields of the code snippet that you can edit.

Object Element Defines the object fields of the code snippet that you can edit.

A text value is required. This text specifies the unique identifier for the object or literal.

Import Element
Specifies the imported namespaces used by an IntelliSense Code Snippet.

NOTE
The Import element is only supported for Visual Basic projects.

<Import>
<Namespace>... </Namespace>
</Import>

C H IL D EL EM EN T DESC RIP T IO N

Namespace Element Required element. Specifies the namespace used by the code
snippet. There must be exactly one Namespace element in an
Import element.

PA REN T EL EM EN T DESC RIP T IO N

Imports Element Grouping element for Impor t elements.

Imports Element
Groups individual Import elements.

NOTE
The Imports element is only supported for Visual Basic projects.

<Imports>
<Import>... </Import>
<Imports>

C H IL D EL EM EN T DESC RIP T IO N

Import Element Optional element. Contains the imported namespaces for the
code snippet. There may be zero or more Impor t elements in
an Imports element.

PA REN T EL EM EN T DESC RIP T IO N

Snippet Element Contains the references, imports, declarations, and code for
the code snippet.

Keyword Element
Specifies a custom keyword for the code snippet. The code snippet keywords are used by Visual Studio and
represent a standard way for online content providers to add custom keywords for searching or categorization.

<Keyword>
Code Snippet Keyword
</Keyword>

PA REN T EL EM EN T DESC RIP T IO N

Keywords Element Groups individual Keyword elements.

A text value is required. The keyword for the code snippet.

Keywords Element
Groups individual Keyword elements. The code snippet keywords are used by Visual Studio and represent a
standard way for online content providers to add custom keywords for searching or categorization

<Keywords>
<Keyword>... </Keyword>
<Keyword>... </Keyword>
<Keywords>

C H IL D EL EM EN T DESC RIP T IO N

Keyword Element Optional element. Contains individual keywords for the code
snippet. There may be zero or more Keyword elements in a
Keywords element.
PA REN T EL EM EN T DESC RIP T IO N

Header Element Contains general information about the code snippet.

Literal Element
Defines the literals of the code snippet that you can edit. The Literal element is used to identify a replacement
for a piece of code that is entirely contained within the snippet, but will likely be customized after it is inserted into
the code. For example, literal strings, numeric values, and some variable names should be declared as literals.
Literals and objects cannot contain an ID element with a value of selected or end. The value $selected$ represents
text selected in the document that is to be inserted into the snippet when it is invoked. $end$ marks the location
to place the cursor after the code snippet is inserted.

<Literal Editable="true/false">
<ID>... </ID>
<ToolTip>... </ToolTip>
<Default>... </Default>
<Function>... </Function>
</Literal>

AT T RIB UT E DESC RIP T IO N

Editable Optional Boolean attribute. Specifies whether or not you


can edit the literal after the code snippet is inserted. The
default value of this attribute is true .

C H IL D EL EM EN T DESC RIP T IO N

Default Element Required element. Specifies the literal's default value when you
insert the code snippet. There must be exactly one Default
element in a Literal element.

Function Element Optional element. Specifies a function to execute when the


literal receives focus in Visual Studio. There may be zero or
one Function elements in a Literal element.

ID Element Required element. Specifies a unique identifier for the literal.


There must be exactly one ID element in a Literal
element.

ToolTip Element Optional element. Describes the expected value and usage of
the literal. There may be zero or one Tooltip elements in a
Literal element.

PA REN T EL EM EN T DESC RIP T IO N

Declarations Element Contains the literals and objects of a code snippet that you
can edit.

Namespace Element
Specifies the namespace that must be imported for the code snippet to compile and run. The namespace specified
in the Namespace element is automatically added to an Imports statement at the beginning of the code, if it does
not already exist.

NOTE
The Namespace element is only supported for Visual Basic projects.

<Namespace>
Namespace
</Namespace>

PA REN T EL EM EN T DESC RIP T IO N

Import Element Imports the specified namespace.

A text value is required. This text specifies a namespace that the code snippet assumes is imported.

Object Element
Defines the objects of the code snippet that you can edit. The Object element is used to identify an item that is
required by the code snippet but is likely to be defined outside of the snippet itself. For example, Windows Forms
controls, ASP.NET controls, object instances, and type instances should be declared as objects. Object declarations
require that a type be specified, which is done with the Type element.

<Object Editable="true/false">
<ID>... </ID>
<Type>... </Type>
<ToolTip>... </ToolTip>
<Default>... </Default>
<Function>... </Function>
</Object>

AT T RIB UT E DESC RIP T IO N

Editable Optional Boolean attribute. Specifies whether or not you


can edit the literal after the code snippet is inserted. The
default value of this attribute is true .

C H IL D EL EM EN T DESC RIP T IO N

Default Element Required element. Specifies the literal's default value when you
insert the code snippet. There must be exactly one Default
element in a Literal element.

Function Element Optional element. Specifies a function to execute when the


literal receives focus in Visual Studio. There may be zero or
one Function elements in a Literal element.

ID Element Required element. Specifies a unique identifier for the literal.


There must be exactly one ID element in a Literal
element.
C H IL D EL EM EN T DESC RIP T IO N

ToolTip Element Optional element. Describes the expected value and usage of
the literal. There may be zero or one Tooltip elements in a
Literal element.

Type Element Required element. Specifies the type of the object. There must
be exactly one Type element in an Object element.

PA REN T EL EM EN T DESC RIP T IO N

Declarations Element Contains the literals and objects of a code snippet that you
can edit.

Reference Element
Specifies information about the assembly references required by the code snippet.

NOTE
The Reference element is only supported for Visual Basic projects.

<Reference>
<Assembly>... </Assembly>
<Url>... </Url>
</Reference>

C H IL D EL EM EN T DESC RIP T IO N

Assembly Element Required element. Contains the name of the assembly


referenced by the code snippet. There must be exactly one
Assembly element in a Reference element.

Url Element Optional element. Contains a URL that provides more


information about the referenced assembly. There may be
zero or one Url elements in a Reference element.

PA REN T EL EM EN T DESC RIP T IO N

References Element Grouping element for Reference elements.

References Element
Groups individual Reference elements.

NOTE
The References element is only supported for Visual Basic projects.
<References>
<Reference>... </Reference>
</References>

C H IL D EL EM EN T DESC RIP T IO N

Reference Element Optional element. Contains information about assembly


references for the code snippet. There may be zero or more
Reference elements in a References element.

PA REN T EL EM EN T DESC RIP T IO N

Snippet Element Contains the references, imports, declarations, and code for
the code snippet.

Shortcut Element
Specifies the shortcut text used to insert the snippet. The text value of a Shortcut element can only contain
alphanumeric characters, hyphens ( - ), and underscores ( _ ).
Cau t i on

_ and – are not supported characters in C++ snippet shortcuts.

<Shortcut>
Shortcut Text
</Shortcut>

PA REN T EL EM EN T DESC RIP T IO N

Header Element Contains general information about the code snippet.

A text value is optional. This text is used as a shortcut for inserting the code snippet.

Snippet Element
Specifies the references, imports, declarations, and code for the code snippet.

<Snippet>
<References>... </References>
<Imports>... </Imports>
<Declarations>... </Declarations>
<Code>... </Code>
</Snippet>

C H IL D EL EM EN T DESC RIP T IO N

Code Element Required element. Specifies the code that you want to insert
into a documentation file. There must be exactly one Code
element in a Snippet element.
C H IL D EL EM EN T DESC RIP T IO N

Declarations Element Optional element. Specifies the literals and objects that make
up the parts of a code snippet that you can edit. There may
be zero or one Declarations elements in a Snippet
element.

Imports Element Optional element. Groups individual Import elements. There


may be zero or one Imports elements in a Snippet
element.

Optional element. Groups individual Reference elements.


There may be zero or one References elements in a
Snippet element.

PA REN T EL EM EN T DESC RIP T IO N

CodeSnippet Element Allows you to specify a heading and multiple IntelliSense Code
Snippets, which you can insert into Visual Studio code files.

SnippetType Element
Specifies how Visual Studio inserts the code snippet.

<SnippetType>
SurroundsWith/Expansion
<SnippetType>

PA REN T EL EM EN T DESC RIP T IO N

SnippetTypes Element Groups SnippetType elements.

The text value must be one of the following values:


SurroundsWith : allows the code snippet to be placed around a selected piece of code.
Expansion : allows the code snippet to be inserted at the cursor.
Refactoring : specifies that the code snippet is used during Visual C# refactoring. Refactoring cannot be
used in custom code snippets.

SnippetTypes Element
Groups individual SnippetType elements. If the SnippetTypes element is not present, the code snippet can be
inserted anywhere in the code.

<SnippetTypes>
<SnippetType>... </SnippetType>
<SnippetType>... </SnippetType>
<SnippetTypes>
C H IL D EL EM EN T DESC RIP T IO N

SnippetType Element Optional element. Specifies how Visual Studio inserts the code
snippet into the code. There may be zero or more
SnippetType elements in a SnippetTypes element.

PA REN T EL EM EN T DESC RIP T IO N

Header Element Specifies general information about the code snippet.

Title Element
Specifies the title for the code snippet. The title stored in the Title element of the code snippet appears in the
Code Snippet Picker and in the code snippet's description in the Code Snippets Manager .

<Title>
Code Snippet Title
<Title>

PA REN T EL EM EN T DESC RIP T IO N

Header Element Specifies general information about the code snippet.

A text value is required. This text specifies the title of the code snippet.

ToolTip Element
Describes the expected value and usage of a literal or object in a code snippet, which Visual Studio displays in a
ToolTip when it inserts the code snippet into a project. The ToolTip text is displayed when the mouse hovers over
the literal or object after the code snippet has been inserted.

<ToolTip>
ToolTip description
</ToolTip>

PA REN T EL EM EN T DESC RIP T IO N

Literal Element Defines the literal fields of the code snippet that you can edit.

Object Element Defines the object fields of the code snippet that you can edit.

A text value is required. This text specifies the ToolTip description to be associated with the object or literal in the
code snippet.

Type Element
Specifies the type of the object. The Object element is used to identify an item that is required by the code snippet
but is likely to be defined outside of the snippet itself. For example, Windows Forms controls, ASP.NET controls,
object instances, and type instances should be declared as objects. Object declarations require that a type be
specified, which is done with the Type element.
<Type>
Type
</Type>

PA REN T EL EM EN T DESC RIP T IO N

Object Element Defines the object fields of the code snippet that you can edit.

A text value is required. This text specifies the type of the object.

Url Element
Specifies a URL that provides more information about the referenced assembly.

NOTE
The Url element is only supported for Visual Basic projects.

<Url>
www.microsoft.com
</Url>

PA REN T EL EM EN T DESC RIP T IO N

Reference Element Specifies the assembly references required by the code


snippet.

A text value is required. This text specifies a URL with more information about the referenced assembly. This URL is
displayed when the reference cannot be added to the project.

See Also
Code Snippets Walkthrough: Creating a Code Snippet
Using the Toolbox
11/21/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can use the toolbox to add controls and other items to your project. You can drag and drop different controls
onto the surface of the designer you are using, and resize and position the controls.
The toolbox appears in conjunction with designer views, such as the designer view of a XAML file. The toolbox
displays only those controls that can be used in the current designer.
The .NET Framework version that your project targets also affects the set of controls visible in the toolbox. By
default, Visual Studio 2013 projects target the .NET Framework 4.5.1. You can set your project to target a different
version of the .NET Framework by selecting the project node in Solution Explorer , and then browsing to
Proper ties/Application/Target Framework .

Managing the Toolbox and its Controls


By default the toolbox is collapsed along the left side of the Visual Studio IDE, and appears when the cursor is
moved over it. You can pin the toolbox (by clicking the Pin icon on the toolbox toolbar) so that it remains open
when you move the cursor. You can also undock the toolbox window and drag it anywhere on your screen. You can
dock, undock, and hide the toolbox by right-clicking the toolbox toolbar and selecting one of the options.
You can rearrange the items in a toolbox tab or add custom tabs and items by using the following commands on
the context menu:
Rename item - Renames the selected item.
Show All - Shows all possible controls (not just the ones that apply to the current designer).
List View - Shows the controls in a vertical list. If unchecked, the controls appear horizontally.
Choose Items - Opens the Choose Toolbox Items dialog box so that you can specify the items that
appear in the Toolbox . You can show or hide an item by selecting or clearing its check box.
Sor t items alphabetically - Sorts the items by name.
Reset Toolbar - Restores the default toolbox settings and items.
Add Tab - Adds a new toolbox tab.
Move Up - Moves the selected item up.
Move Down - Moves the selected item down.

Creating and Distributing Custom Toolbox Controls


You can create a custom toolbox control in either Visual Basic or Visual C#, and you can start with a project
template that's based on Windows Presentation Foundation or Windows Forms. You can then distribute your
control to your teammates or publish it on the web by using the Toolbox Controls Installer.
Viewing the Structure of Code
10/16/2020 • 10 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can examine the objects and members in Visual Studio projects, and the objects and members in .NET
Framework components, COM components, dynamic-link libraries (DLL), and type libraries (TLB).
The following sections of this document describe the different code structure windows.
Class View (Visual Basic, C#, C++)
Call Hierarchy (Visual Basic, C#, C++)
Object Browser
Code Definition Window (C#, C++)
You can also use Solution Explorer to browse the types and members in your projects, search for symbols, view
a method’s Call Hierarchy, find symbol references, and more without having to switch between the multiple tool
windows listed previously.
If you have Visual Studio Enterprise you can use code maps to visualize the structure of your code and its
dependencies across the entire solution, and drill down to parts of the code that interest you. For more
information, see Map dependencies across your solutions.

NOTE
The Visual Studio edition and the settings you are using may affect the features in the IDE. They might differ from those
described in this topic.

Class View (Visual Basic, C#, C++)


Class View is shown as part of Solution Explorer as well as in a separate window. The Class View window
displays the elements of an application. The upper pane displays namespaces, types, interfaces, enumerations, and
classes, and the lower pane displays the members that belong to the type selected in the upper pane. By using this
window, you can move to member definitions in the source code (or in the Object Browser if the element is
defined outside your solution).
You do not have to compile a project to view its elements in Class View . The window is refreshed as you modify
the code in your project.
You can add code to your project by selecting the project node and choosing the Add button to open the Add
New Item dialog box. The code is added in a separate file.
If your project is checked in to source code control, every Class View element displays an icon that indicates the
source code status of the file. Common source code control commands such as Check Out , Check In , and Get
Latest Version are also available on the shortcut menu for the element.
Class View Toolbar
The Class View toolbar contains the following commands.

C OMMAND DESC RIP T IO N

New Folder Creates a virtual folder or subfolder in which you can organize
frequently-used elements. They are saved in the active
solution (.suo) file. After you rename or delete an element in
your code, it might appear in a virtual folder as an error node.
To correct this problem, delete the error node. If you renamed
an element, you can move it from the project hierarchy into
the folder again.

Back Navigates to the previously selected item.

For ward Navigates to the next selected item.

View Class Diagram (managed code projects only) Becomes available when you select a namespace or type in
Class View . When a namespace is selected, the class diagram
shows all the types in it. When a type is selected, the class
diagram shows only that type.

Class View Settings


The Class View Settings button on the toolbar has the following settings.

NAME DESC RIP T IO N

Show Base Types Base types are displayed.

Show Derived Types Derived types are displayed.

Show Hidden Types and Members Hidden types and members (not intended for use by clients)
are displayed in light gray text.

Show Public Members Public members are displayed.

Show Protected Members Protected members are displayed.

Show Private Members Private members are displayed.

Show Other Members Other kinds of members are displayed, including internal (or
Friend in Visual Basic) members.

Show Inherited Members Inherited members are displayed.

Show Extension Methods Extension methods are displayed.

Class View Shortcut Menu


The shortcut menu in Class View may contain the following commands, depending on the kind of project
selected.

C OMMAND DESC RIP T IO N

Go To Definition Finds the definition of the element in the source code, or in


the Object Browser , if the element is not defined in the
open project.
C OMMAND DESC RIP T IO N

Browse Definition Displays the selected item in the Object Browser .

Find All References Finds the currently selected object item and displays the
results in a Find Results window.

Filter To Type (managed code only) Displays only the selected type or namespace. You can
remove the filter by choosing the Clear Find (X) button next
to the Find box.

Copy Copies the fully qualified name of the item.

Sor t Alphabetically Lists types and members alphabetically by name.

Sor t by Member Type Lists types and members in order by type (such that classes
precede interfaces, interfaces precede delegates, and methods
precede properties).

Sor t by Member Access Lists types and members in order by access type, such as
public or private.

Group by Member Type Sorts types and members into groups by object type.

Go To Declaration (C++ code only) Displays the declaration of the type or member in the source
code, if available.

Go To Definition Displays the definition of the type or member in the source


code, if available.

Go To Reference Displays a reference to the type or member in the source


code, if available.

View Call Hierarchy Displays the selected method in the Call Hierarchy window.

Call Hierarchy (Visual Basic, C#, C++)


The Call Hierarchy window shows where a given method (or property or constructor) is called, and lists the
methods that are called from that method. You can view multiple levels of the call graph, which shows the
caller/callee relationships among the methods in a specified scope.
You can display the Call Hierarchy window by selecting a method (or property or constructor) and then choosing
View Class Hierarchy on the shortcut menu. The display should resemble the following picture.
Call Hierarchy
window
By using the drop-down list on the toolbar, you can specify the scope of the hierarchy: the solution, the current
project, or the current document.
The main pane displays the calls to and from the method, and the Call Sites pane displays the location of the
selected call. For members that are virtual or abstract, an Overrides method name node appears. For interface
members, an Implements method name node appears.
The Call Hierarchy window does not find method group references, which include places where a method is
added as an event handler or is assigned to a delegate. To find these references, use the Find All References
command.
The shortcut menu in the Call Hierarchy window contains the following commands.

C OMMAND DESC RIP T IO N

Add as New Root Adds the selected node as a new root node.

Remove Root Removes the selected root node from the tree view pane.

Go to Definition Navigates to the original definition of a method.

Find All References Finds in the project all the references to the selected method.

Copy Copies the selected node (but not its sub-nodes).

Refresh Refreshes the information.

Object Browser
The Object Browser displays descriptions of the code in your projects.
You can filter what you want to view in the Object Browser . By using the drop-down list at the top of the window,
you can choose among the following options:
Any .NET Framework
Silverlight
The active solution
A custom set of components
Custom components can include managed code executables, library assemblies, type libraries, and .ocx files.
It is not possible to add C++ custom components. Custom settings are saved in the Visual Studio user
application directory, %APPDATA%\Roaming\Microsoft\VisualStudio\11.0\ObjBrowEX.dat.
The left pane of the Object Browser shows physical containers such as .NET Framework and COM
components. You can expand the container nodes to display the namespaces they contain, and then expand
the namespaces to display the types they contain. When you select a type, its members (such as properties
and methods) are listed in the right pane. The lower right pane displays detailed information about the
selected item.
You can search for a specific item by using the Search box at the top of the window. Searches are case-
insensitive. Search results are displayed in the left pane. To clear a search, choose the Clear Search (X)
button next to the Search box.
The Object Browser keeps track of the selections you have made, and you can navigate among your
selections by using the For ward and Back buttons on the toolbar.
You can use the Object Browser to add an assembly reference to an open solution by selecting an item
(assembly, namespace, type, or member) and choosing the Add Reference button on the toolbar.
Object Browser Settings
By using the Object Browser Settings button on the toolbar, you can specify one of the following views.

NAME DESC RIP T IO N

View Namespaces Displays namespaces rather than physical containers, in the


left pane. Namespaces stored in multiple physical containers
are merged.

View Containers Displays physical containers rather than namespaces, in the


left pane. View Namespaces and View Containers are
mutually exclusive settings.

Show Base Types Displays base types.

Show Derived Types Displays derived types.

Show Hidden Types and Members Displays hidden types and members (not intended for use by
clients), in light gray text.

Show Public Members Displays public members.

Show Protected Members Displays protected members.

Show Private Members Displays private members.

Show Other Members Displays other types of members, including internal (or Friend
in Visual Basic) members.

Show Inherited Members Displays inherited members.

Show Extension Methods Displays extension methods.

Object Browser Shortcut Menu Commands


The shortcut menu in the Object Browser may contain the following commands, depending on the kind of item
selected.
C OMMAND DESC RIP T IO N

Browse Definition Shows the primary node for the selected item.

Find All References Finds the currently selected object item and displays the
results in a Find Results window.

Filter To Type Displays only the selected type or namespace. You can
remove the filter by choosing the Clear Search button.

Copy Copies the fully qualified name of the item.

Remove If the scope is a custom component set, removes the selected


component from the scope.

Sor t Alphabetically Lists types and members alphabetically by name.

Sor t by Object Type Lists types and members in order by type (such that classes
precede interfaces, interfaces precede delegates, and methods
precede properties).

Sor t by Object Access Lists types and members in order by access type, such as
public or private.

Group by Object Type Sorts types and members into groups by object type.

Go To Declaration (C++ projects only) Displays the declaration of the type or member in the source
code, if available.

Go To Definition Displays the definition of the type or member in the source


code, if available.

Go To Reference Displays a reference to the type or member in the source


code, if available.

View Call Hierarchy Displays the selected method in the Call Hierarchy window.

Code Definition Window (C#, C++)


The Code Definition window displays the definition of a selected type or member in the active project. The type
or member can be selected in the code editor or in a code view window.
Although this window is read-only, you can set breakpoints or bookmarks in it. To modify the displayed definition,
choose Edit Definition on the shortcut menu. This opens the source file in the code editor and moves the
insertion point to the line where the definition begins.
Code Definition Shortcut Menu
The shortcut menu in the Code Definition window may contain the following commands, depending on the
programming language.

C OMMAND DESC RIP T IO N

Create Unit Tests Creates unit tests for the selected element.
C OMMAND DESC RIP T IO N

Generate Sequence Diagram When a method is selected, generates a sequence diagram.

Create Private Accessor If a unit test is present in the solution, generates a method
that the test uses to access the code.

Go To Definition Finds the definition (or definitions, for partial classes) and
displays them in a Find Results window.

Find All References Finds the references to the type or member in the solution.

View Call Hierarchy Displays the method in the Call Hierarchy window.

Show Calling Tests If there are unit tests in the project, shows the tests that call
the selected code.

Run Calling Tests If there are unit tests in the project, runs the tests for the
selected code.

Breakpoint Inserts a breakpoint (or a tracepoint).

Run to Cursor Runs the program in debug mode to the location of the
cursor.

Copy Copies the selected line.

Outlining Standard outlining commands.

Edit Definition Moves the insertion point to the definition in the code
window.

Choose Encoding Opens the Encoding window so that you can set an
encoding for the file.

Document Outline Window


You can use the Document Outline window in conjunction with designer views, such as the designer for a XAML
page or a Windows Form designer, or with HTML pages. This window displays the elements in a tree view so that
you can view the logical structure of the form or page and find controls that are deeply embedded or hidden.

See Also
Class View and Object Browser Icons
Class View and Object Browser Icons
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Class View** and the Object Browser display icons that represent code entities, for example, namespaces,
classes, functions, and variables. The following table illustrates and describes the icons.

IC O N DESC RIP T IO N IC O N DESC RIP T IO N

Namespace Method or Function

Class Operator

Interface Property

Structure Field or Variable

Union Event

Enum Constant

TypeDef Enum Item

Module Map Item

Extension Method External Declaration

Delegate Error

Exception Template

Map Unknown

Type Forwarding

Signal Icons
The following signal icons apply to all the previous icons and indicate their accessibility.
NOTE
If your project is included in a source control database, additional signal icons may be displayed to indicate source-control
status, such as checked in or checked out.

IC O N DESC RIP T IO N

<No Signal Icon> Public. Accessible from anywhere in this component and from
any component that references it.

Protected. Accessible from the containing class or type, or


those derived from the containing class or type.

Private. Accessible only in the containing class or type.

Sealed.

Friend/Internal. Accessible only from the project.

Shortcut. A shortcut to the object.

See Also
Viewing the Structure of Code
Designing and Viewing Classes and Types
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Design, visualize, and refactor classes and other types in your code with Class Designer in Visual Studio. Use class
diagrams to create and edit classes in your Visual C# .NET, Visual Basic .NET, or C++ project, understand your
project structure better, or reorganize your code.
Here's more about what you can do with class diagrams:
Design : Edit your project's code by editing the class diagram. Add new elements and delete unwanted ones.
Your changes are reflected in code.
Visualize : Understand your project's structure by viewing the classes in your project on a diagram.
Customize your diagram so that you can focus on the project details that you care about the most. Save
your diagram to use later for demonstration or documentation.
Refactor : Override methods, rename identifiers, refactor parameters, and implement interfaces and abstract
classes.

In This Section
Working with Classes and Other Types (Class Designer)
Working with Class Diagrams (Class Designer)
Designing Classes and Types (Class Designer)
Viewing Types and Relationships (Class Designer)
Refactoring Classes and Types (Class Designer)
Working with Visual C++ Code (Class Designer)
Additional Information About Class Designer Errors

Related Sections
Writing Code
Map dependencies across your solutions
Working with Classes and Other Types (Class
Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Focus more easily on the classes and types that you care about the most when you create and edit them with Class
Designer in Visual Studio. Use class diagrams to work more visually with your Visual C# .NET, Visual Basic .NET, or
C++ code.

In This Section
Working with Class Diagrams (Class Designer)
Designing Classes and Types (Class Designer)
Viewing Types and Relationships (Class Designer)
Refactoring Classes and Types (Class Designer)
Working with Visual C++ Code (Class Designer)
Additional Information About Class Designer Errors
Working with Class Diagrams (Class Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Class diagrams help you understand the class structure of projects others have written (or that you wrote a long
time ago). You can use them to customize, share and present project information with others.
The first step in presenting project information is to create a class diagram that displays what you want to show.
For more information, see Viewing Types and Relationships (Class Designer). You can create multiple class
diagrams for a project that can be used to display a distinct view of the project, a chosen subset of the project's
types, or a chosen subset of the members of types.
In addition to defining what each class diagram shows, you can also change the way that information is presented;
for more information, see How to: Customize Class Diagrams (Class Designer).
After you have fine-tuned one or more class diagrams, you can copy them into Microsoft Office documents and
print them, or export them as image files. For more information, see How to: Copy Class Diagram Elements to a
Microsoft Office Document (Class Designer), How to: Print Class Diagrams (Class Designer) and How to: Export
Class Diagrams As Images (Class Designer).

NOTE
Class Designer does not track the location of your source files, so changing your project structure or moving source files in
the project can cause Class Designer to lose track of the type, especially the source type of a typedef, base classes, or
association types. You might get an error, like Class Designer is unable to display this type . If you do, drag the
modified or relocated source code to the class diagram again to redisplay it.

In This Section
How to: Add Class Diagrams to Projects (Class Designer)
Describes how to add class diagrams to projects.
How to: Customize Class Diagrams (Class Designer)
Provides information about how to customize class diagrams.
How to: Copy Class Diagram Elements to a Microsoft Office Document (Class Designer)
Explains how to copy from a class diagram into an Office document.
How to: Export Class Diagrams As Images (Class Designer)
Describes how to export class diagrams as images.
How to: Print Class Diagrams (Class Designer)
Explains how to print class diagrams.
How to: Add Comments to Class Diagrams (Class Designer)
Describes how to add comments to a class diagram.
To delete a type shape and its underlying code
Describes how to remove shapes from class diagrams.

See Also
Viewing Types and Relationships (Class Designer) How to: Customize Class Diagrams (Class Designer) How to:
Remove Type Shapes from Class Diagrams (Class Designer)
How to: Add Class Diagrams to Projects (Class
Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

To design, edit, and refactor classes and other types, add a class diagram to your Visual C# .NET, Visual Basic .NET,
or C++ project. To visualize different parts of the code in a project, add multiple class diagrams to the project.
You can't create class diagrams from projects that share code across multiple apps. To create UML class diagrams,
see Create UML modeling projects and diagrams.
To add a blank class diagram to a project
1. In Solution Explorer, right-click the project name. Then choose Add New Item or Add , New Item .
2. From the template list, choose the Class Diagram . For Visual C++ projects, look under Templates , and
then under Utility to find this template.
The class diagram opens in Class Designer and appears as a file that has a .cd extension in Solution Explorer
in the project hierarchy. Use the Class Designer toolbox to drag shapes and lines to the diagram.
3. To add multiple class diagrams, repeat the steps in this procedure.
To add a class diagram based on existing types
1. In Solution Explorer, open the class file context menu, then choose View Class Diagram .
-or-
In Class View , open the namespace or type context menu, then choose View Class Diagram .
To display the contents of a complete project in a class diagram
1. In Solution Explorer or Class View, right-click the project and choose View , then choose View Class
Diagram .
An auto-populated Class Diagram is created.

See Also
How to: Create Types by using Class Designer How to: View Existing Types (Class Designer) Designing Classes and
Types (Class Designer) Viewing Types and Relationships (Class Designer) Working with Class Diagrams (Class
Designer)
How to: Customize Class Diagrams (Class Designer)
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can change the way that class diagrams display information. You can customize the whole diagram or the
individual types on the design surface.
For example, you can adjust the zoom level of an entire class diagram, change how individual type members are
grouped and sorted, hide or show relationships, and move individual or sets of types anywhere on the diagram.

NOTE
Customizing the way that shapes appear on the diagram doesn't change the underlying code for the types represented on
the diagram.

The sections that contain type members, such as the Properties section in a class, are called compartments. You
can hide or show individual compartments and type members.
In this topic
Zoom in and out of the class diagram
Customize grouping and sorting of type members
Hide compartments on a type
Hide individual members on a type
Show hidden compartments and members on a type
Hide relationships
Show hidden relationships
Remove a shape from a class diagram
Delete a type shape and its underlying code

Zoom in and out of the class diagram


1. Open and select a class diagram file in Class Designer.
2. On the Class Designer toolbar, click the Zoom In or Zoom Out button to change the zoom level of the
designer surface.
or
Specify a particular zoom value. You can use the Zoom drop down list or type a valid zoom level (valid
range is between 10% and 400%).
NOTE
Changing the zoom level does not affect the scale of your class diagram printout.

Customize grouping and sorting of type members


1. Open and select a class diagram file in Class Designer.
2. Right-click an empty area on the design surface and point to Group Members .
3. Select one of the available options:
a. Group by Kind separates individual type members into a grouped list of Properties, Methods,
Events, and Fields. The individual groups depend on the entities definition: for example, a class will
not display any events group if there are no events yet defined for that class.
b. Group by Access separates individual type members into a grouped list based on the member's
access modifiers. For example, Public and Private.
c. Sor t Alphabetically displays the items that make up an entity as a single alphabetized list. The list
is sorted in ascending order.

Hide compartments on a type


1. Open and select a class diagram file in the class designer.
2. Right click the member category in the type you want to customize (for example, select the Methods node
in a class.
3. Click Hide Compar tment .
The selected compartment disappears from the type container.

Hide individual members on a type


1. Open and select a class diagram file in Class Designer.
2. Right-click the member in the type you want to hide.
3. Click Hide .
The selected member disappears from the type container.

Show hidden compartments and members on a type


1. Open and select a class diagram file in Class Designer.
2. Right-click the name of the type with the hidden compartment.
3. Click Show All Members .
All hidden compartments and members appear in the type container.

Hide relationships
1. Open and select a class diagram file in Class Designer.
2. Right-click the association or inheritance line that you want to hide.
3. Click Hide for association lines, and click Hide Inheritance Line for inheritance lines.
4. Click Show All Members .
All hidden compartments and members appear in the type container.

Show hidden relationships


1. Open and select a class diagram file in Class Designer.
2. Right-click the type with the hidden association or inheritance.
Click Show All Members for association lines, and click Show Base Class or Show Derived Classes
for inheritance lines.

Remove a shape from a class diagram


You can remove a type shape from the class diagram without affecting the type's underlying code. Removing type
shapes from a class diagram affects only that diagram: the underlying code that defines the type and other
diagrams that display the type are not affected.
1. On the class diagram, select the type shape you want to remove from the diagram.
2. On the Edit menu, choose Remove from Diagram .
The type shape and any lines of association or inheritance connected to the shape no longer appear on the
diagram.

Delete a type shape and its underlying code


1. Right-click the shape on the design surface.
2. Select Delete Code from the context menu.
The shape is removed from the diagram and its underlying code is deleted from the project.

See Also
Working with Class Diagrams (Class Designer) How to: Change Between Member Notation and Association
Notation (Class Designer) How to: View Existing Types (Class Designer) Viewing Types and Relationships (Class
Designer)
How to: Copy Class Diagram Elements to a Microsoft
Office Document (Class Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can copy shapes from a .NET class diagram (.cd file) to other documents. You'll either get a copy of the shape or
its underlying code based on the kind of document where you paste it. To copy shapes from UML class diagrams in
a modeling project, see Export diagrams as images.
To copy a single element
Right-click the shape and choose Copy Image .
To copy several elements
1. Select the shapes on the diagram that you want to copy.
2. Right-click your selection and choose Copy Image .
To copy all the elements in a class diagram
1. Right-click the diagram surface and choose Select All . (Keyboard: Ctrl + A )
2. On the Edit menu, select Copy Image .
You can also choose Copy instead of Copy Image . Copy copies the image as a regular bitmap. Copy
Image copies the image as a vector-based image, which is better for most Office applications.

See Also
How to: Print Class Diagrams (Class Designer) How to: Export Class Diagrams As Images (Class Designer)
How to: Export Class Diagrams As Images (Class
Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

To export a class diagram that you created from code in a project, save the diagram as an image. If you want to
export UML class diagrams instead, see Export diagrams as images.
1. Open your class diagram (.cd) file.
2. From the Class Diagram menu or the diagram surface shortcut menu, choose Expor t Diagram as
Image .
3. Select a diagram.
4. Select the format that you want.
5. Choose Expor t to finish exporting.
To automatically update exported images that are linked from other documents, export the diagram again
in Visual Studio.

See Also
How to: Print Class Diagrams (Class Designer) Working with Class Diagrams (Class Designer)
How to: Print Class Diagrams (Class Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can print a class diagram using the print feature of Visual Studio.
To print a class diagram
1. Display the class diagram. (If necessary, select the class diagram tab to display it.)
2. Click Print on the File menu.
The entire class diagram will print. Note that you may need to adjust the settings in the Page Setup Dialog
box in order to print at an appropriate size.

See Also
How to: Copy Class Diagram Elements to a Microsoft Office Document (Class Designer) How to: Export Class
Diagrams As Images (Class Designer)
How to: Add Comments to Class Diagrams (Class
Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can use comment shapes to annotate class diagrams. A comment shape has one property, Text , into which you
can type text. Comment shapes exist only on the diagram surface and not in code.
A comment resides on the class diagramview in Class Designer ; if you open a second class diagram onto the
same project, comments you created in the first view are not visible. If you delete a diagram, all the comments it
contained are also deleted.
You can resize a comment shape but you cannot change other aspects of its appearance, such as its background
color, font, or font size.
To add a comment
1. Drag a comment from the Class Designer Toolbox onto the class diagram.
2. Click in the new comment shape on the diagram and type the text you want.

See Also
Working with Class Diagrams (Class Designer) Working with Class Diagrams (Class Designer) How to: Customize
Class Diagrams (Class Designer)
Designing Classes and Types (Class Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Using Class Designer , you can not only visualize classes and types, but design them as well. The following topics
describe how to do this.

NOTE
When working with the Class Designer, you should inspect the code it emits before executing it in order to verify that the
code is appropriate for your security context.

In This Section
How to: Create Types by using Class Designer
Describes how to use the Class Diagram to create a type.
How to: Create Inheritance Between Types (Class Designer)
Explains how to define an inheritance relationship between types.
How to: Create Associations Between Types (Class Designer)
Describes how to define associations in the class diagram.
How to: Visualize a Collection Association (Class Designer)
Explains how to define a collection association in the Class Designer.
Creating and Configuring Type Members (Class Designer)
Provides information and links to topics about creating and configuring type members with the Class Designer.

Related Sections
Viewing Types and Relationships (Class Designer)
Refactoring Classes and Types (Class Designer)

See Also
Working with Class Diagrams (Class Designer)
How to: Create Types by using Class Designer
10/16/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

To design new types for Visual C# .NET and Visual Basic .NET projects, create them on a class diagram. To see
existing types, see How to: View Existing Types (Class Designer).
Create a new type
Apply a custom attribute to a type
Apply a custom attribute to a type member

Create a new type


1. In the Toolbox, under Class Designer, drag one of these onto a class diagram:
Class or Abstract Class
Enum
Interface
Structure (VB) or Struct (C#)
Delegate
Module (VB only)
2. Name the type. Then select its access level.
3. Select the file where you want to add the initial code for the type:
To create a new file and add it to the current project, select Create new file and name the file.
To add code to an existing file, select Add to existing file .
If your solution has a project that shares code across multiple apps, you can add a new type to a class
diagram in the app project, but only if the corresponding class file is in the same app project or is in
the shared project.
4. Now add other items to define the type:

FOR A DD

Classes, abstract classes, structures or structs Methods, properties, fields, events, constructors (method),
destructors (method), and constants that define the type

Enums Field values that make up the enumeration


FOR A DD

Interfaces Methods, properties, and events that make up the


interface

Delegate Parameters that define the delegate

Module Methods, properties, fields, events, constructors (method),


and constants that define the module

See Creating Members.

Apply a custom attribute to a type


1. Click the type's shape on a class diagram.
2. In the Properties window, next to the Custom Attributes property for the type, click the ellipsis (…) button.
3. Add one or more custom attributes with one per line. Don't enclose them in brackets.
When you're done, the custom attributes are applied to the type.

Apply a custom attribute to a type member


1. Click the member's name in its type's shape on a class diagram, or its row in the Class Details window.
2. In the Properties window, find the member's Custom Attributes property.
3. Add one or more custom attributes with one per line. Don't enclose them in brackets.
When you're done, the custom attributes are applied to the type.

See Also
How to: Create Inheritance Between Types (Class Designer) How to: Create Associations Between Types (Class
Designer) Creating and Configuring Type Members (Class Designer) Working with Class Diagrams (Class
Designer) Designing Classes and Types (Class Designer)
How to: Create Inheritance Between Types (Class
Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

To create an inheritance relationship between two types on a class diagram using Class Designer, connect the base
type with its derived type or types. You can have an inheritance relationship between two classes, between a class
and an interface, or between two interfaces.
To create an inheritance between types
1. From your project in Solution Explorer, open a class diagram (.cd) file.
If you don't have a class diagram, create it. See How to: Add Class Diagrams to Projects (Class Designer).
2. In the Toolbox , under Class Designer , click Inheritance .
3. On the class diagram, draw an inheritance line between the types that you want, starting from:
A derived class to the base class
An implementing class to the implemented interface
An extending interface to the extended interface
4. Optionally, when you have a derived type from a generic type, click the inheritance line. In the Proper ties
window, set the Type Arguments property to match the type that you want for the generic type.

NOTE
If a parent abstract class contains at least one abstract member, then all abstract members are implemented as non-
abstract inheriting classes.
Although you can visualize existing generic types, you can't create new generic types. You also can't change the type
parameters for existing generic types.

See Also
Inheritance Inheritance Basics How to: View Inheritance Between Types (Class Designer) Visual C++ Classes in
Class Designer
How to: Create Associations Between Types (Class
Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Association lines in Class Designer show how classes in a diagram are related. An Association line represents a
class that is the type of a property or field of another class in your project. Association lines are generally used to
illustrate the most important relationships between classes in your project.
While you could display all fields and properties as associations, it makes more sense to show only important
members as associations, depending on what you intend to emphasize in the diagram. (You can show less
important members as regular members or hide them altogether.)

NOTE
Class Designer supports only unidirectional associations.

To define an association line in the Class Diagram


1. In the Toolbox, under Class Designer, select Association .
2. Draw a line between the two shapes you want to link with an association.
A new property is created in the first class. This property displays as an association line (not as a property
within a compartment in the shape) with a default name. Its type is the shape to which the association line
points.
To change the name of an association
On the diagram surface, click the label of the association line and edit it.
- or -
1. Click the shape that contains the property that is shown as an association.
The shape obtains focus and its members display in the Class Details window and in the Properties window.
2. In either the Class Details window or the Properties window, edit the name field for that property and press
Enter.
The name is updated in the Class Details window, on the association line, in the Properties window, and in
code.

See Also
How to: Change Between Member Notation and Association Notation (Class Designer)
How to: Visualize a Collection Association (Class
Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Properties and fields that are collections of other types can be displayed on the class diagram as a collection
association. Unlike a regular association, which displays a field or property as a line linking the owning class to the
field's type, a collection association is displayed as a line linking the owning class to the collected type.
To create a collection association
1. In code, create a property or field whose type is itself a strongly-typed collection.
2. In the class diagram, expand the class so that properties and fields are shown.
3. In the class, right-click the field or property and choose Show as Collection Association .
The property or field is shown as an association line linking to the collected type.

See Also
How to: Create Associations Between Types (Class Designer) Designing Classes and Types (Class Designer) Viewing
Types and Relationships (Class Designer)
Creating and Configuring Type Members (Class
Designer)
10/18/2019 • 13 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can add these members to types on a class diagram and configure those members in the Class Details
window:

TYPE M EM B ERS IT C A N C O N TA IN

Class method, property (for C# and Visual Basic), field, event (for C#
and Visual Basic), constructor (method), destructor (method),
constant

Enum member

Interface method, property, event (for C# and Visual Basic)

Abstract Class method, property (for C# and Visual Basic), field, event (for C#
and Visual Basic), constructor (method), destructor (method),
constant

Structure (Struct in C#) method, property (for C# and Visual Basic) field, event (for C#
and Visual Basic), constructor (method), constant

Delegate Parameter

Module (VB Only) method, property, field, event, constructor, constant

NOTE
Make property declaration more concise when a property's get and set accessors don't need additional logic by using auto-
implemented properties (C# only). To show the full signature, from the Class Diagram menu, choose Change Members
Format , Display Full Signature . For more information about auto-implemented properties, see Auto-Implemented
Properties.

Common Tasks
TA SK SUP P O RT IN G C O N T EN T
TA SK SUP P O RT IN G C O N T EN T

Get star ted: Before you create and configure type members, - Opening the Class Details Window
you must open the Class Details window. - Class Details Usage Notes
- Display of Read-Only Information
- Keyboard and Mouse Shortcuts in the Class Diagram and
Class Details Window (Class Designer)

Create and modify type members: You can create new - Creating Members
members, modify members, and add parameters to a method - Modifying Type Members
by using the Class Details window. - Adding Parameters to Methods

Opening the Class Details Window


By default, the Class Details Window appears automatically when you open a new class diagram (see How to: Add
Class Diagrams to Projects (Class Designer)). You can also open the Class Details window explicitly, in the following
ways.
To open the Class Details window
1. Right-click on any class in the diagram to display a context menu.
2. In the context menu, click Class Details Window .
– or -
Point to Other Windows on the View menu and then click Class Details .

Creating Members
You can create a member using any of the following tools:
Class Designer
Class Details window toolbar
Class Details window

NOTE
You can also create constructors and destructors using the procedures in this section. Please bear in mind that constructors
and destructors are special kinds of methods, and as such, they appear in the Methods compartment in class diagram
shapes and in the Methods section of the Class Details window grid.

NOTE
The only entity you can add to a delegate is parameter. Note that the procedure entitled 'To Create a member using the Class
Details Window toolbar' is not valid for this action.

To create a member using Class Designer


1. Right-click the type to which you want to add a member, point to Add , and then choose the type of member
you want to add.
A new member signature is created and added to the type. It is given a default name that you can change in
Class Designer , the Class Details window, or in the Proper ties window.
2. Optionally, specify other details about the member, such as its type.
To create a member using the Class Details Window toolbar
1. On the diagram surface, select the type to which you want to add a member.
The type obtains focus and its contents are displayed in the Class Details window.
2. In the Class Details window toolbar, click the top icon and select New <member> from the drop-list.
The cursor moves to the Name field in a row for the kind of member you want to add. For example, if you
clicked New Proper ty , the cursor moves to a new row in the Proper ties section of the Class Details
window.
3. Type the name of the member you want to create and press Enter (or otherwise move focus, such as by
pressing Tab).
A new member signature is created and added to the type. The member now exists in code and is displayed
in Class Designer , the Class Details window, and the Properties window.
4. Optionally, specify other details about the member, such as its type.
To create a member using the Class Details Window
1. On the diagram surface, select the type to which you want to add a member.
The type obtains focus and its contents are displayed in the Class Details window.
2. In the Class Details window, in the section that contains the kind of member you want to add, click <add
member> . For example, if you want to add a field, click <add field> .
3. Type the name of the member you want to create and press Enter.
A new member signature is created and added to the type. The member now exists in code and is displayed
in the Class Designer , the Class Details window, and the Properties window.
4. Optionally, specify other details about the member, such as its type.
Note: You can also use keyboard shortcuts to create members. For more information, see Keyboard and
Mouse Shortcuts in the Class Diagram and Class Details Window (Class Designer).

Modifying Type Members


Class Designer enables you to modify the members of types that are displayed on the diagram. You can modify the
members of any type displayed on a class diagram that are not read-only. (See Display of Read-Only Information
(Class Designer).) You modify type members by using in-place editing on the design surface, Properties window,
and the Class Details window.
All the members displayed in the Class Details window represent the members of the types on the class diagram.
There are four kinds of members: methods, properties, fields, and events.
All member rows appear under headings that group the members by kind. For example, all properties appear
under the heading Proper ties , which, as a node in the grid, can be collapsed or expanded.
Each member row displays the following elements:
Member Icon
Each kind of member is represented by its own icon. Point the mouse at the member icon to display the
member’s signature. Click the member icon or the whitespace to the left of the member icon to select the
row.
Member Name
The Name column in a member row displays the name of the member. This name is also displayed in the
Name property in the Properties window. Use this cell to change the name of any member that has read-
write permissions.
If the Name column is too narrow to show the whole name, pointing the mouse on the member name
displays the entire name.
Member Type
The MemberType cell uses IntelliSense, which lets you select from a list of all the types available in the
current project or referenced projects.
Member Modifier
Change the visibility modifier of a member to either Public ( public ), Private ( private ), Friend (
internal ) Protected ( protected ), Protected``Friend ( protected``internal ), or Default .

<add member>
The last row in the Class Details window contains the text <add member> in the Name cell. If you click
this cell, you can create a new member. For more information, see Creating Members.
Member proper ties in the Proper ties window
The Class Details window displays a subset of the member properties that are displayed in the Properties
window. Changing a property in one location will update the value of the property globally. This includes the
display of its value in the other location.
Summar y
The Summar y cell exposes a summary of information about the member. Click the ellipsis in the
Summar y cell to view or edit information about the Summar y , Return Type , and Remarks for the
member.
Hide
When the Hide check box is selected, the member is not displayed in the type.
To modify a type member
1. Using Class Designer, select a type.
2. If the Class Details window is not displayed, click the Class Details Window button on the Class Designer
toolbar.
3. Edit the values in the fields of the Class Details window grid. After each edit, press ENTER, or otherwise
move focus away from the edited field, for example, by pressing TAB. Your edits reflect immediately in code.

NOTE
If you want to modify only the name of a member, you can do so by using in-place editing.

Adding Parameters to Methods


Add parameters to methods using the Class Details window. Parameters can be configured to be required or
optional. Providing a value for the Optional Default property of a parameter instructs the designer to generate
code as an optional parameter.
Parameter rows contain the following items:
Name
The Name column in a parameter row displays the name of the parameter. This name is also displayed in
the Name property in the Properties window. You can use this cell to change the name of any parameter
with read-write permissions.
Pointing at the parameter name displays the name of the parameter if the Name column is too narrow to
show the entire name.
Type
The Parameter Type cell uses Intellisense, which lets you choose from a list of all the types available in the
current project or referenced projects.
Modifier
The Modifier cell in a parameter row accepts and displays the new modifier of the parameter. To enter a
new parameter modifier, use the drop-down list box to select from None , ref , out , or params in C#, and
ByVal , ByRef , or ParamArray in VB.
Summar y
The Summar y cell in a parameter row allows entering of code comments that appear in IntelliSense when
entering the parameter into the code editor.
<add parameter>
The last parameter row of a member contains the text <add parameter> in the Name cell. Clicking this
cell lets you create a new parameter. For more information, see To add a parameter to a method.
Parameter proper ties in the Proper ties window
The Properties window displays the same parameter properties displayed in the Class Details window:
Name , Type , Modifier , Summar y , as well as the Optional Default property. Changing a property in one
location updates the value of the property globally, including the display of its value in the other location.

NOTE
To add a parameter to a delegate, see Creating Members.

NOTE
Although a destructor is a method, it cannot have parameters.

To add a parameter to a method


1. On the diagram surface, click the type containing the method to which you want to add a parameter.
The type obtains focus and its contents display in the Class Details window.
2. In the Class Details window, expand the row of the method to which you want to add a parameter.
An indented parameter row appears, containing only a pair of parentheses and the words <add
parameter>.
3. Click <add parameter> , type the name of the new parameter, and press Enter .
The new parameter is added to the method and the method’s code. It displays in the Class Details window
and the Properties window.
4. Optionally, specify other details about the parameter, such as its type.
To add an optional parameter to a method
1. On the diagram surface, click the type containing the method to which you want to add an optional
parameter.
The type obtains focus and its contents display in the Class Details window.
2. In the Class Details window, expand the row of the method to which you want to add an optional parameter.
An indented parameter row appears, containing only a pair of parentheses and the words <add
parameter>.
3. Click <add parameter> , type the name of the new parameter, and press Enter .
The new parameter is added to the method and the method’s code. It displays in the Class Details window
and the Properties window.
4. In the Properties window, type a value for the Optional Default property. Setting a parameter's Optional
Default property makes that parameter optional.

NOTE
Optional parameters must be the last parameters in the parameter list.

Class Details Usage Notes


Please note the following tips for using the Class Details window.
Editable and non-editable cells
All cells in the Class Details window are editable with a few exceptions:
The entire type is read-only, when, for example, it resides in a referenced assembly (see Display of Read-
Only Information (Class Designer).) When you select the shape in the Class Designer, the Class Details
window displays its details in a read-only state.
For indexers, the name is read-only and the rest (type, modifier, summary) are editable.
All generics have read-only parameters in the Class Details window. To change a generic parameter, edit its
source code.
The name of the type parameter that is defined on a generic type is read-only.
When a type's code is broken (unparsable), Class Details window displays the type's contents as read-only.
The Class Details Window and source code
You can view source code by right-clicking a shape in the Class Details window (or the Class Designer) and
then clicking View Code. The source code file opens and scrolls to the selected element.
Changing source code is immediately reflected in the display of signature information in the Class Designer
and the Class Details window. If the Class Details window is closed at the time, the new information is visible
the next time you open it.
When a type's code is broken (unparsable), Class Details window displays the type's contents as read only.
Clipboard functionality in the Class Details Window
You can copy or cut fields or rows from the Class Details window and paste them into another type. You can
cut a row only if it is not read-only. When you paste the row, Class Details window assigns a new name
(derived from the name of the copied row) to avoid a conflict.
Display of Read-Only Information
Class Designer and the Class Details window can display the types (and members of types) for the following:
a project that contains a class diagram
a project referenced from a project that contains a class diagram
an assembly referenced from a project that contains a class diagram
In the latter two cases, the referenced entity (a type or member) is read-only in the class diagram that
represents it.
An entire project or portions of it, such as individual files, may be read-only. The most common cases in
which a project or one of its files is read-only are when it is under source-code control (and not checked
out), it exists in an external assembly, or when the operating system considers the files to be read-only.
Source-Code Control
Because a class diagram is saved as a file in a project, you need to check out the project in order to save any
changes you make in Class Designer or the Class Details window.
Read-Only Projects
The project may be read-only for a reason other than source-code control. Closing the project displays a
dialog box asking whether to overwrite the project file, discard changes (don’t save) or cancel the close
operation. If you choose to overwrite, project files are overwritten and made read-write. The new class
diagram file is added.
Read-Only Types
If you try to save a project containing a type whose source-code file is read-only, the Save of Read-Only
File dialog box appears, which gives you choices to save the file under a new name or new location, or to
overwrite the read-only file. If you overwrite the file, the new copy is no longer read-only.
If a code file contains a syntax error, shapes displaying code in that file will be temporarily read-only until
the syntax error is fixed. Shapes in this state display red text and a red icon which displays a tooltip reading
"The source code file contains a parse error".
A referenced type (such as a .NET Framework type), which exists under another project node or under a
referenced-assembly node, is indicated on the Class Designer design surface as read-only. A local type,
which exists in the project you have open, is read-write, and its shape on the Class Designer design surface
is indicated as such.
Indexers are read-write in code and the Class Details window, but the indexer name is read-only.
You cannot edit partial methods by using the Class Designer or the Class Details window; you must use the
Code Editor to edit them.
You cannot edit native C++ code by using the Class Designer or the Class Details window; you must use the
Code Editor to edit native C++ code.

Related Topics
T IT L E DESC RIP T IO N

Viewing Types and Relationships (Class Designer) You can view your existing types, members, and relationships
in a class diagram.
T IT L E DESC RIP T IO N

Refactoring Classes and Types (Class Designer) By using refactoring, you can easily rename type and type
members. You can also move members between classes, split a
class into partial classes, and implement interfaces.
Keyboard and Mouse Shortcuts in the Class Diagram
and Class Details Window (Class Designer)
10/16/2020 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can use the keyboard in addition to the mouse to perform navigational actions in Class Designer and in the
Class Details window.
In this topic
Using the Mouse in Class Designer
Using the Mouse in the Class Details Window
Using the Keyboard in Class Designer
Using the Keyboard in the Class Details Window

Using the Mouse in Class Designer


The following mouse actions are supported in class diagrams:

M O USE C O M B IN AT IO N C O N T EXT DESC RIP T IO N

Double-click Shape elements Opens the code editor.

Lollipop connector Expand/collapse lollipop.

Lollipop connector label Invokes Show Interface command.

Mouse Wheel Class diagram Scroll vertically.

SHIFT + Mouse Wheel Class diagram Scroll horizontally.

CTRL + Mouse Wheel Class diagram Zoom.

CTRL + Shift + click Class diagram Zoom.

Using the Mouse in the Class Details Window


Using a mouse, you can change the appearance of the Class Details window and the data it displays, in the
following ways:
Clicking any editable cell lets you edit the contents of that cell. Your changes are reflected in all places that
data is stored or displayed, including in the Properties window and in source code.
Clicking any cell of a row causes the Properties window to display the properties for the element
represented by that row.
To change the width of a column, drag the boundary on the right side of the column heading until the
column is the width you want.
You can expand or collapse compartment or property nodes by clicking the arrow symbols to the left of the
row.
The Class Details Window offers several buttons for creating new members in the current class and for
navigating among the members’ compartments in the Class Details Window grid. For more information, see
Class Details Window Buttons.

Using the Keyboard in Class Designer


The following keyboard actions are supported in class diagrams:

K EY C O N T EXT DESC RIP T IO N

Arrow keys Inside type shapes Tree-style navigation on shape contents


(wrapping around shape is supported).
Left and right keys expand/collapse
current item if it is expandable and
navigate to parent if not (see tree-view
navigation for detailed behavior).

Top-level shapes Moving shapes on the diagram.

SHIFT+arrow keys Inside type shapes Building continuous selection consisting


of shape elements such as members,
nested types, or compartments. These
shortcuts do not support wrapping
around.

HOME Inside type shapes Navigate to the top-level shape title.

Top-level shapes Navigate to first shape on the diagram.

END Inside type shapes Navigate to last visible element inside


the shape.

Top-level shapes Navigate to the last shape on the


diagram.

SHIFT+HOME Inside type shape Selects elements within the shape


starting with the current item and
ending with the top-most item on the
same shape.

SHIFT+END Inside type shape Same as SHIFT+HOME but in top-down


direction.

ENTER All contexts Invokes default action on the shape


which is also available via double-click.
In most cases this is View Code but
some elements define it differently
(lollipops, compartment headers,
lollipop labels).
K EY C O N T EXT DESC RIP T IO N

+/- All contexts If currently focused element is


expandable, these keys expand/collapse
the element.

> All contexts On elements with children, this expands


the element if it is collapsed and
navigates to first child.

< All contexts Navigates to the parent element.

ALT+SHIFT+L Inside type shapes + on type shapes. Navigates to the lollipop of currently
selected shape if it is present.

ALT+SHIFT+B Inside type shapes + on type shapes. If base type list is shown on the type
shape and has more than one item, this
toggles expansion state of the list
(collapse/expand).

DELETE On type and comment shapes Invokes Remove from Diagram


command.

On everything else. Invokes Delete from Code command


(members, parameters, associations,
inheritance, lollipop labels).

CTRL+DELETE All contexts Invokes Delete from Code command


on selection.

TAB All contexts Navigates to next child within the same


parent (supports wrapping).

SHIFT+TAB All contexts Navigates to previous child within the


same parent (supports wrapping).

SPACE All contexts Toggles selection on the current


element.

Using the Keyboard in the Class Details Window


NOTE
The following key bindings were chosen to specifically to mimic the experience of typing code.

Use the following keys to navigate the Class Details window:

K EY RESULT
K EY RESULT

, (comma) If the cursor is in a parameter row, typing a comma moves the


cursor to the Name field of the next parameter. If the cursor is
in the last parameter row of a method, it moves the cursor to
the <add parameter> field, which you can use to create a new
parameter.

If the cursor is elsewhere in the Class Details Window, typing a


comma literally adds a comma in the current field.

; (semicolon) Move the cursor to the Name field of the next member row in
the Class Details Window grid.
or

) (close parenthesis)

Tab Moves the cursor to the next field, first moving left to right
and then top to bottom. If the cursor is moving from a field in
which you have typed text, Class Details Window processes
that text and stores it if it does not produce an error.

If the cursor is on an empty field such as <add parameter>,


Tab moves it to the first field of the next row.

<space> Moves the cursor to the next field, first moving left to right
and then top to bottom. If the cursor is on an empty field
such as <add parameter>, it moves to the first field of the
next row. Note that <space> typed immediately after a
comma is ignored.

If the cursor is in the Summary field, typing a space adds a


space character.

If the cursor is in the Hide column of a given row, typing a


space toggles the value of the Hide checkbox.

CTRL+Tab Switch to another document window. For example, switch


from the Class Details Window to an open code file.

ESC (Escape) If you have begun to type text in a field, pressing ESC acts as
an undo key, reverting the field's contents to its previous
value. If the Class Details Window has general focus, but no
specific cell has focus, pressing ESC moves focus away from
the Class Details Window.

Up arrow and down arrow These keys move the cursor from row to row vertically in the
Class Details Window grid.

Left arrow If the cursor is in the Name column, pressing the left arrow
collapses the current node in the hierarchy (if it is open).

Right arrow If the cursor is in the Name column, pressing the right arrow
expands the current node in the hierarchy (if it is collapsed).

See Also
Creating and Configuring Type Members (Class Designer)
Viewing Types and Relationships (Class Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Class Designer uses class diagrams to show you the details of types, for example, their constituent members, and
the relationships that they share. The visualization of these entities is actually a dynamic view into the code. This
means that you can edit types on the designer and then see your edits reflected in the source code of the entity.
Similarly, the class diagram is kept synchronized with changes you make to entities in code.

NOTE
If your project contains a class diagram and if your project references a type that is located in another project, the class
diagram does not show the referenced type until you build the project for that type. Likewise, the diagram does not
display changes to the code of the external entity until you rebuild the project for that entity. For information about type
in referenced assemblies and read-only files, see Display of Read-Only Information (Class Designer).

In This Section
How to: View Existing Types (Class Designer)
Describes how Class Designer can be used to visualize pre-existing code.
How to: View Inheritance Between Types (Class Designer)
Describes how to view the inheritance relationships between types.
How to: Change Between Member Notation and Association Notation (Class Designer)
Describes how to switch between member notation and association notation.

Related Sections
Designing Classes and Types (Class Designer)
Refactoring Classes and Types (Class Designer)
How to: Customize Class Diagrams (Class Designer)
Working with Class Diagrams (Class Designer)
How to: View Existing Types (Class Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

To see an existing type and its members, add its shape to a class diagram.
You can see local and referenced types. A local type exists in the currently open project and is read/write. A
referenced type exists in another project or in a referenced assembly and is read-only.
To design new types on class diagrams, see How to: Create Types by using Class Designer.
To see types in a project on a class diagram
1. From a project in Solution Explorer, open an existing class diagram (.cd) file. Or if no class diagram exists,
add a new class diagram to the project. See How to: Add Class Diagrams to Projects (Class Designer).
2. From the project in Solution Explorer, drag a source code file to the class diagram.

WARNING
If your solution has a project that shares code across multiple apps, you can drag files or code to a class diagram
only from these sources:
The app project that contains the diagram
A shared project that was imported by the app project
A referenced project
An assembly

Shapes representing the types defined in the source code file appear on the diagram at the position where
you dragged the file.
You can also view types in the project by dragging one or more types from the project node in Class View
to the class diagram.

TIP
If Class View is not open, open Class View from the View menu. For more information about Class View, see Viewing Classes
and Their Members.

To display types at default locations on the diagram, select one or more types in Class View, right-click the selected
types, and choose View Class Diagram .

NOTE
If a closed class diagram containing the type already exists in the project, the class diagram opens to display the type shape.
However, if no class diagram containing the type exists in the project, Class Designer creates a new class diagram in the
project and opens it to display the type.
When you first display a type on the diagram, its shape appears collapsed by default. You can expand the shape to
view its contents.
To display the contents of a project in a class diagram
1. In Solution Explorer or Class View, right-click the project and choose View , then choose View Class
Diagram .
An auto-populated Class Diagram is created.

See Also
How to: View Inheritance Between Types (Class Designer) How to: Customize Class Diagrams (Class Designer)
Viewing Types and Relationships (Class Designer)
How to: View Inheritance Between Types (Class
Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can find the inheritance relationship, if it exists, between a base type and its derived types on a class diagram
in Class Designer. To create an inheritance relationship, if none exist, between two types, see How to: Create
Inheritance Between Types (Class Designer).
To find the base type
1. On the class diagram, click the type for which you want to see the base class or interface.
2. On the Class Diagram menu, choose Show Base Class or Show Base Interfaces .
The type's base class or interface appears selected on the diagram. Any hidden inheritance lines now appear
between the two shapes.
You can also right-click the type whose base type you want to display, and choose Show Base Class or
Show Base Interfaces .
To find the derived types
1. On the class diagram, click the type for which you want to see the derived classes or interfaces.
2. On the Class Diagram menu, choose Show Derived Classes or Show Derived Interfaces .
The type’s derived classes or interfaces appear on the diagram. Any hidden inheritance lines now appear
between the shapes.
You can also right-click the type for which you want to see its derived types, and choose Show Derived
Classes or Show Derived Interfaces .

See Also
How to: Create Associations Between Types (Class Designer) Viewing Types and Relationships (Class Designer)
How to: Change Between Member Notation and
Association Notation (Class Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In Class Designer, you can change the way the class diagram represents an association relationship between two
types from member notation to association notation and vice versa. Members displayed as association lines often
provide a useful visualization of how types are related.

NOTE
Association relationships can be represented as a member property or field. To change member notation to association
notation, one type must have a member of another type. To change association notation to member notation, the two types
must be connected by an association line. For more information, see How to: Create Associations Between Types (Class
Designer). If your project contains multiple class diagrams, changes that you make to the way a diagram displays association
relationships affect only that diagram. To change the way another diagram displays association relationships, open or display
that diagram and perform these steps.

To change member notation to association notation


1. From the project node in Solution Explorer, open the class diagram (.cd) file.
2. In the type shape on the class diagram, right-click the member property or field representing the
association, and choose Show as Association .

TIP
If no properties or fields are visible in the type shape, the compartments in the shape might be collapsed. To expand
the type shape, double-click the compartment name or right-click the type shape, and choose Expand .

The member disappears from the compartment in the type shape and an association line appears to
connect the two types. The association line is labeled with the name of the property or field.
To change association notation to member notation
On the class diagram, right-click the association line, and choose Show as Proper ty or Show as Field as
appropriate.
The association line disappears, and the property displays in the appropriate compartment within its type
shape on the diagram.

See Also
How to: Create Inheritance Between Types (Class Designer) How to: View Inheritance Between Types (Class
Designer) Viewing Types and Relationships (Class Designer) How to: Visualize a Collection Association (Class
Designer)
Refactoring Classes and Types (Class Designer)
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

When you refactor code, you make it easier to understand, maintain, and more efficient by changing its internal
structure and how its objects are designed, not its external behavior. Use Class Designer and the Class Details
window to reduce the work that you have to do and the chance of introducing bugs when you refactor Visual C#
.NET, Visual Basic .NET, or C++ code in your Visual Studio project.

NOTE
The files of a project might be read-only because the project is under source-code control and is not checked out; it is a
referenced project; or its files are marked as read-only on disk. When you work in a project in one of these states, you will
be presented with various ways to save your work depending on the project’s state. This applies to refactoring code and also
to code that you change in another way, such as directly editing it. For more information, see Display of Read-Only
Information (Class Designer).

Common Tasks
TA SK SUP P O RT IN G C O N T EN T

Refactoring classes: You can use refactoring operations to - How to: Split a Class into Partial Classes (Class Designer)
split a class into partial classes or to implement an abstract
base class.

Working with interfaces: In Class Designer, you can - How to: Implement an Interface (Class Designer)
implement an interface on the class diagram by connecting it
to a class that provides code for the interface methods.

Refactoring types, type members, and parameters: By - Renaming Types and Type Members
using Class Designer, you can rename types, override type - Moving Type Members from One Type to Another
members, or move them from one type to another. You can - How to: Create a Nullable Type (Class Designer)
also create nullable types.

Renaming Types and Type Members


In Class Designer, you can rename a type or a member of a type on the class diagram or in the Properties window.
In the Class Details window, you can change the name of a member but not a type. Renaming a type or type
member propagates to all windows and code locations where the old name appeared.
To r e n a m e a n a m e i n t h e C l a ss D e si g n e r

1. On the class diagram, select the type or member and click on the name.
The name of the member becomes editable.
2. Type the new name for the type or type member
To r e n a m e a n a m e i n t h e C l a ss D e t a i l s W i n d o w
1. To display the Class Details window, right-click the type or type member and then click Class Details .
The Class Details window appears.
2. In the Name column, change the name of the type member
3. To move focus away from the cell, press the ENTER key or click away from the cell.

NOTE
In the Class Details window, you can change the name of a member but not a type.

To r e n a m e a n a m e i n t h e P r o p e r t i e s w i n d o w

1. On the class diagram or the Class Details window, right-click the type or member and then click
Proper ties .
The Properties window appears and displays properties for the type or type member.
2. In the Name property, change the name of the type or type member.
The new name propagates to all windows and code locations in the current project where the old name
appeared.
Moving Type Members from One Type to Another
Using Class Designer , you can move a type member from one type to another type, if both are visible in the
current class diagram.
To m o v e a t y p e m e m b e r fr o m o n e t y p e t o a n o t h e r

1. In a type that is visible on the design surface, right-click the member you want to move to another type, and
then click Cut .
2. Right-click the destination type and then click Paste .
The property is removed from the source type and appears in the destination type.

Related Topics
T IT L E DESC RIP T IO N

Viewing Types and Relationships (Class Designer)

Designing Classes and Types (Class Designer)


How to: Implement an Interface (Class Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In Class Designer, you can implement an interface on the class diagram by connecting it to a class that provides
code for the interface methods. Class Designer generates an interface implementation and displays the relationship
between the interface and the class as an inheritance relationship. You can implement an interface by drawing an
inheritance line between the interface and the class or by dragging the interface from Class View.

TIP
You can create interfaces the same way you create other types. If the interface exists but does not appear on the class
diagram, then first display it. For more information, see How to: Create Types by using Class Designer and How to: View
Existing Types (Class Designer).

To implement an interface by drawing an inheritance line


1. On the class diagram, display the interface and the class that will implement the interface.
2. Draw an inheritance line from the class and the interface.
A lollipop appears attached to the class and a label with the interface name identifies the inheritance
relationship. Visual Studio generates stubs for all interface members.
For more information, see How to: Create Inheritance Between Types (Class Designer).
To implement an interface from the Class View window
1. On the class diagram, display the class that you want to implement the interface.
2. Open Class View and locate the interface.

TIP
If Class View is not open, open Class View from the View menu. For more information about Class View, see Viewing
Classes and Their Members.

3. Drag the interface node to the class shape on the diagram.


A lollipop appears attached to the class and a label with the interface name identifies the inheritance
relationship. Visual Studio generates stubs for all interface members; at this point, the interface is
implemented.

See Also
How to: Create Types by using Class Designer How to: View Existing Types (Class Designer) How to: Create
Inheritance Between Types (Class Designer) Refactoring Classes and Types (Class Designer)
How to: Split a Class into Partial Classes (Class
Designer)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can divide the declaration of a class or structure among several declarations by using the Partial keyword in
Visual Basic or the partial keyword in Visual C#. You can use as many partial declarations as you want, in as many
different source files as you want, or in one source file. However, all the declarations must be in the same assembly
and the same namespace.
Partial classes are useful in several situations. For example, when you are working on large projects, separating a
class into more than one file enables more than one programmer to work on it at the same time. When you are
working with code that Visual Studio generates, you can change the class without having to re-create the source
file. (Examples of code that Visual Studio generates include Windows Forms and Web Service wrapper code.) You
can thus create code that uses auto-generated classes without having to modify the file that Visual Studio creates.
There are two kinds of partial methods. In Visual C#, they are called declaring and implementing; in Visual Basic,
they are called declaration and implementation.
Class Designer supports partial classes and methods. The type shape in the class diagram refers to a single
declaration location for the partial class. If the partial class is defined in multiple files, you can specify which
declaration location Class Designer will use by setting the New Member Location property in the Proper ties
window. That is, when you double-click a class shape, Class Designer goes to the source file that contains the class
declaration identified by the New Member Location property. When you double-click a partial method in a class
shape, Class Designer goes to the partial method declaration. Also, in the Proper ties window, the File Name
property refers to the declaration location. For partial classes, File Name lists all of the files that contain
declaration and implementation code for that class. However, for partial methods, File Name lists only the file that
contains the partial method declaration.
The following examples split the definition of class Employee into two declarations, each of which defines a
different procedure. The two partial definitions in the examples could be in one source file or in two different
source files.

NOTE
Visual Basic uses partial-class definitions to separate Visual Studio—generated code from user-authored code. The code is
separated into discrete source files. For example, the Windows Form Designer defines partial classes for controls such as
Form . You should not modify the generated code in these controls.

For more information about partial types in Visual Basic, see Partial.

Example
To split a class definition in Visual Basic, use the Partial keyword, as shown in the following example.
' First part of class definition.
Partial Public Class Employee
Public Sub CalculateWorkHours()
End Sub
End Class

' Second part of class definition.


Partial Public Class Employee
Public Sub CalculateTaxes()
End Sub
End Class

Example
To split a class definition in Visual C#, use the partial keyword, as shown in the following example.

// First part of class definition.


public partial class Employee
{
public void CalculateWorkHours()
{
}
}

// Second part of class definition.


public partial class Employee
{
public void CalculateTaxes()
{
}
}

See Also
Partial Classes and Methods partial (Type) partial (Method) (C# Reference) Partial
How to: Create a Nullable Type (Class Designer)
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Certain value types do not always have (or need) a defined value. This is common practice in databases, where
some fields might not be assigned any value. For example, you might assign a null value to a database field to
signify that it has not yet been assigned a value.
A nullable type is a value type that you extend so that it takes the typical range of values for that type and also a
null value. For example, a nullable of Int32 , also denoted as Nullable<Int32>, can be assigned any value from -
2147483648 to 2147483647, or it can be assigned a null value. A Nullable<bool> can be assigned the values
True , False , or null (no value at all).

Nullable types are instances of the Nullable<T> structure. Each instance of a nullable type has two public read-only
properties, HasValue and Value :
HasValue is of type bool and indicates whether the variable contains a defined value. True means that the
variable contains a non-null value. You can test for a defined value by using a statement such as
if (x.HasValue) or if (y != null) .

Value is of the same type as the underlying type. If HasValue is True , Value contains a meaningful value.
If HasValue is False , accessing Value will throw an invalid operation exception.
By default, when you declare a variable as a nullable type, it has no defined value ( HasValue is False ), other
than the default value of its underlying value type.
Class Designer displays a nullable type just as it displays its underlying type.
For more information about nullable types in Visual C#, see Nullable Types. For more information about
nullable types in Visual Basic, see Nullable Value Types.

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the
following instructions. The Visual Studio edition that you have and the settings that you use determine these
elements. For more information, see Personalizing the IDE.

To add a nullable type by using the Class Designer


1. In the Class Diagram, expand an existing class or create a new class.
2. To add a class to the project, on the Class Diagram menu, click Add , and then click Add Class .
3. To expand the class shape, on the Class Diagram menu, click Expand .
4. Select the class shape. On the Class Diagram menu, click Add , and then click Field . A new field that has the
default name Field will appear in the class shape and also in the Class Details window.
5. In the Name column of the Class Details window (or in the class shape itself), change the name of the new
field to a valid and meaningful name.
6. In the Type column of the Class Details window, declare the type as a nullable type, as shown in the
following code:

// Declare a nullable type in Visual C#:


class Test
{
int? building_number = 5;
}

' Declare a nullable type in Visual Basic:


Class Test
Dim buildingNumber As Nullable(Of Integer) = 5
End Class

To add a nullable type by using the Code Editor


1. Add a class to the project. Select the project node in Solution Explorer , and, on the Project menu, click
Add Class .
2. In the .cs or .vb file for the new class, add one or more nullable types in the new class to the class declaration.
3. From Class View, drag the new class icon to the Class Designer design surface. A class shape appears in the
class diagram.
4. Expand the details for the class shape and move the mouse pointer over the class members. The tooltip
displays the declaration of each member.
5. Right-click the class shape and click Class Details . You can view or modify the new type's properties in the
Class Details window.

See Also
Nullable<T> Nullable Types Using Nullable Types How to: Identify a Nullable Type Nullable Value Types
Working with Visual C++ Code (Class Designer)
1/10/2020 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Class Designer displays a visual design surface called a class diagram that provides a visual representation of the
code elements in your project. You can use class diagrams to design and visualize classes and other types in a
project.
Class Designer supports the following C++ code elements:
Class (resembles a managed class shape, except that it can have multiple inheritance relationships)
Anonymous class (displays Class View's generated name for the anonymous type)
Template class
Struct
Enum
Macro (displays the post-processed view of the macro)
Typedef

NOTE
This is not the same as the UML class diagram, which you can create in a Modeling Project. For more information, see UML
Class Diagrams: Reference.

Troubleshooting Type Resolution and Display Issues


Location of Source Files
Class Designer does not keep track of the location of source files. Therefore, if you modify your project structure or
move source files in your project, Class Designer can lose track of the type (especially the source type of a typedef,
base classes, or association types). You might receive an error such as Class Designer is unable to display this
type . If you do, drag the modified or relocated source code to the class diagram again to redisplay it.
Update and Performance Issues
For Visual C++ projects, it might take 30 to 60 seconds for a change in the source file to appear in the class
diagram. This delay might also cause Class Designer to throw the error No types were found in the selection .
If you receive an error such as this, click Cancel in the error message and wait for the code element to appear in
Class View. After you do this, Class Designer should be able to display the type.
If a class diagram does not update with changes you have made in the code, you might need to close the diagram
and open it again.
Type Resolution Issues
Class Designer might not be able to resolve types for the following reasons:
The type is in a project or assembly that is not referenced from the project that contains the class diagram.
To correct this error, add a reference to the project or assembly that contains the type. For more information,
see NIB How to: Add or Remove References By Using the Add Reference Dialog Box.
The type is not in the correct scope, so Class Designer cannot locate it. Ensure that the code is not missing a
using , imports , or #include statement. Also make sure that you have not moved the type (or a related
type) out of the namespace in which it was originally located.
The type does not exist (or has been commented out). To correct this error, make sure that you have not
commented out or deleted the type.
The type is located in a library referenced by an #import directive. A possible workaround is to manually
add the generated code (the .tlh file) to an #include directive into the header file.
The error you are most likely to see for a type resolution issue is Code could not be found for one or
more shapes in class diagram '<element>' . This error message does not necessarily indicate that your
code is in error. It indicates only that class designer was unable to display your code. Try the following
measures.
Ensure that the type exists. Ensure that you have not unintentionally commented out or deleted the source
code.
Ensure that Class Designer supports the type that you entered. See Limitations for C++ Code Elements.
Try to resolve the type. The type might be in a project or assembly that is not referenced from the project
that contains the class diagram. To correct this error, add a reference to the project or assembly that
contains the type. For more information, see NIB How to: Add or Remove References By Using the Add
Reference Dialog Box.
Ensure that the type is in the correct scope so that Class Designer can locate it. Make sure that the code is
not missing a using , imports , or #include statement. Also make sure that you have not moved the type
(or a related type) out of the namespace in which it was originally located.
Troubleshooting Other Error Messages
You can find assistance with troubleshooting errors and warnings in the Microsoft Developer Network (MSDN)
public forums. See the Visual Studio Class Designer Forum.

Limitations for C++ Code Elements


When a Visual C++ project is loaded, Class Designer functions in a read-only manner. You can change the
class diagram, but you cannot save changes from the class diagram back to the source code.
Class Designer supports only native C++ semantics. For Visual C++ projects that are compiled into
managed code, Class Designer will only visualize code elements that are native types. Therefore, you can
add a class diagram to a project, but Class Designer will not allow you to visualize elements in which the
IsManaged property is set to true (that is, value types and reference types).

For Visual C++ projects, the Class Designer reads only the definition of the type. For example, assume that
you define a type in a header (.h) file and define its members in an implementation (.cpp) file. If you invoke
"View Class Diagram" on the implementation (.cpp) file, Class Designer displays nothing. As another
example, if you invoke "View Class Diagram" on a .cpp file that uses an #include statement to include other
files but does not contain any actual class definitions, Class Designer again displays nothing.
IDL (.idl) files, which define COM interfaces and type libraries, do not display in diagrams unless they are
compiled to native C++ code.
Class Designer does not support global functions and variables.
Class Designer does not support unions. This is a special type of class in which the memory allocated is
only the amount necessary for the union's largest data member.
Class Designer does not display basic data types such as int and char .
Class Designer does not display types that are defined outside the current project if the project does not
have correct references to those types.
Class Designer can display nested types but not the relationships between a nested type and other types.
Class Designer cannot display types that are void or that derive from a void type.

See Also
Designing and Viewing Classes and Types Working with Classes and Other Types (Class Designer) Working with
Class Diagrams (Class Designer) Designing Classes and Types (Class Designer) Additional Information About Class
Designer Errors Visual C++ Classes in Class Designer Visual C++ Structures in Class Designer Visual C++
Enumerations in Class Designer Visual C++ Typedefs in Class Designer
Visual C++ Classes in Class Designer
10/18/2019 • 6 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Class Designer supports C++ classes and visualizes native C++ classes in the same way as Visual Basic and Visual
C# class shapes, except that C++ classes can have multiple inheritance relationships. You can expand the class
shape to show more fields and methods in the class or collapse it to conserve space.

NOTE
Class Designer does not support unions (a special type of class in which the memory allocated is only the amount necessary
for the union's largest data member).

Simple Inheritance
When you drag more than one class onto a class diagram, and the classes have a class inheritance relationship, an
arrow connects them. The arrow points in the direction of the base class. For example, when the following classes
are displayed in a class diagram, an arrow connects them, pointing from B to A:

class A {};
class B : A {};

You can also drag only class B to the class diagram, right-click the class shape for B, and then click Show Base
Classes . This displays its base class: A.

Multiple Inheritance
Class Designer supports the visualization of multiple-class inheritance relationships. Multiple inheritance is used
when a derived class has attributes of more than one base class. Following is an example of multiple inheritance:

class Bird {};


class Swimmer {};
class Penguin : public Bird, public Swimmer {};

When you drag more than one class onto the class diagram, and the classes have a multiple-class inheritance
relationship, an arrow connects them. The arrow points in the direction of the base classes.
Right-clicking a class shape and then clicking Show Base Classes displays the base classes for the selected class.

NOTE
The Show Derived Classes command is not supported for C++ code. You can display derived classes by going to Class
View, expanding the type node, expanding the Derived Types subfolder, and then dragging those types onto the class
diagram.
For more information about multiple-class inheritance, see (NOTINBUILD) Multiple Inheritance and Multiple Base
Classes.

Abstract Classes
Class Designer supports abstract classes (also named "abstract base classes"). These are classes that you never
instantiate, but from which you can derive other classes. Using an example from "Multiple Inheritance" earlier in
this document, you might instantiate the Bird class as individual objects as follows:

int main()
{
Bird sparrow;
Bird crow;
Bird eagle;
}

However, you might not intend to instantiate the Swimmer class as individual objects. You might intend only to
derive other types of animal classes from it, for example, Penguin , Whale , and Fish . In that case, you would
declare the Swimmer class as an abstract base class.
To declare a class as abstract, you can use the abstract keyword. Members marked as abstract, or included in an
abstract class, are virtual and must be implemented by classes that derive from the abstract class.

class Swimmer abstract


{
virtual void swim();
void dive();
};

You can also declare a class as abstract by including at least one pure virtual function:

class Swimmer
{
virtual void swim() = 0;
void dive();
};

When you display these declarations in a Class Diagram, the class name Swimmer and its pure virtual function
swim are in displayed in italic in an abstract class shape, together with the notation Abstract Class . Notice that
the abstract class type shape is the same as that of a regular class, except that its border is a dotted line.
A class derived from an abstract base class must override each pure virtual function in the base class, or the
derived class cannot be instantiated. So, for example, if you derive a Fish class from the Swimmer class, Fish
must override the swim method:

class Fish : public Swimmer


{
void swim(int speed);
};

int main()
{
Fish guppy;
}

When you display this code in a Class Diagram, Class Designer draws an inheritance line from Fish to Swimmer .
Anonymous Classes
Class Designer supports anonymous classes. Anonymous class types are classes declared without an identifier.
They cannot have a constructor or destructor, cannot be passed as arguments to functions, and cannot be returned
as return values from functions. You can use an anonymous class to replace a class name with a typedef name, as
in the following example:

typedef struct
{
unsigned x;
unsigned y;
} POINT;

Structures can also be anonymous. Class Designer displays anonymous classes and structures the same as it
displays the respective type. Although you can declare and display anonymous classes and structures, Class
Designer will not use the tag name that you specify. It will use the name that Class View generates. The class or
structure appears in Class View and Class Designer as an element called __unnamed .
For more information about anonymous classes, see Anonymous Class Types.

Template Classes
Class Designer supports the visualization of template classes. Nested declarations are supported. The following
table shows some typical declarations.

C O DE EL EM EN T C L A SS DESIGN ER VIEW

template <class T> A<T>

class A {}; Template Class

template <class T, class U> A<T, U>

class A {}; Template Class

template <class T, int i> A<T, i>

class A {}; Template Class

template <class T, template <class K> class U> A<T, U>

class A {}; Template Class

The following table shows some examples of partial specialization.

C O DE EL EM EN T C L A SS DESIGN ER VIEW

template<class T, class U> A<T, U>

class A {}; Template Class

template<class T> A<T, T>

class A<T, T> {}; Template Class


C O DE EL EM EN T C L A SS DESIGN ER VIEW

template <class T> A<T, int>

class A<T, int> {}; Template Class

template <class T1, class T2> A<T1*, T2*>

class A<T1*, T2*> {}; Template Class

The following table shows some examples of inheritance in partial specialization.

C O DE EL EM EN T C L A SS DESIGN ER VIEW

template <class T, class U> A<T, U>

class A {}; Template Class

template <class TC> B

class A<T, int> {}; Class

class B : A<int, float> (points to Class A)

{}; C

class C : A<int, int> Class

{};
(points to Class A)

The following table shows some examples of partial specialization template functions.

C O DE EL EM EN T C L A SS DESIGN ER VIEW

class A A

{ func<T, U> (+ 1 overload)

template <class T, class U>

void func(T a, U b);

template <class T>

void func(T a, int b);

};
C O DE EL EM EN T C L A SS DESIGN ER VIEW

template <class T1> A<T1>

class A { Template Class

template <class T2> B<T2>

class B {}; Template Class

}; (B is contained within class A under Nested Types )

template<> template<>

class A<type>::B<type> {};

template <class T> A

class C {}; Class

class A : C<int> {}; -> C<int>

C<T>

Template Class

The following table shows some examples of template inheritance.

C O DE EL EM EN T C L A SS DESIGN ER VIEW

template <class T> A

class C {}; Class

template<> ->B

class C<int> { C<int>

class B {}; Class

} (B is contained within class C under Nested Types )

C<T>
class A : C<int>::B {};

Template Class

The following table shows some examples of canonical specialized class connection.
C O DE EL EM EN T C L A SS DESIGN ER VIEW

template <class T> A

class C {}; Class

template<> ->C<int>

class C<int> {}; C<int>

class A : C<int> {}; Class

class D : C<float> {}; C<T>

Template Class

Class

->C<float>

class B { B

template <class T> min <T>

T min (const T &a, const T &b);

};

See Also
Working with Visual C++ Code (Class Designer) Classes and Structs Anonymous Class Types (NOTINBUILD)
Multiple Inheritance Multiple Base Classes Templates
Visual C++ Structures in Class Designer
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Class Designer supports C++ structures, which are declared with the keyword struct . Following is an example:

struct MyStructure
{
char a;
int i;
long j;
};

For more information about using the struct type, see struct.
A C++ structure shape in a class diagram looks and works like a class shape, except that the label reads Struct and
it has square corners instead of rounded corners.

C O DE EL EM EN T C L A SS DESIGN ER VIEW

struct StructureName {}; StructureName

Struct

See Also
Working with Visual C++ Code (Class Designer) Classes and Structs struct
Visual C++ Enumerations in Class Designer
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Class Designer supports C++ enum and scoped enum class types. Following is an example:

enum CardSuit {
Diamonds = 1,
Hearts = 2,
Clubs = 3,
Spades = 4
};

// or...
enum class CardSuit {
Diamonds = 1,
Hearts = 2,
Clubs = 3,
Spades = 4
};

A C++ enumeration shape in a class diagram looks and works like a structure shape, except that the label reads
Enum or Enum class , it is pink instead of blue, and it has a colored border on the left and top margins. Both
enumeration shapes and structure shapes have square corners.
For more information about using the enum type, see Enumerations.

See Also
Working with Visual C++ Code (Class Designer) Enumerations
Visual C++ Typedefs in Class Designer
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Typedef statements create one or more layers of indirection between a name and its underlying type. The Class
Designer supports C++ typedef types, which are declared with the keyword typedef , for example:

typedef class coord


{
void P(x,y);
unsigned x;
unsigned y;
} COORD;

You can then use this type to declare an instance:


COORD OriginPoint;

Although you can declare a typedef without a name, Class Designer will not use the tag name that you specify; it
will use the name that Class View generates. For example, the following declaration is valid, but it appears in Class
View and Class Designer as an object named __unnamed :

typedef class coord


{
void P(x,y);
unsigned x;
unsigned y;
};

For more information about using the typedef type, see (NOTINBUILD)typedef Specifier.
A C++ typedef shape has the shape of the type specified in the typedef. For example, if the source declares
typedef class , the shape has rounded corners and the label Class . For typedef struct , the shape has square
corners and the label Struct .
Classes and structures can have nested typedefs declared within them; therefore, class and structure shapes can
show nested typedef declarations as nested shapes.
Typedef shapes support the Show as Association and Show as Collection Association commands on the
context menu.
The following are some examples of typdef types that the Class Designer supports:
typedef type name

name : type
typedef
Draws an association line connecting to type name, if possible.
typedef void (*func)(int)

func: void (*)(int)

typedef
Typedef for function pointers. No association line is drawn.
Class Designer does not display a typedef if its source type is a function pointer.

typedef int MyInt;


class A {
MyInt I;
};

MyInt: int

typedef
A

Class
Draws an association line pointing from the source type shape to the target type shape.
Class B {};

typedef B MyB;

Class
MyB : B

typedef
Right-clicking a typedef shape and clicking Show As Association displays the typedef or class and an Alias of
line joining the two shapes (similar to an association line).
typedef B MyB;

typedef MyB A;

MyBar : Bar

typedef
Same as above.

Class B {};
typedef B MyB;

class A {
MyB B;
};

Class
MyB : B
typedef
A

Class
MyB is a nested typedef shape.
#include <vector>

...

using namespace std;

...

typedef vector<int> MyIntVect;

vector<T> Class
MyIntVect : vector<int>

typedef
class B {};

typedef B MyB;

class A : MyB {};

MyB : B

typedef
-> B
B

Class
-> MyB
Class Designer does not support displaying this kind of relationship by using a context menu command.
#include <vector>

Typedef MyIntVect std::vector<int>;

Class MyVect : MyIntVect {};

std::vector<T>

Class
MyIntVect : std::vector<int>

typedef
MyVect

Class
-> MyIntVect
See Also
Working with Visual C++ Code (Class Designer) (NOTINBUILD)typedef Specifier
Additional Information About Class Designer Errors
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Class Designer does not track the location of your source files, so modifying your project structure or moving
source files in the project can cause Class Designer to lose track of the type (especially the source type of a typedef,
base classes, or association types). You might receive an error such as Class Designer is unable to display this
type . If you do, drag the modified or relocated source code to the class diagram again to redisplay it.
You can find assistance with other errors and warnings in the following resources:
Working with Visual C++ Code (Class Designer) Includes troubleshooting information about displaying C++ in a
class diagram.
Visual Studio Class Designer Forum Provides a forum for questions about the Class Designer.

See Also
Designing and Viewing Classes and Types
Setting Bookmarks in Code
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can use bookmarks to mark lines in your code so that you can quickly return to a specific location and jump
back and forth between locations.
Bookmark commands and icons are available in two places: the bookmark window (View/Bookmark Window )
and the text editor toolbar.

Managing Bookmarks
To add a bookmark, place the cursor on the line you want to bookmark. Click the Toggle button, or press CTRL+K.
This adds the bookmark. If you click the Toggle button (or press CTRL+K) again, the bookmark is removed. You
can also delete bookmarks by clicking the Delete button in the bookmark window.

IMPORTANT
The bookmark is set to the line number, not to the code. If you modify the code, the bookmark is retained at the line
number, and does not move with the code.

You can navigate between bookmarks by using the Next Bookmark and Previous Bookmark buttons in the
bookmark window.
You can organize bookmarks into virtual folders by clicking New Folder in the bookmark window and then
dragging selected bookmarks into the new folder.
You can turn off bookmarks (without removing them) by clicking the Disable All Bookmarks button in the
bookmark window. You can re-enable them by clicking the same button (which is now called Enable All
Bookmarks ).
Using the Task List
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the Task List to track code comments that use tokens such as TODO and HACK , or custom tokens, and to
manage shortcuts that will take you directly to a predefined location in the code. Click on the item in the list to go
to its location in the source code.
In this topic:
The Task List window
User Tasks
Tokens and comments
Custom tokens
C++ TODO comments
Shortcuts

The Task List window


When the Task List is open, it appears at the bottom of the application window.
To open the Task List
On the View menu, choose Task List (Keyboard: Ctrl+\,T).

To change the sort order of the list


Click the header of any column. To further refine your search results, press Shift and click a second column
header.
As an alternative, on the shortcut menu, choose Sor t by , and choose a header. To further refine your search
results, press Shift and choose a second header.
To show or hide columns
On the shortcut menu, choose Show Columns . Choose the columns that you want to show or hide.
To change the order of the columns
Drag any column header to the location that you want.

User Tasks
The user task feature has been removed in Visual Studio 2015. When you open a solution which has user task data
from Visual Studio 2013 and earlier in Visual Studio 2015, the user task data in your .suo file will not be affected,
but the user tasks will not be displayed in the task list.
If you wish to continue to access and update your user task data, you should open the project in Visual Studio 2013
and copy the content of any user tasks into your preferred project management tool (such as Team Foundation
Server).

Tokens and comments


A comment in your code preceded by a comment marker and a predefined token will also appear in the Task List
window. For example, the following C# comment has three distinct parts:
The comment marker ( // )
The token, for example ( TODO )
The comment (the rest of the text)

// TODO: Load state from previously suspended application

Because TODO is a predefined token, this comment appears as a TODO task in the list.
Custom tokens
By default, Visual Studio includes the following tokens: HACK, TODO, UNDONE, NOTE. These are not case sensitive.
You can also create your own custom tokens.
To c r e a t e a c u st o m t o k e n

1. On the Tools menu, choose Options .


2. Open the Environment folder and then choose Task List .
The Task List, Environment, Options Dialog Box is displayed.
3. In the Tokens category, in the Name text box, enter your token name, for example "BUG".
4. In the Priority drop-down list, choose a default priority for the new token. Choose the Add button.
C++ TODO comments
By default, C++ TODO comments are displayed in the Task List window. You can change this behavior.
To t u r n o ff C + + T O D O c o m m e n t s

1. On the Tools menu, go to Options | Text Editor | C/C++ | View | Enumerate Comment Tasks and set
the value to false.
2. In the Options dialog box, open Text Editor .
3. Under C/C++ , choose View , and then set Enumerate Comment Tasks to False .

Shortcuts
A shortcut is a bookmark in the code that is tracked in the Task List ; it has a different icon than a regular
bookmark. Double-click the shortcut in the Task List to go to the corresponding location in the code.

To create a shortcut
Insert the pointer into the code where you want to place a shortcut. Choose Edit | Bookmarks | Add Task
List Shor tcut or press (Keyboard: Ctrl+K, Ctrl+H).
To navigate through the shortcuts in the code, choose a shortcut in the list, and then choose Next Task or
Previous Task from the shortcut menu.

See Also
Task List, Environment, Options Dialog Box
Find code changes and other history with CodeLens
10/18/2019 • 8 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Stay focused on your work while you find out what happened to your code - without leaving the editor. Find
references and changes to your code, linked bugs, work items, code reviews, and unit tests.

NOTE
CodeLens is available only in Visual Studio Enterprise and Visual Studio Professional editions. It is not available in Visual
Studio Community edition.

See where and how the individual parts of your code are used in your solution:

Contact your team about changes to your code without leaving the editor:

To choose the indicators that you want to see, or to turn CodeLens off and on, go to Tools , Options , Text Editor ,
All Languages , CodeLens .

Find references to your code


You'll need:
Visual Studio Enterprise or Visual Studio Professional
Visual C# .NET or Visual Basic .NET code
Choose the references indicator (Alt + 2 ). If you see 0 references , you have no references from Visual
C# or Visual Basic code. This doesn't include references from other items such as XAML and ASPX files.

To view the referencing code, move your mouse on top of the reference.

To open the file containing the reference, double-click the reference.


To see relationships between this code and its references, create a code map and choose Show All
References in the code map shortcut menu.

Find your code's history and linked items


Review your code's history to find out what happened to your code. Or, review changes before they're merged into
your code so you can better understand how changes in other branches might affect your code.
You'll need:
Visual Studio Enterprise or Visual Studio Professional
Team Foundation Server 2013 or later, Visual Studio Team Services, or Git
Lync 2010 or later, or Skype for Business, to contact your team from the code editor
For Visual C# .NET or Visual Basic .NET code that's stored with Team Foundation version control (TFVC) or
Git, you get CodeLens details at the class and method levels (code-element-level indicators). If your Git
repository is hosted in TfGit, you also get links to TFS work items.

For all other types of files that you can open in the Visual Studio editor, you get CodeLens details for the
entire file in one place at the bottom of the window (file-level indicators).

To use the keyboard to select indicators, press and hold the ALT key to display the related number keys.

Find changes in your code


Find who changed your C# or Visual Basic code, and the changes they made, in code-element-level indicators. This
is what you see when you use Team Foundation version control (TFVC) in Team Foundation Server or Visual Studio
Team Services.
The default time period is the last 12 months. If your code is stored in Team Foundation Server, you can change
this by running the TFSConfig command with the CodeIndex command and the /indexHistor yPeriod flag.
To see a detailed history of all the changes, including those from more than a year ago, choose Show all file
changes .

This opens the History window for the changesets.

When your files are in a Git repository and you choose the code-element-level changes indicator, this is what you
see.
Find changes for an entire file (except for C# and Visual Basic files) in the file-level indicators at the bottom of the
window.

To get more details about a change, right-click that item. Depending on whether you are using TFVC or Git you get
a series of options to compare the versions of the file, view details and track the changeset, get the selected
version of the file, and email the author of that change. Some of these details appear in Team Explorer.
You can also see who changed your code over time. This can help you find patterns in your team's changes and
assess their impact.

Find changes in your current branch


Suppose your team has multiple branches - a main branch and a child development - to reduce the risk of
breaking stable code:
Find how many people changed your code and how many changes were made (Alt + 6 ) in your main branch:

Find when your code was branched


Go to your code in the child branch, for example, the Dev branch here. Choose the changes indicator (Alt + 6 ):

Find incoming changes from other branches

…like this bug fix in the Dev branch here:

You can review this change without leaving your current branch (Main):

Find when changes got merged


So you can see which changes are included in your branch:
For example, your code in the Main branch now has the bug fix from the Dev branch:

Compare an incoming change with your local version (Shift + F10)

You can also double-click the changeset.


What do the icons mean?

IC O N W H ERE DID T H E C H A N GE C O M E F RO M ?

The current branch

The parent branch

A child branch

A peer branch

A branch further away than a parent, child, or peer

A merge from the parent branch to a child branch

A merge from a child branch to the parent branch

A merge from an unrelated branch (baseless merge)

Find linked work items


Find linked code reviews

Find linked bugs

Contact the owner of an item

Open the shortcut menu for an item to see the contact options. If you have Lync or Skype for Business installed,
you see these options:
Find unit tests for your code
Find out more about unit tests that exist for your code without opening Test Explorer. You'll need:
Visual Studio Enterprise or Visual Studio Professional
Visual C# .NET or Visual Basic .NET code
A unit test project that has unit tests for your application code
1. Go to application code that has unit tests.
2. Review the tests for that code (Alt + 3 ).

3. If you see a warning icon , run the tests.

4. To review a test's definition, double-click the test item in the CodeLens indicator window to open the code
file in the editor.
5. Review the test’s results. Choose the test status indicator ( or ), or press Alt + 1 .

6. To see how many people changed this test, who changed this test, or how many changes were made to this
test, Find your code's history and linked items.

Q&A
Q: How do I turn CodeLens off or on? Or choose which indicators to see?
A: You can turn indicators off or on, except for the references indicator. Go to Tools , Options , Text Editor , All
Languages , CodeLens .
When the indicators are turned on, you can also open the CodeLens options from the indicators.
Turn CodeLens file-level indicators on and off using the chevron icons at the bottom of the editor window.

Q: Where is CodeLens?
A: CodeLens appears in Visual C# .NET and Visual Basic .NET code at the method, class, indexer, and property level.
CodeLens appears at the file level for all other types of files.
Make sure CodeLens is turned on. Go to Tools , Options , Text Editor , All Languages , CodeLens .
If your code is stored in TFS, make sure that code indexing is turned on by using the CodeIndex command
with the TFS Config command.
TFS-related indicators appear only when work items are linked to the code and when you have permissions
to open linked work items. Confirm that you have team member permissions.
Unit test indicators don't appear when application code doesn't have unit tests. Test status indicators appear
automatically in test projects. If you know that your application code has unit tests, but the test indicators
don't appear, try building the solution (Ctrl + Shift + B ).
Q: Why don't I see the work item details for a commit?
A: This might happen because CodeLens can't find the work items in TFS. Check that you're connected to the team
project that has those work items and that you have permissions to see those work items. This might also happen
if the commit description has incorrect information about the work item IDs in TFS.
Q: Why don't I see the Lync or Skype indicators?
A: They don't appear if you're not signed into Lync or Skype for Business, don't have one of these installed, or don't
have a supported configuration. But you can still send mail:

Which Lync and Skype configurations are suppor ted?


Skype for Business (32-bit or 64-bit)
Lync 2010 or later alone (32-bit or 64-bit), but not Lync Basic 2013 with Windows 8.1
CodeLens doesn't support having different versions of Lync or Skype installed. They might not be localized
for all localized versions of Visual Studio.
Q: How do I change the font and color for CodeLens?
A: Go to Tools , Options , Environment , Fonts and Colors .

To use the keyboard:


1. Press Alt + T + O to open the Options box.
2. Press Up Arrow or Down Arrow to go to the Environment node, then press Left Arrow to expand the
node.
3. Press Down Arrow to go to Fonts and Colors .
4. Press TAB to go to the Show settings for list, and then press Down Arrow to select CodeLens .
Q: Can I move the CodeLens heads-up display?
A: Yes, choose to dock CodeLens as a window.
Q: How do I refresh the indicators?
A: This depends on the indicator:
References : This indicator updates automatically when the code changes. If you have this indicator docked
as a separate window, refresh the indicator manually here:

Team : Refresh these indicators manually here:

Test : Find unit tests for your code to refresh this indicator.
Q: What's "Local Version"?
A: The Local Version arrow points at the most recent changeset in your local version of this file. When the server
has more recent changesets, they appear above or below the Local Version arrow, depending on the order used
to sort the changesets.
Q: Can I manage how CodeLens processes code to show history and linked items?
A: Yes, if your code is in TFS, use the CodeIndex command with the TFS Config command.
CodeIndex Command
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the CodeIndex command to manage code indexing on Team Foundation Server. For example, you might want
to reset the index to fix CodeLens information, or turn off indexing to investigate server performance issues.
Required Permissions
To use the CodeIndex command, you must be a member of the Team Foundation Administrators security
group. See Permission reference for Team Foundation Server.

NOTE
Even if you log on with administrative credentials, you must open an elevated Command Prompt window to run this
command. You must also run this command from the application tier for Team Foundation.

Syntax
TFSConfig CodeIndex /indexingStatus | /setIndexing:[ on | off | keepupOnly ] | /ignoreList:[ add | remove |
removeAll | view ] ServerPath | /listLargeFiles [/fileCount:FileCount] [/minSize:MinSize] | /reindexAll |
/destroyCodeIndex [/noPrompt] | /temporaryDataSizeLimit:[ view | <SizeInGBs> | disable ] |
/indexHistoryPeriod:[ view | all | <NumberOfMonths> ] [/collectionName:CollectionName |
/collectionId:CollectionId]

Parameters

A RGUM EN T DESC RIP T IO N

CollectionName Specifies the name of the team project collection. If the name
has spaces, enclose the name with quotation marks, for
example, "Fabrikam Web Site".

CollectionId Specifies the identification number of the team project


collection.

ServerPath Specifies the path to a code file.

O P T IO N DESC RIP T IO N

/indexingStatus Show the status and configuration of the code indexing


service.
O P T IO N DESC RIP T IO N

/setIndexing: [ on | off | keepupOnly ] - on : Start indexing all changesets.


- off : Stop indexing all changesets.
- keepupOnly : Stop indexing previously created changesets
and start indexing new changesets only.

/ignoreList: [ add | remove | removeAll | view ] ServerPath Specifies a list of code files and their paths that you don't
want indexed.
You can use the wildcard character (*) at the start, end, or
both ends of the server path. - add : Add the file that you don't want indexed to the
ignored file list.
- remove : Remove the file that you want indexed from the
ignored file list.
- removeAll: Clear the ignored file list and start indexing all
files.
- view : See all the files that aren't being indexed.

/listLargeFiles [/fileCount: FileCount /minSize: Shows the specified number of files that exceeds the specified
MinSize ] size in KB. You can then use the /ignoreList option to
exclude these files from indexing.

/reindexAll Clear previously indexed data and restart indexing.

/destroyCodeIndex [/noPrompt] Delete the code index and remove all indexed data. Does not
require confirmation if you use the /noPrompt option.

/temporar yDataSizeLimit :[ view | < SizeInGBs > | disable ] Control how much temporary data that CodeLens creates
when processing changesets. The default limit is 2 GB.

- view : Show the current size limit.


- SizeInGBs : Change the size limit.
- disable : Remove the size limit.

This limit is checked before CodeLens processes a new


changeset. If temporary data exceeds this limit, CodeLens will
pause processing past changesets, not new ones. CodeLens
will restart processing after the data is cleaned up and falls
below this limit. Cleanup runs automatically once a day. This
means temporary data might exceed this limit until cleanup
starts running.

/indexHistor yPeriod :[ view | all | < NumberOfMonths >] Control how long to index your change history. This affects
how much history CodeLens shows you. The default limit is
12 months. This means CodeLens shows your change history
from the last 12 months only.

- view : Show the current number of months.


- all: Index all change history.
- NumberOfMonths : Change the number of months used to
index change history.

/collectionName: CollectionName Specifies the name of the team project collection on which to
run the CodeIndex command. Required if you don't use
/CollectionId .

/collectionId: CollectionId Specifies the identification number of the team project


collection on which to run the CodeIndex command.
Required if you don't use /CollectionName .
Examples
NOTE
The example companies, organizations, products, domain names, email addresses, logos, people, places, and events depicted
herein are fictitious. No association with any real company, organization, product, domain name, email address, logo, person,
places, or events is intended or should be inferred.

To see the code indexing status and configuration:

TFSConfig CodeIndex /indexingStatus /collectionName:"Fabrikam Web Site"

To start indexing all changesets:

TFSConfig CodeIndex /setIndexing:on /collectionName:"Fabrikam Web Site"

To stop indexing previously created changesets and start indexing new changesets only:

TFSConfig CodeIndex /setIndexing:keepupOnly /collectionName:"Fabrikam Web Site"

To find up to 50 files that are larger than 10 KB:

TFSConfig CodeIndex /listLargeFiles /fileCount:50 /minSize:10 /collectionName:"Fabrikam Web Site"

To exclude a specific file from indexing and add it to the ignored file list:

TFSConfig CodeIndex /ignoreList:add "$/Fabrikam Web Site/Catalog.cs" /collectionName:"Fabrikam Web Site"

To see all the files that aren't indexed:

TFSConfig CodeIndex /ignoreList:view

To clear previously indexed data and restart indexing:

TFSConfig CodeIndex /reindexAll /collectionName:"Fabrikam Web Site"

To save all changeset history:

TFSConfig CodeIndex /indexHistoryPeriod:all /collectionName:"Fabrikam Web Site"

To remove the size limit on CodeLens temporary data and continue indexing regardless of temporary data size:

TFSConfig CodeIndex /temporaryDataSizeLimit:disable /collectionName:"Fabrikam Web Site"

To delete the code index with confirmation:

TFSConfig CodeIndex /destroyCodeIndex /collectionName:"Fabrikam Web Site"


See Also
Managing server configuration with TFSConfig Command-line tools for TFS
Using the Visual Studio Development Environment
for C#
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Visual Studio integrated development environment (IDE) is a collection of development tools exposed through
a common user interface. Some of the tools are shared with other Visual Studio languages, and some, such as the
C# compiler, are unique to Visual C#. This topic provides links to the most important Visual C# tools.

Related Topics
T IT L E DESC RIP T IO N

Walkthrough: Create a Simple Application Provides an overview of many of the features and tools
included in Visual Studio for application development.

Creating Solutions and Projects Describes how to create a project that contains all the source
code files, resource files such as icons, references to external
files, and configuration data such as compiler settings.

Introduction to the Project Designer Provides an overview of the Project Designer, which provides
a centralized location for managing project properties,
settings, and resources.

Writing Code Describes Visual Studio tools that help you modify and
manipulate text, code, and markup, insert and configure
controls and other objects and namespaces, and add
references to external components and resources.

Visual C# IntelliSense Provides links to topics that describe Visual C#–specific


features, such as automatic code generation and IntelliSense
for most recently used members.

Visual C# Code Snippets Provides an overview of using Code Snippets in Visual C# to


automatically add common code constructs to your
application

Writing Code Provides links to procedures about how to use the Find and
Replace window, Bookmarks, and the Task List and Error List to
locate lines of code.

Viewing the Structure of Code Explains how to browse hierarchies of classes, class members,
and resources.

How to: Add an Application Configuration File to a C# Project Describes how to add a configuration file (app.config) to a C#
project.
T IT L E DESC RIP T IO N

Metadata as Source Describes how the IDE enables you to view metadata as
source code.

Refactoring (C#) Lists refactoring operations that help you modify your code
without changing the behavior of your application.

Compiling and Building Explains how to configure debug, release, and special builds of
your Visual Studio solution.

Debugging in Visual Studio Describes how to run the Visual Studio Debugger to resolve
logic and semantic errors.

Managing Application Resources (.NET) Shows how to add or edit resources for your project, such as
strings, images, icons, audio, and files.

See Also
C#
Getting Started with C#
C# Reference
How to: Add an Application Configuration File to a
C# Project
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

By adding an application configuration file (app.config file) to a C# project, you can customize how the common
language runtime locates and loads assembly files. For more information about application configuration files, see
How the Runtime Locates Assemblies.

NOTE
The Windows Store doesn’t support System.Configuration. As a result, Store apps don’t contain an app.config template.

When you build your project, the development environment automatically copies your app.config file, changes the
file name of the copy to match your executable, and then moves the copy to the bin directory.
To add an application configuration file to your C# project
1. On the menu bar, choose Project , Add New Item .
The Add New Item dialog box appears.
2. Expand Installed , expand Visual C# Items , and then choose the Application Configuration File
template.
3. In the Name text box, enter a name, and then choose the Add button.
A file that's named app.config is added to your project.

See Also
Managing Application Settings (.NET) Configuration File Schema Configuring Apps How to: Configure an App to
Target a .NET Framework Version Using the Visual Studio Development Environment for C#
Metadata as Source
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Metadata as source enables you to view metadata that appears as C# source code in a read-only buffer. This
enables a view of the declarations of the types and members (without implementations). You can view metadata as
source by running the Go To Definition command for types or members whose source code is not available from
your project or solution.

NOTE
When you try to run the Go To Definition command for types or members that are marked as internal, the integrated
development environment (IDE) does not display their metadata as source, regardless of whether the referencing assembly is
a friend or not.

You can view metadata as source in either the Code Editor or the Code Definition window.

Viewing Metadata as Source in the Code Editor


When you run the Go To Definition command for an item whose source code is unavailable, a tabbed document
that contains a view of that item's metadata, displayed as source, appears in the Code Editor. The name of the type,
followed by [from metadata] , appears on the document's tab.
For example, if you run the Go To Definition command for Console, metadata for Console appears in the Code
Editor as C# source code that resembles its declaration, but without an implementation.

Viewing Metadata as Source in the Code Definition Window


When the Code Definition window is active or visible, the IDE automatically executes the Go To Definition
command for items under the cursor in the Code Editor and for items that are selected in Class View or the
Object Browser . If the source code is not available for that item, the IDE displays the item's metadata as source in
the Code Definition window.
For example, if you put your cursor inside the word Console in the Code Editor, metadata for Console appears as
source in the Code Definition window. The source resembles the Console declaration, but without an
implementation.
If you want to see the declaration of an item that appears in the Code Definition window, right-click the item and
click Go To Definition .
Refactoring (C#)
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Refactoring is the process of improving your code after it has been written by changing the internal structure of
the code without changing the external behavior of the code.
Visual C# provides the following refactoring commands on the Refactoring menu:
Extract Method Refactoring (C#)
Rename Refactoring (C#)
Encapsulate Field Refactoring (C#)
Extract Interface Refactoring (C#)
Remove Parameters Refactoring (C#)
Reorder Parameters Refactoring (C#)

Multi-Project Refactoring
Visual Studio supports multi-project refactoring for projects that are in the same solution. All of the refactoring
operations that correct references across files correct those references across all projects of the same language.
This works for any project-to-project references. For example, if you have a console application that references a
class library, when you rename a class library type (using the Rename refactoring operation), the references to the
class library type in the console application are also updated.

Changes Preview
Many refactoring operations provide an opportunity for you to review all the reference changes that a refactoring
operation would perform on your code, before committing to those changes. For these refactoring operations, a
preview reference changes option will appear in the refactoring dialog box. After selecting that option and
accepting the refactoring operation, the Preview Changes Dialog Box will appear. Notice that the Preview
Changes dialog box has two views. The bottom view will display your code with all the reference updates due to
the refactoring operation. Pressing Cancel on the Preview Changes dialog box will stop the refactoring
operation, and no changes will be made to your code.

Refactoring Warnings
If the compiler does not have a complete understanding of your program, and it is possible that the refactoring
engine might not update all the appropriate references, the warning dialog box is displayed. This warning dialog
box also provides an opportunity for you to preview your code in the Preview Changes dialog box before you
commit changes.
NOTE
If a method contains a syntax error (which the IDE indicates with a red wavy underline), then the refactoring engine will not
update any references to an element within that method. The example below illustrates this behavior.

By default, if you execute a refactoring operation without previewing reference changes and a compilation error is
detected in your program, then the development environment displays this warning dialog box.
If you execute a refactoring operation that has Preview reference changes enabled and a compilation error is
detected in your program, then the development environment will display the following warning message at the
bottom of the Preview Changes dialog box, in lieu of displaying the Refactoring Warning dialog box:
Your project or one of its dependencies does not currently build. References may not be updated.
This refactoring warning is only available for refactoring operations that provide the Preview reference
changes option.

Error-Tolerant Refactoring and Verification Results


Refactoring is error tolerant. In other words, you can perform a refactoring in a project that cannot build. However,
in these cases the refactoring process might not update ambiguous references correctly.
The Verification Results dialog box can notify you if the refactoring engine detects compile errors or discovers
that a refactoring operation inadvertently causes a code reference to bind to something different from what it was
originally bound to (rebinding issue).
To turn on the verification results feature, on the Tools menu, click Options . In the Options dialog box, expand
Text Editor , and then expand C# . Click Advanced and select the Verify results of refactoring check box.
The Verification Results dialog box distinguishes the difference between two kinds of rebinding issues.
References whose definition will no longer be the renamed symbol
This kind of rebinding issue occurs when a reference no longer refers to a renamed symbol. For example, consider
the following code:

class Example
{
private int a;
public Example(int b)
{
a = b;
}
}

If you use refactoring to rename a to b , this dialog box appears. The reference to the renamed variable a now
binds to the parameter that is passed to the constructor instead of binding to the field.
References whose definition will now become the renamed symbol
This kind of rebinding issue occurs when a reference that previously did not refer to the renamed symbol now
does refer to the renamed symbol. For example, consider the following code:
class Example
{
private static void Method(object a) { }
private static void OtherMethod(int a) { }
static void Main(string[] args)
{
Method(5);
}
}

If you use refactoring to rename OtherMethod to Method , this dialog box appears. The reference in Main now
refers to the overloaded method that accepts an int parameter instead of the overloaded method that accepts
an object parameter.

See Also
Using the Visual Studio Development Environment for C# How to: Restore C# Refactoring Snippets
Extract Method Refactoring (C#)
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Extract Method is a refactoring operation that provides an easy way to create a new method from a code
fragment in an existing member.
Using Extract Method , you can create a new method by extracting a selection of code from inside the code block
of an existing member. The new, extracted method contains the selected code, and the selected code in the existing
member is replaced with a call to the new method. Turning a fragment of code into its own method lets you quickly
and accurately reorganize code for better reuse and readability.
Extract Method has the following benefits:
Encourages best coding practices by emphasizing discrete, reusable methods.
Encourages self-documenting code through good organization.
When descriptive names are used, high-level methods can read more like a series of comments.
Encourages the creation of finer-grained methods to simplify overriding.
Reduces code duplication.
To use Extract Method
1. Create a console application named ExtractMethod , and then replace Program with the following example
code.

class A
{
const double PI = 3.141592;

double CalculatePaintNeeded(double paintPerUnit, double radius)


{
// Select any of the following:
// 1. The entire next line of code.
// 2. The right-hand side of the next line of code.
// 3. Just "PI *" of the right-hand side of the next line
// of code (to see the prompt for selection expansion).
// 4. All code within the method body.
// ...Then invoke Extract Method.

double area = PI * radius * radius;

return area / paintPerUnit;


}
}

2. Select the code fragment you want to extract:


double area = PI * radius * radius;

3. On the Refactor menu, click Extract Method .


The Extract Method dialog box appears.
Alternatively, you can also type the keyboard shortcut CTRL+R, M to display the Extract Method dialog
box.
You can also right-click the selected code, point to Refactor , and then click Extract Method to display the
Extract Method dialog box.
4. Specify a name for the new method, such as CircleArea , in the New Method Name box.
A preview of the new method signature displays under Preview Method Signature .
5. Click OK .

Remarks
When you use the Extract Method command, the new method is inserted following the source member in the
same class.

Partial Types
If the class is a partial type, then Extract Method generates the new method immediately following the source
member. Extract Method determines the signature of the new method, creating a static method when no instance
data is referenced by the code in the new method.

Generic Type Parameters


When you extract a method that has an unconstrained generic type parameter, the generated code will not add the
ref modifier to that parameter unless a value is assigned to it. If the extracted method will support reference
types as the generic type argument, then you should manually add the ref modifier to the parameter in the
method signature.

Anonymous Methods
If you try to extract part of an anonymous method that includes a reference to a local variable that is either
declared or referenced outside the anonymous method, then Visual Studio will warn you about potential semantic
changes.
When an anonymous method uses the value of a local variable, the value is obtained at the moment the
anonymous method is executed. When an anonymous method is extracted into another method, the value of the
local variable is obtained at the moment of the call to the extracted method.
The following example illustrates this semantic change. If this code is executed, then 11 will be printed to the
console. If you use Extract Method to extract the region of code that is marked by code comments into its own
method and then execute the refactored code, then 10 will be printed to the console.
class Program
{
delegate void D();
D d;
static void Main(string[] args)
{
Program p = new Program();
int i = 10;
/*begin extraction*/
p.d = delegate { Console.WriteLine(i++); };
/*end extraction*/
i++;
p.d();
}
}

To work around this situation, make the local variables that are used in the anonymous method fields of the class.

See Also
Refactoring (C#)
Rename Refactoring (C#)
10/18/2019 • 6 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Rename is a refactoring feature in the Visual Studio integrated development environment (IDE) that provides an
easy way to rename identifiers for code symbols such as fields, local variables, methods, namespaces, properties,
and types. Rename can be used to change the names in comments and in strings and to change the declarations
and calls of an identifier.

NOTE
When using Source Control for Visual Studio, get the latest version of sources before you try to perform rename refactoring.

Rename refactoring is available from the following Visual Studio features:

F EAT URE B EH AVIO R O F REFA C TO RIN G IN T H E IDE

Code Editor In the Code Editor, rename refactoring is available when you
position the cursor on certain types of code symbols. When
the cursor is in this position, you can invoke the Rename
command by typing the keyboard shortcut (CTRL + R, CTRL +
R), or by selecting the Rename command from a smart tag,
shortcut menu, or the Refactor menu.

Class View When you select an identifier in Class View, rename


refactoring is available from the shortcut menu and Refactor
menu.

Object Browser When you select an identifier in Object Browser, rename


refactoring is only available from the Refactor menu.

Property Grid of the Windows Forms Designer In the Proper ty Grid of the Windows Forms Designer,
changing the name of a control will initiate a rename
operation for that control. The Rename dialog box will not
appear.
F EAT URE B EH AVIO R O F REFA C TO RIN G IN T H E IDE

Solution Explorer In Solution Explorer , a Rename command is available on


the shortcut menu. If the selected source file contains a class
whose class name is the same as the file name, you can use
this command to simultaneously rename the source file and
execute rename refactoring.

For example, if you create a default Windows-based


application and then rename Form1.cs to TestForm.cs, the
source file name Form1.cs will change to TestForm.cs and the
class Form1 and all references to that class will be renamed to
TestForm. Note: The Undo command (CTRL+Z) will only
undo rename refactoring in the code and will not change the
file name back to the original name.

If the selected source file does not contain a class whose name
is the same as the file name, the Rename command in
Solution Explorer will only rename the source file and will
not execute rename refactoring.

Rename Operations
When you execute Rename , the refactoring engine performs a rename operation specific for each code symbol, as
described in the following table.

C O DE SY M B O L REN A M E O P ERAT IO N

Field Changes the declaration and usages of the field to the new
name.

Local variable Changes the declaration and usages of the variable to the
new name.

Method Changes the name of the method and all references to that
method to the new name. Note: When you rename an
extension method, the rename operation propagates to all
instances of the method that are in scope, regardless of
whether the extension method is being used as a static
method or an instance method. For more information, see
Extension Methods.

Namespace Changes the name of the namespace to the new name in the
declaration, all using statements, and fully qualified names.
Note: When renaming a namespace, Visual Studio also
updates the Default Namespace property on the
Application page of the Project Designer . This property
cannot be reset by selecting Undo from the Edit menu. To
reset the Default Namespace property value, you must
modify the property in the Project Designer . For more
information, see Application Page.

Property Changes the declaration and usages of the property to the


new name.

Type Changes all declarations and all usages of the type to the new
name, including constructors and destructors. For partial
types, the rename operation will propagate to all parts.
To rename an identifier
1. Create a console application named RenameIdentifier , and then replace Program with the following
example code.

class ProtoClassA
{
// Invoke on 'MethodB'.
public void MethodB(int i, bool b) { }
}

class ProtoClassC
{
void D()
{
ProtoClassA MyClassA = new ProtoClassA();

// Invoke on 'MethodB'.
MyClassA.MethodB(0, false);
}
}

2. Place the cursor on MethodB , either in the method declaration or the method call.
3. From the Refactor menu, select Rename . The Rename dialog box appears.
You can also right-click the cursor, point to Refactor on the context menu, and then click Rename to display
the Rename dialog box.
4. In the New Name field, type MethodC .
5. Select the Search in Comments check box.
6. Click OK .
7. In the Preview Changes dialog box, click Apply .
To rename an identifier using smart tags
1. Create a console application named RenameIdentifier , and then replace Program with the following
example code.

class ProtoClassA
{
// Invoke on 'MethodB'.
public void MethodB(int i, bool b) { }
}

class ProtoClassC
{
void D()
{
ProtoClassA MyClassA = new ProtoClassA();

// Invoke on 'MethodB'.
MyClassA.MethodB(0, false);
}
}

2. In the declaration for MethodB , type or backspace over the method identifier. A smart tag prompt will
appear below this identifier.
NOTE
You can only invoke rename refactoring using smart tags at the declaration of an identifier.

3. Type the keyboard shortcut SHIFT+ALT+F10, and then press the DOWN ARROW to display the smart tag
menu.
-or-
Move the mouse pointer over the smart tag prompt to display the smart tag. Then move the mouse pointer
over the smart tag and click the DOWN ARROW to display the smart tag menu.
4. Select the Rename '<identifer1>' to '<identifier2>' menu item to invoke rename refactoring without a
preview of the changes to your code. All references to <identifer1> will automatically be updated to
<identifier2> .
-or-
Select the Rename with preview menu item to invoke rename refactoring with a preview of the changes
to your code. The Preview Changes dialog box will appear.

Remarks
Renaming Implemented or Overridden Members
When you Rename a member that either implements/overrides or is implemented/overridden by members in
other types, Visual Studio displays a dialog box that says the rename operation will cause cascading updates. If you
click Continue , the refactoring engine recursively finds and renames all members in base and derived types that
have implements/overrides relationships with the member being renamed.
The following code example contains members with implements/overrides relationships.

interface IBase
{
void Method();
}
public class Base
{
public void Method()
{ }
public virtual void Method(int i)
{ }
}
public class Derived : Base, IBase
{
public new void Method()
{ }
public override void Method(int i)
{ }
}
public class C : IBase
{
public void Method()
{ }
}

In the previous example, renaming C.Method() also renames Ibase.Method() because C.Method() implements
Ibase.Method() . Next, the refactor engine recursively sees that Ibase.Method() is implemented by
Derived.Method() and renames Derived.Method() . The refactor engine does not rename Base.Method() , because
Derived.Method()does not override Base.Method() . The refactoring engine stops here unless you have Rename
overloads checked in the Rename dialog box.
If Rename overloads is checked, the refactor engine renames Derived.Method(int i) because it overloads
Derived.Method() , Base.Method(int i) because it is overridden by Derived.Method(int i) , and Base.Method()
because it is an overload of Base.Method(int i) .

NOTE
When you rename a member that was defined in a referenced assembly, a dialog box explains that renaming will cause build
errors.

Renaming Properties of Anonymous Types


When you rename a property in anonymous types, the rename operation will propagate to properties in other
anonymous types that have the same properties. The following examples illustrate this behavior.

var a = new { ID = 1};


var b = new { ID = 2};

In the preceding code, renaming ID will change ID in both statements because they have the same underlying
anonymous type.

var companyIDs =
from c in companylist
select new { ID = c.ID, Name = c.Name};

var orderIDs =
from o in orderlist
select new { ID = o.ID, Item = o.Name};

In the preceding code, renaming ID will only rename one instance of ID because companyIDs and orderIDs do
not have the same properties.

See Also
Refactoring (C#) Anonymous Types
Encapsulate Field Refactoring (C#)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Encapsulate Field refactoring operation enables you to quickly create a property from an existing field, and
then seamlessly update your code with references to the new property.
When a field is public, other objects have direct access to that field and can modify it, undetected by the object that
owns that field. By using properties to encapsulate that field, you can disallow direct access to fields.
To create the new property, the Encapsulate Field operation changes the access modifier for the field that you
want to encapsulate to private, and then generates get and set accessors for that field. In some cases, only a get
accessor is generated, such as when the field is declared read-only.
The refactoring engine updates your code with references to the new property in the areas specified in the Update
References section of the Encapsulate Field dialog box.
To create a property from a field
1. Create a console application named EncapsulateFieldExample , and then replace Program with the following
example code.

class Square
{
// Select the word 'width' and then use Encapsulate Field.
public int width, height;
}
class MainClass
{
public static void Main()
{
Square mySquare = new Square();
mySquare.width = 110;
mySquare.height = 150;
// Output values for width and height.
Console.WriteLine("width = {0}", mySquare.width);
Console.WriteLine("height = {0}", mySquare.height);
}
}

2. In the Code Editor, place the cursor in the declaration, on the name of the field that you want to encapsulate.
In the example below, place the cursor on the word width :

public int width, height;

3. On the Refactor menu, click Encapsulate Field .


The Encapsulate Field dialog box appears.
You can also type the keyboard shortcut CTRL+R, E to display the Encapsulate Field dialog box.
You can also right-click the cursor, point to Refactor , and then click Encapsulate Field to display the
Encapsulate Field dialog box.
4. Specify settings.
5. Press ENTER, or click the OK button.
6. If you selected the Preview reference changes option, then the Preview Reference Changes window
opens. Click the Apply button.
The following get and set accessor code is displayed in your source file:

public int Width


{
get { return width; }
set { width = value; }
}

The code in the Main method is also updated to the new Width property name.

Square mySquare = new Square();


mySquare.Width = 110;
mySquare.height = 150;
// Output values for width and height.
Console.WriteLine("width = {0}", mySquare.Width);

Remarks
The Encapsulate Field operation is only possible when the cursor is positioned on the same line as the field
declaration.
For declarations that declare multiple fields, Encapsulate Field uses the comma as a boundary between fields,
and initiates refactoring on the field that is nearest the cursor and on the same line as the cursor. You can also
specify which field you want to encapsulate by selecting the name of that field in the declaration.
The code that is generated by this refactoring operation is modeled by the encapsulate field code snippets feature.
Code Snippets are modifiable. For more information, see Code Snippets.

See Also
Refactoring (C#) Visual C# Code Snippets
Extract Interface Refactoring (C#)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Extract Interface is a refactoring operation that provides an easy way to create a new interface with members that
originate from an existing class, struct, or interface.
When several clients use the same subset of members from a class, struct, or interface, or when multiple classes,
structs, or interfaces have a subset of members in common, it can be useful to embody the subset of members in
an interface. For more information about using interfaces, see Interfaces.
Extract Interface generates an interface in a new file and positions the cursor at the beginning of the new file. You
can specify which members to extract into the new interface, the name of the new interface, and the name of the
generated file using the Extract Interface dialog box.
To use Extract Interface
1. Create a console application named ExtractInterface , and then replace Program with the following code

// Invoke Extract Interface on ProtoA.


// Note: the extracted interface will be created in a new file.
class ProtoA
{
public void MethodB(string s) { }
}

2. With the cursor positioned in MethodB , and click Extract Interface on the Refactor menu.
The Extract Interface dialog box appears.
You can also type the keyboard shortcut CTRL+R, I to display the Extract Interface dialog box.
You can also right-click the mouse, point to Refactor , and then click Extract Interface to display the
Extract Interface dialog box.
3. Click Select All .
4. Click OK .
You see the new file, IProtoA.cs, and the following code:

using System;
namespace TopThreeRefactorings
{
interface IProtoA
{
void MethodB(string s);
}
}
Remarks
This feature is only accessible when the cursor is positioned in the class, struct, or interface that contains the
members that you would like to extract. When the cursor is in this position, invoke the Extract Interface refactoring
operation.
When you invoke extract interface on a class or on a struct, the bases and interfaces list is modified to include the
new interface name. When you invoke extract interface on an interface, the bases and interfaces list is not modified.

See Also
Refactoring (C#)
Remove Parameters Refactoring (C#)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Remove Parameters is a refactoring operation that provides an easy way to remove parameters from methods,
indexers, or delegates. Remove Parameters changes the declaration; at any locations where the member is called,
the parameter is removed to reflect the new declaration.
You perform the Remove Parameters operation by first positioning the cursor on a method, indexer, or delegate.
While the cursor is in position, to invoke the Remove Parameters operation, click the Refactor menu, press the
keyboard shortcut, or select the command from the shortcut menu.

NOTE
You cannot remove the first parameter in an extension method.

To remove parameters
1. Create a console application named RemoveParameters , and then replace Program with the following code.

class A
{
// Invoke on 'A'.
public A(string s, int i) { }
}

class B
{
void C()
{
// Invoke on 'A'.
A a = new A("a", 2);
}
}

2. Place the cursor on method A , either in the method declaration or the method call.
3. From the Refactor menu, select Remove Parameters to display the Remove Parameters dialog box.
You can also type the keyboard shortcut CTRL+R, V to display the Remove Parameters dialog box.
You can also right-click the cursor, point to Refactor , and then click Remove Parameters to display the
Remove Parameters dialog box.
4. Using the Parameters field, position the cursor on int i , and then click Remove .
5. Click OK .
6. In the Preview Changes — Remove Parameters dialog box, click Apply .
Remarks
You can remove parameters from a method declaration or a method call. Position the cursor in the method
declaration or delegate name and invoke Remove Parameters.
Cau t i on

Remove Parameters enables you to remove a parameter that is referenced in the body of the member, but it does
not remove the references to that parameter in the method body. This can introduce build errors into your code.
However, you can use the Preview Changes dialog box to review your code before executing the refactoring
operation.
If a parameter being removed is modified during the call to a method, the removal of the parameter will also
remove the modification. For example, if a method call is changed from

MyMethod(param1++, param2);

to

MyMethod(param2);

by the refactoring operation, param1 will not be incremented.

See Also
Refactoring (C#)
Reorder Parameters Refactoring (C#)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Reorder Parameters is a Visual C# refactoring operation that provides an easy way to change the order of the
parameters for methods, indexers, and delegates. Reorder Parameters changes the declaration, and at any locations
where the member is called, the parameters are rearranged to reflect the new order.
To perform the Reorder Parameters operation, put the cursor on or next to a method, indexer, or delegate. When
the cursor is in position, invoke the Reorder Parameters operation by pressing the keyboard shortcut, or by clicking
the command from the shortcut menu.

NOTE
You cannot reorder the first parameter in an extension method.

To reorder parameters
1. Create a class library named ReorderParameters , and then replace Class1 with the following example code.

class ProtoClassA
{
// Invoke on 'MethodB'.
public void MethodB(int i, bool b) { }
}

class ProtoClassC
{
void D()
{
ProtoClassA MyClassA = new ProtoClassA();

// Invoke on 'MethodB'.
MyClassA.MethodB(0, false);
}
}

2. Place the cursor on MethodB , either in the method declaration or the method call.
3. On the Refactor menu, click Reorder Parameters .
The Reorder Parameters dialog box appears.
4. In the Reorder Parameters dialog box, select int i in the Parameters list, and then click the down
button.
Alternatively, you can drag int i after bool b in the Parameters list.
5. In the Reorder Parameters dialog box, click OK .
If the Preview reference changes option is selected in the Reorder Parameters dialog box, the Preview
Changes - Reorder Parameters dialog box will appear. It provides a preview of the changes in the
parameter list for MethodB in both the signature and the method call.
a. If the Preview Changes - Reorder Parameters dialog box appears, click Apply .
In this example, the method declaration and all the method call sites for MethodB are updated.

Remarks
You can reorder parameters from a method declaration or a method call. Position the cursor on or next to the
method or delegate declaration but not in the body.

See Also
Refactoring (C#)
Debugging in Visual Studio
4/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Visual Studio debugger helps you observe the run-time behavior of your program and find problems. The
debugger works with all Visual Studio programming languages and their associated libraries. With the debugger,
you can break execution of your program to examine your code, examine and edit variables, view registers, see
the instructions created from your source code, and view the memory space used by your application.
For a quick introduction to debugging and diagnostics in Visual Studio, see Debug, Profile, and Diagnose.
Debugger Windows Lists the different debugger windows.
Debugger Basics Discusses the fundamentals of using the Visual Studio debugger. Topics include
debugging basics, execution control, attaching to a running program, Just-In-Time debugging, launching
the debugger automatically, dumps, breakpoints, inspecting your program, handling exceptions, Edit and
Continue, and using expressions in the debugger.
More Debugging Features Describes different debugging features.
Remote Debugging Describes how to set up and use remote debugging.
Debug Multithreaded Applications Describes how to debug multithreaded applications.
IntelliTrace Describes the IntelliTrace feature.
Debugging Applications Describes how to debug different kinds of applications.
Debugging User Interface Reference Provides reference information on the windows and dialog boxes you
use when debugging your application. These topics are also available when you press F1 while you have
focus on a debugging user interface element, such as the Breakpoints window.
Debug Interface Access SDK Describes the Microsoft Debug Interface Access Software Development Kit
(DIA SDK). The DIA SDK provides access to debug information stored in program database (.pdb) files
generated by Microsoft postcompiler tools.

See Also
Profiling Tools Visual Studio IDE
Profiling Tools
5/15/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Profiling and diagnostics tools help you diagnose memory and CPU usage and other application-level issues. With
these tools, you can accumulate data (such as variable values, function calls, and events) over the time you run
your application in the debugger. You can view the state of your application at different points during the execution
of your code.
Check out the summary at the bottom to see what tools are available for your project type (for example, desktop,
UWP, ASP.NET).
You can access the profiling tools by using Debug / Windows / Show Diagnostic Tools to use the tools during
your debug session, or by using Debug / Performance Profiler... to do a focused performance analysis. See
Running Profiling Tools With or Without the Debugger for more information on the different approaches.

See What's New in Profiling Tools to learn about new features for this release.
The following sections describe the different performance tools that are available in Visual Studio.

Memory Usage
Find memory leaks and inefficient memory while you’re debugging with the Memor y Usage tool. The tool lets
you take snapshots of the managed and native memory heap. You can use this tool with desktop apps, Windows
Universal apps, and ASP.NET apps. The Memor y Usage tool can be run from the Diagnostics Tools window
while you are debugging (Debug / Windows / Show Diagnostic Tools ) or outside the debugger (Debug /
Performance Profiler...). See Memory Usage and Memory Usage without Debugging for more information.

CPU Usage

The CPU Usage tool shows you where the CPU is spending time executing C++, C#/VB, and JavaScript code. You
can use this tool with both desktop and Windows Universal apps, as well as Azure App Services apps. The CPU
Usage tool can be run from the Diagnostics Tools window while you are debugging (Debug / Windows /
Show Diagnostic Tools ) or outside the debugger (Debug / Performance Profiler...). See CPU Usage for more
information.

Performance Explorer

The Performance Explorer (Debug / Profiler / Performance Explorer ) allows you to use many different
tools, including CPU Sampling , Instrumentation , .NET Memor y Allocation , and Resource Contention . You
can use Performance Explorer tools with desktop apps and ASP.NET apps, but not Windows Universal apps. For
more information, see Performance Explorer.

GPU Usage
Use the GPU Usage tool to better understand the high-level hardware utilization of your Direct3D app. You can use
this tool with both desktop and Windows Universal apps, but not ASP.NET apps. The GPU Usage tool can be run
from the Diagnostic Tools window while you are debugging (Debug / Show Diagnostic Tools ) or outside the
debugger (Debug / Performance Profiler...).

Application Timeline

The Application Timeline tool helps improve the performance of XAML applications by providing a detailed view of
their resource consumption. You can use the Application Timeline with desktop and Windows Universal apps,
but not ASP.NET apps. The Application Timeline tool can be run from the Diagnostics Tools window (Debug /
Performance Profiler...).

PerfTips

When the debugger stops execution at a breakpoint or stepping operation, the elapsed time between the break
and the previous breakpoint appears as a tip in the editor window. These PerfTips help you to monitor and analyze
the performance of your app while you are debugging. You can see PerfTips in desktop, Windows Universal, and
ASP.NET apps.

JavaScript Memory

The JavaScript Memory tool lets you measure, evaluate, and target performance-related issues in your code by
collecting timing information at the entrance and exit of each function in your app. You can use this tool with
Windows Universal HTML apps. The JavaScript Function Timing tool can be run from the Diagnostics Tools
window (Debug / Performance Profiler...).

HTML UI Responsiveness

The HTML UI responsiveness tool helps you isolate performance problems in your apps, including lack of
responsiveness, slow loading time, and visual updates that are less frequent than expected. You can use this tool
with Windows Universal HTML apps. The HTML UI Responsiveness tool can be run from the Diagnostics Tools
window (Debug / Performance Profiler...).

IntelliTrace

IntelliTrace lets you record specific events, examine data in the Locals window during debugger events and
function calls, and debug errors that are hard to reproduce. IntelliTrace is primarily a debugging tool, but it also
provides information that can be used for performance investigations. You can use this tool in Visual Studio
Enterprise only, with desktop, Windows Universal, and ASP.NET C# apps. You can find IntelliTrace in the
Diagnostics Tools window while you are debugging (Debug / Windows / Show Diagnostic Tools ).

Profiling in Production
The recommended approach to profiling in production is to profile from the command line using vsperf.exe to
collect a CPU Profile. For remote profiling support in Azure App Service, you can profile through the Server
Explorer or Kudu Portal.

Which Tool Should I Use?


Here is a table that lists the different tools Visual Studio offers and the different project types you can use them
with:

W IN DO W S
P ERF O RM A N C E TO O L W IN DO W S DESK TO P UN IVERSA L / STO RE A SP. N ET

Memory Usage yes yes no

CPU Usage yes yes Azure App Service only

GPU Usage yes yes no

Application Timeline yes yes no


W IN DO W S
P ERF O RM A N C E TO O L W IN DO W S DESK TO P UN IVERSA L / STO RE A SP. N ET

PerfTips yes yes for XAML, no for HTML no

Performance Explorer yes no yes

IntelliTrace .NET Enterprise only .NET Enterprise only .NET Enterprise only

HTML UI responsiveness no yes for HTML, no for XAML no

JavaScript Memory no yes for HTML, no for XAML no

See Also
Visual Studio IDE
Unit Test Your Code
1/10/2020 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Unit tests give developers and testers a quick way to look for logic errors in the methods of classes in Visual C#,
Visual Basic, and Visual C++ projects.
The unit test tools include:
1. Test Explorer. Test Explorer lets you run unit tests and view their results. Test Explorer can use any unit test
framework, including a third-party framework, that has an adapter for the Explorer.
2. Microsoft unit test framework for managed code. The Microsoft unit test framework for managed
code is installed with Visual Studio and provides a framework for testing .NET code.
3. Microsoft unit test framework for C++. The Microsoft unit test framework for C++ is installed with
Visual Studio and provides a framework for testing native code.
4. Code coverage tools. You can determine the amount of product code that your unit tests exercise from
one command in Test Explorer.
5. Microsoft Fakes isolation framework . The Microsoft Fakes isolation framework can create substitute
classes and methods for production and system code that create dependencies in the code under test. By
implementing the fake delegates for a function, you control the behavior and output of the dependency
object.
You can also use IntelliTest to explore your .NET code to generate test data and a suite of unit tests. For
every statement in the code, a test input is generated that will execute that statement. A case analysis is
performed for every conditional branch in the code.

Key tasks
Use the following topics to help with understanding and creating unit tests:

TA SK S A SSO C IAT ED TO P IC S

Quick star ts and walkthroughs: Use the following topics - Walkthrough: Creating and Running Unit Tests for Managed
to learn unit testing in Visual Studio from code examples. Code
- Quick Start: Test Driven Development with Test Explorer
- Adding unit tests to existing C++ applications
- Unit testing native code with Test Explorer

Unit testing with Test Explorer : Learn how Test Explorer - Unit Test Basics
can help create more productive and efficient unit tests. - Create a unit test project
- Run unit tests with Test Explorer
- Install third-party unit test frameworks
- Upgrading Unit Tests from Visual Studio 2010
TA SK S A SSO C IAT ED TO P IC S

Unit testing managed code: - Writing Unit Tests for the .NET Framework with the
Microsoft Unit Test Framework for Managed Code

Unit testing C++ code - Writing Unit tests for C/C++ with the Microsoft Unit Testing
Framework for C++

Isolating unit tests - Isolating Code Under Test with Microsoft Fakes

Use code coverage to identify what propor tion of - Using Code Coverage to Determine How Much Code is
your project's code is being tested using unit tests: being Tested
Learn about the code coverage feature of Visual Studio
Application Lifecycle Management testing tools.

Perform stress and performance analysis by using - Creating and Editing Load Tests
load tests for your unit tests: You can create a load test - How to: Add Web Performance Tests and Unit Tests to a
and add your unit tests to it to help isolate performance and Load Test Scenario
stress issues in your application. Note: Creating and using - How to: Remove Web Tests and Unit Tests from a Load Test
load tests requires Visual Studio Enterprise. Scenario

Set and enforce quality gates: You can create quality - Set and Enforce Quality Gates
gates to enforce that tests are run before code is checked in
to help ensure the quality of the code.

Extend the unit test type: You can add functionality to For sample code of how to extend the unit test framework,
your tests that might not be in the Unit Test Framework. For see the following Microsoft Web site.
example, you can add a test property that specifies if a test
should run as a normal user or not. Or you can extend the
framework to add row attributes to a method and use the
data in that row inside the test.

Set testing options: For example, you can specify where Configure unit tests by using a .runsettings file
test results are stored.

Related tasks
Reviewing Test Results in Microsoft Test Manager
Describes test results and ways to work with them, including how to view, save, and delete them.
Running System Tests Using Microsoft Visual Studio
Provides links to information about using Visual Studio as opposed to using Microsoft Test Manager to run
automated tests.

Reference
Microsoft.VisualStudio.TestTools.UnitTesting Describes the UnitTesting namespace, which provides attributes,
exceptions, asserts, and other classes that support unit testing.
Microsoft.VisualStudio.TestTools.UnitTesting.Web Describes the UnitTesting.Web namespace, which extends the
UnitTesting namespace by providing support for ASP.NET and Web service unit tests.

External resources
Videos
Channel 9: Unit testing your Windows Store apps built using XAML
Forums
Visual Studio Unit Testing
Guidance
Testing for Continuous Delivery with Visual Studio 2012 – Chapter 2: Unit Testing: Testing the Inside
Reference
Content Index for Unit Tests

See Also
Improve Code Quality Testing the application
Designing User Interfaces
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can create and design the user interface for your application by using a variety of tools in Visual Studio.

TO L EA RN M O RE A B O UT SEE

Designing any XAML-based app or application using Visual Designing XAML in Visual Studio and Blend for Visual Studio
Studio or Blend for Visual Studio. .

Designing desktop applications that use the WPF flavor of Create Modern Desktop Applications with Windows
XAML. Presentation Foundation

Developing a DirectX application in Visual Studio. Working with 3-D Assets for Games and Apps

Standard icons available for your programs. The Visual Studio Image Library

See Also
Walkthrough: Create a Simple Application The Visual Studio Image Library
Analyze and model your architecture
10/16/2020 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Make sure your app meets user requirements by using Visual Studio architecture and modeling tools to design
and model your app. Understand existing program code more easily by using Visual Studio to visualize the code's
structure, behavior, and relationships.
Create models at different levels of detail throughout the application lifecycle as part of your development process.
Track requirements, tasks, test cases, bugs, and other work associated with your models by linking model elements
to Team Foundation Server work items and your development plan. See Scenario: Change your design using
visualization and modeling.
To see which versions of Visual Studio support each feature, see Version support for architecture and modeling
tools

To
SC EN A RIO A RT IC L ES

Visualize code : - Visualize code


- Working with Classes and Other Types (Class Designer)
- See the code's organization and relationships by creating - Video: Understand your code dependencies through
code maps. Visualize dependencies between assemblies, visualization (Channel 9)
namespaces, classes, methods, and so on. - Video: Visualize the impact of a change (Channel 9)
- See the class structure and members for a specific project by
creating class diagrams from code.
- Find conflicts between your code and its design by creating
layer diagrams to validate code.

Note : In this release of Visual Studio, the term code map is


used in place of dependency graph. The term graph when
used alone generally refers to a Directed Graph or DGML
diagram (or document). Code maps are a specialized type of
DGML diagram.

Describe and communicate user requirements : - Create models for your app
- Model user requirements
- Clarify user stories, business rules, and other requirements - Video: Improve architecture through modeling (Channel 9)
and help ensure their consistency by drawing UML diagrams
such as use case, activity, and class diagrams.

Define the architecture : - Create models for your app


- Model your app's architecture
- Model the large-scale structure of your software system and - Video: Improve architecture through modeling (Channel 9)
the design patterns by drawing UML component, class, and - Video: Use layer diagrams to design and validate your
sequence diagrams. architecture (Channel 9)
- Define and enforce constraints on dependencies between
the components of your code by creating layer diagrams.
SC EN A RIO A RT IC L ES

Validate your system with the requirements and - Validate your system during development
intended design: - Video: Use layer diagrams to design and validate your
architecture (Channel 9)
- Define acceptance tests or system tests based on the
requirements models. This creates a strong relationship
between the tests and your users' requirements and helps
you update the system more easily when the requirements
change.
- Validate code dependencies with layer diagrams that
describe the intended architecture and prevent changes that
might conflict with the design.

Share models, diagrams, and code maps using Team When you have multiple users who work with these items
Foundation version control: under Team Foundation version control, use these guidelines
to help you avoid version control issues:
- Put code maps, modeling projects, UML diagrams, and layer
diagrams under Team Foundation version control so you can - Manage models and diagrams under version control
share them.

Generate or configure par ts of your application from - Generate and configure your app from models
UML or domain-specific languages :

- Make your design more responsive to requirements changes


and easily variable across a product line.

Customize models and diagrams : - Extend UML models and diagrams


- Modeling SDK for Visual Studio - Domain-Specific
- Adapt models to how your project uses them by defining Languages
additional properties for UML elements, validation constraints
to make sure that your models conform to your business
rules, and additional menu commands and toolbox items.
- Create your own domain-specific languages.

Generate text using T4 templates : - Code Generation and T4 Text Templates

- Use text blocks and control logic inside templates to


generate text-based files.

Types of Models and Their Uses


M O DEL T Y P E A N D T Y P IC A L USES

Code maps

Code maps help you see the organization and relationships in your code.

Typical uses:

- Examine program code so you can better understand its structure and its dependencies, how to update it, and estimate the
cost of proposed changes.

See:

- Map dependencies across your solutions


- Use code maps to debug your applications
- Find potential problems using code map analyzers
M O DEL T Y P E A N D T Y P IC A L USES

Layer diagram

Layer diagrams let you define the structure of an application as a set of layers or blocks with explicit dependencies. You can run
validation to discover conflicts between dependencies in the code and dependencies described on a layer diagram.

Typical uses:

- Stabilize the structure of the application through numerous changes over its life.
- Discover unintentional dependency conflicts before checking in changes to the code.

See:

- Create layer diagrams from your code


- Layer Diagrams: Reference
- Validate code with layer diagrams

UML model

A UML model includes several views, including class, component, use case, activity, and sequence diagrams. You can customize
UML to suit your application domain. For example, you can attach tags, additional information, and constraints to the model
elements. You can also define tools that operate on the models. See Create models for your app.

Typical uses:

- Describe requirements and design. You can quickly apply UML to the development of any application. See Use models in your
development process.
- Generate or configure tests or parts of an application. Some work is required to customize the notation and develop the
generation templates or configurable application. See Generate and configure your app from models.
- For general description and for code generation or configuration in smaller projects.

Domain-specific language (DSL)

A DSL is a notation that you design for a specific purpose. In Visual Studio, it is usually graphical.

Typical uses:

- Generate or configure parts of the application. Work is required to develop the notation and tools. The result can be a better fit
to your domain than a UML customization.
- For large projects or in product lines where the investment in developing the DSL and its tools is returned by its use in more
than one project.

See:

- Modeling SDK for Visual Studio - Domain-Specific Languages

Where can I get more information?


RESO URC E L IN K S

Forums - Visual Studio Visualization & Modeling Tools


- Visual Studio Visualization & Modeling SDK (DSL Tools)

See Also
What's new for modeling in Visual Studio 2015
DevOps and Application Lifecycle Management
Compiling and Building in Visual Studio
11/21/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can use Visual Studio to build applications and to create assemblies and executable programs at frequent
intervals during a development cycle. By building your code often, you can identify compile-time errors, such as
incorrect syntax, misspelled keywords, and type mismatches, earlier. You can also detect and correct run-time
errors, such as logic errors and semantic errors, by frequently building and running debug versions of the code.
When you have fully developed and sufficiently debugged a project or solution, you can compile its components
in a Release build. By default, a Release build is optimized and designed to be smaller and run faster than a
debug version. For more information, see Walkthrough: Building an Application.

Choosing a Build Method


You can build an application by using the default build options in the IDE, at a command prompt, or by using
Team Foundation Build. Each of these options use MSBuild as the underlying technology, and each approach has
specific benefits, as the following table shows.

B UIL D M ET H O D B EN EF IT S F O R M O RE IN F O RM AT IO N

Using the IDE - You can more easily create and run Building and Cleaning Projects and
builds immediately. Solutions in Visual Studio
- You can run multi-processor builds
for C++ and C# projects.
- You can customize some aspects of
the build system.

Running an MSBuild command line - You can build projects without MSBuild
installing Visual Studio.
- You can run multi-processor builds
for all project types.
- You can customize most areas of the
build system.

Using Team Foundation Build - You can automate your build process. Build the application
For example, you can build one or
more projects nightly or every time
that code is checked in. You can also
build projects on shared build servers
rather than on your development
computer.
- You can quickly specify the code that
you want to build, the tests that you
want to run, and other common
options.
- You can modify the build workflow,
and as needed, create build activities to
perform deeply customized tasks.
Building from the IDE
When you create a project, default build configurations are defined for it, and a solution build configuration is
assigned to it to provide context for builds. Solution configurations define how the projects in solution are built
and deployed. Project configurations are a set of project properties that are unique for a platform and build type
(for example, Release Win32). You can edit these default configurations, and you can create your own
configurations. For more information, see Introduction to the Project Designer and NIB How to: Modify Project
Properties and Configuration Settings.
From within the IDE, you can perform the following additional tasks:
Change the build output directory.
Identify projects that are dependent on the output from another project in order to build correctly.
Change the amount of information included in the build log or Output window for builds.
Hide specific compiler warnings for Visual C#, Visual C++, or Visual Basic.
Specify custom pre-compile and post-compile actions for a build.
Improve build performance by using parallel builds. For more information, see Building Multiple Projects
in Parallel or the blog post Tuning C++ build parallelism.

See Also
Walkthrough: Building an Application Understanding Build Configurations Understanding Build Platforms
Building (Compiling) Web Site Projects How to: Create and Remove Project Dependencies
Walkthrough: Building an Application
11/21/2019 • 6 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

By completing this walkthrough, you’ll become more familiar with several options that you can configure when
you build applications with Visual Studio. You’ll create a custom build configuration, hide certain warning
messages, and increase build output information, among other tasks, for a sample application.
This topic contains the following sections:
Install the Sample Application
Create a Custom Build Configuration
Build the Application
Hide Compiler Warnings
Display Additional Build Details in the Output Window
Create a Release Build
To install the sample application
1. On the menu bar, choose Tools , Extensions and Updates .
2. Choose the Online category, and then choose the Samples Galler y category.
3. Specify Introduction in the search box to find the sample.

4. In the results list, choose either Introduction to Building WPF Applications (Visual C#) or
Introduction to Building WPF Applications (Visual Basic) .
5. Choose the Download button, and then choose the Close button.
The Introduction to Building WPF Applications sample appears in the New Project dialog box.
To create a solution for the sample application
1. Open the New Project dialog box.

2. In the Installed category, choose the Samples category to display the Introduction to Building WPF
Applications sample.
3. Name the solution IntroWPFcsharp for Visual C#.

OR
Name the solution IntroWPFvb for Visual Basic.
4. Choose the OK button.

Create a Custom Build Configuration


When you create a solution, debug and release build configurations and their default platform targets are defined
for the solution automatically. You can then customize these configurations or create your own. Build
configurations specify the build type. Build platforms specify the operating system that an application targets for
that configuration. For more information, see Understanding Build Configurations, Understanding Build Platforms,
and Debug and Release Project Configurations.
You can change or create configurations and platform settings by using the Configuration Manager dialog box.
In this procedure, you’ll create a build configuration for testing.
To create a build configuration
1. Open the Configuration Manager dialog box.

2. In the Active solution configuration list, choose New .


3. In the New Solution Configuration dialog box, name the new configuration Test , copy settings from
the existing Debug configuration, and then choose the OK button.
4. In the Active solution platform list, choose New .
5. In the New Solution Platform dialog box, choose x64 , and don’t copy settings from the x86 platform.

6. Choose the OK button.


The active solution configuration has been changed to Test with the active solution platform set to x64.

You can quickly verify or change the active solution configuration by using the Solution Configurations
list on the Standard toolbar.

Build the Application


Next, you’ll build the solution with the custom build configuration.
To build the solution
On the menu bar, choose Build , Build Solution .
The Output window displays the results of the build. The build succeeded, but several warning messages
were generated.
Figure 1: Visual Basic warnings

Figure 2: Visual C# warnings

Hide Compiler Warnings


You can temporarily hide certain warning messages during a build rather than have them clutter up the build
output.
To hide a specific Visual C# warning
1. In Solution Explorer , choose the top-level project node.
2. On the menu bar, choose View , Proper ty Pages .
The Project Designer opens.
3. Choose the Build page and then, in the Suppress warnings box, specify the warning number 1762 .
For more information, see Build Page, Project Designer (C#).
4. Build the solution.
The Output window displays only summary information for the build.

To suppress all Visual Basic build warnings


1. In Solution Explorer , choose the top-level project node.
2. On the menu bar, choose View , Proper ty Pages .
The Project Designer opens.
3. On the Compile page, select the Disable all warnings check box.

For more information, see Configuring Warnings in Visual Basic.


4. Build the solution.
The Output window displays only summary information for the build.

For more information, see How to: Suppress Compiler Warnings.

Display Additional Build Details in the Output Window


You can change how much information about the build process appears in the Output window. Build verbosity is
usually set to Minimal, which means that the Output window displays only a summary of the build process along
with any high priority warnings or errors. You can display more information about the build by using the Options
Dialog Box, Projects and Solutions, Build and Run.

IMPORTANT
If you display more information, the build will take longer to complete.

To change the amount of information in the Output window


1. Open the Options dialog box.

2. Choose the Projects and Solutions category, and then choose the Build and Run page.
3. In the MSBuild project build output verbosity list, choose Normal , and then choose the OK button.
4. On the menu bar, choose Build , Clean Solution .
5. Build the solution, and then review the information in the Output window.
The build information includes the time that the build started (located at the beginning), the order in which
files were processed, and the amount of time that the process took to complete (located at the end). This
information also includes the actual compiler syntax that Visual Studio runs during the build.
For example, in the Visual C# build, the /nowarn option lists the warning code, 1762, that you specified
earlier in this topic, along with three other warnings.
In the Visual Basic build, /nowarn doesn’t include specific warnings to exclude, so no warnings appear.

TIP
You can search the contents of the Output window if you display the Find dialog box by choosing the Ctrl+F keys.

For more information, see How to: View, Save, and Configure Build Log Files.
Create a Release Build
You can build a version of the sample application that’s optimized for shipping it. For the release build, you’ll
specify that the executable is copied to a network share before the build is kicked off.
For more information, see How to: Change the Build Output Directory and Building and Cleaning Projects and
Solutions in Visual Studio.
To specify a release build for Visual Basic
1. Open the Project Designer .

2. Choose the Compile page.


3. In the Configuration list, choose Release .
4. In the Platform list, choose x86 .
5. In the Build output path box, specify a network path.
For example, you can specify \\myserver\builds.

IMPORTANT
A message box might appear, warning you that the network share that you’ve specified might not be a trusted
location. If you trust the location that you’ve specified, choose the OK button in the message box.

6. Build the application.

To specify a release build for Visual C#


1. Open the Project Designer .
2. Choose the Build page.
3. In the Configuration list, choose Release .
4. In the Platform list, choose x86 .
5. In the Output path box, specify a network path.
For example, you could specify \\myserver\builds.

IMPORTANT
A message box might appear, warning you that the network share that you’ve specified might not be a trusted
location. If you trust the location that you’ve specified, choose the OK button in the message box.

6. Build the application.

The executable file is copied to the network path that you specified. Its path would be
\\myserver\builds\FileName.exe.
Congratulations: you’ve successfully completed this walkthrough.

See Also
Walkthrough: Building a Project (C++)
ASP.NET Web Application Project Precompilation Overview
Walkthrough: Using MSBuild
Building and Cleaning Projects and Solutions in
Visual Studio
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

By using the procedures in this topic, you can build, rebuild, or clean all or some of the projects or project items in
a solution. For a step-by-step tutorial, see Walkthrough: Building an Application.

NOTE
The UI in your edition of Visual Studio might differ from what this topic describes, depending on your active settings. To
change your settings, open the Tools menu, and then choose Impor t and Expor t Settings . For more information, see
Customizing Development Settings in Visual Studio.

To build, rebuild, or clean an entire solution


1. In Solution Explorer , choose or open the solution.
2. On the menu bar, choose Build , and then choose one of the following commands:
Choose Build or Build Solution to compile only those project files and components that have
changed since the most recent build.

NOTE
The Build command becomes Build Solution when a solution includes more than one project.

Choose Rebuild Solution to "clean" the solution and then build all project files and components.
Choose Clean Solution to delete any intermediate and output files. With only the project and
component files left, new instances of the intermediate and output files can then be built.

To build or rebuild a single project


1. In Solution Explorer , choose or open the project.
2. On the menu bar, choose Build , and then choose either Build ProjectName or Rebuild ProjectName.
Choose Build ProjectName to build only those project components that have changed since the
most recent build.
Choose Rebuild ProjectName to "clean" the project and then build the project files and all project
components.

To build only the startup project and its dependencies


1. On the menu bar, choose Tools , Options .
2. In the Options dialog box, expand the Projects and Solutions node, and then choose the Build and
Run page.
The Build and Run, Projects and Solutions, Options dialog box opens.
3. Select the Only build star tup projects and dependencies on Run check box.
When this check box is selected, only the current startup project and its dependencies are built when you
perform either of the following steps:
On the menu bar, choose Debug > Star t Debugging (F5).
On the menu bar, choose Build > Build Solution (CTRL+SHIFT+B).
When this check box is cleared, all projects, their dependencies, and the solution files are built when
you run either of the preceding commands. By default, this check box is cleared.

To build only the selected Visual C++ project


1. Choose a Visual C++ project, and then, on the menu bar, choose Build , Project Only , and one of the
following commands:
Build Only ProjectName
Rebuild Only ProjectName
Clean Only ProjectName
Link Only ProjectName
These commands apply only to the Visual C++ project that you chose, without building, rebuilding,
cleaning, or linking any project dependencies or solution files. Depending on your version of Visual
Studio, the Project Only submenu might contain more commands.

To compile multiple C++ project items


1. In Solution Explorer , choose multiple files that have can be compiled actions, open the shortcut menu for
one of those files, and then choose Compile .
If the files have dependencies, the files will be compiled in dependency order. The compile operation will fail
if the files require a precompiled header that isn’t available when you compile. The compile operation uses
the current active solution configuration.

To stop a build
1. Perform either of the following steps:
On the menu bar, choose Build , Cancel .
Choose the Ctrl + Break keys.

See also
How to: View, Save, and Configure Build Log Files Obtaining Build Logs Compiling and Building Understanding
Build Configurations Debug and Release Project Configurations C/C++ Building Reference Devenv Command Line
Switches Solutions and Projects
How to: Change the Build Output Directory
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can specify the location of output on a per-configuration basis (for debug, release, or both) generated by your
project.

NOTE
If you have a Setup project see the note at the end of this article.

Changing the Build Output directory


To change the build output directory
1. On the menu bar, choose Project , Appname Proper ties . You can also right-click the project node in the
Solution Explorer and select Proper ties .
2. If you have a Visual Basic project, select the Compile tab. If you have a Visual C# project, select the Build
tab. If you have a C++ project or a JavaScript project, select the General tab.
3. In the configuration drop-down at the top, choose the configuration whose output file location you want to
change (debug, release, or all).
Find the output path entry (Build output path in Visual Basic, Output Director y in Visual C++, Output
Path in JavaScript and C#). Specify a new build output directory relative to the project directory.

NOTE
In a Setup Project, the Output file name box changes only the location of the Setup.exe file, not the location of the project
files. For more information, see Build, Configuration Proper ties, Deployment Project Proper ties Dialog Box.

See Also
Build Page, Project Designer (C#) General Property Page (Project) Compiling and Building
How to: Build to a Common Output Directory
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

By default, Visual Studio builds each project in a solution in its own folder inside the solution. You can change the
build output paths of your projects to force all outputs to be placed in the same folder.
To place all solution outputs in a common directory
1. Click on one project in the solution.
2. On the Project menu, click Proper ties .
3. Depending on the type of project, click on either the Compile tab or the Build tab, and set the Output path
to a folder to use for all projects in the solution.
4. Repeat steps 1-3 for all projects in the solution.

See Also
Compiling and Building How to: Change the Build Output Directory
Specifying Custom Build Events in Visual Studio
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

By specifying a custom build event, you can automatically run commands before a build starts or after it finishes.
For example, you can run a .bat file before a build starts or copy new files to a folder after the build is complete.
Build events run only if the build successfully reaches those points in the build process.
For specific information about the programming language that you’re using, see the following topics:
Visual Basic--How to: Specify Build Events (Visual Basic).
Visual C# and F#--How to: Specify Build Events (C#).
Visual C++--Specifying Build Events.

Syntax
Build events follow the same syntax as DOS commands, but you can use macros to create build events more easily.
For a list of available macros, see Pre-build Event/Post-build Event Command Line Dialog Box.
For best results, follow these formatting tips:
Add a call statement before all build events that run .bat files.
Example: call C:\MyFile.bat

Example: call C:\MyFile.bat call C:\MyFile2.bat

Enclose file paths in quotation marks.


Example (for Windows 8): "%ProgramFiles(x86)%\Microsoft SDKs\Windows\v8.0A\Bin\NETFX 4.0
Tools\gacutil.exe" -if "$(TargetPath)"
Separate multiple commands by using line breaks.
Include wildcards as needed.
Example: for %I in (*.txt *.doc *.html) do copy %I c:\ mydirectory \

NOTE
%I in the code above should be %%I in batch scripts.

See Also
Compiling and Building Pre-build Event/Post-build Event Command Line Dialog Box MSBuild Special Characters
Walkthrough: Building an Application
How to: Set Multiple Startup Projects
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Visual Studio allows you to specify how more than one project is run when you start the debugger.
To set multiple startup projects
1. In the Solution Explorer , select the solution (the very top node). Right-click the node to get the context
menu.
2. Select Proper ties . The Solution Proper ty Pages dialog box opens.
3. Expand the Common Proper ties node, and click Star tup Project .
4. Click Multiple Star tup Projects and set the appropriate actions. For more information, see NIB How to:
Modify Project Properties and Configuration Settings.

See Also
Compiling and Building Creating Solutions and Projects
How to: Create and Remove Project Dependencies
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

When building a solution that contains multiple projects, it can be necessary to build certain projects first, to
generate code used by other projects. When a project consumes executable code generated by another project, the
project that generates the code is referred to as a project dependency of the project that consumes the code. Such
dependency relationships can be defined in the Project Dependencies Dialog Box.
To assign dependencies to projects
1. In Solution Explorer, select a project.
2. On the Project menu, choose Project Dependencies .
The Project Dependencies dialog box opens.

NOTE
The Project Dependencies option is only available in a solution with more than one project.

3. On the Dependencies tab, select a project from the Project drop-down menu.
4. In the Depends on field, select the check box of any other project that must build before this project does.
Your solution must consist of more than one project before you can create project dependencies.
To remove dependencies from projects
1. In Solution Explorer, select a project.
2. On the Project menu, choose Project Dependencies .
The Project Dependencies dialog box opens.

NOTE
The Project Dependencies option is only available in a solution with more than one project.

3. On the Dependencies tab, select a project from the Project drop-down menu.
4. In the Depends on field, clear the check boxes beside any other projects that are no longer dependencies
of this project.

See Also
Building and Cleaning Projects and Solutions in Visual Studio Compiling and Building Understanding Build
Configurations NIB How to: Modify Project Properties and Configuration Settings
How to: View, Save, and Configure Build Log Files
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

After you build a project in the Visual Studio IDE, you can view information about that build in the Output
window. By using this information, you can, for example, troubleshoot a build failure. For C++ projects, you can
also view the same information in a .txt file that's created and saved automatically. For managed-code projects,
you can copy and paste the information from the Output window into a .txt file and save it yourself. You can also
use the IDE to specify what kinds of information you want to view about each build.
If you build any kind of project by using MSBuild, you can create a .txt file to save information about the build. For
more information, see Obtaining Build Logs.
To view the build log file for a C++ project
1. In Windows Explorer or File Explorer , open the following file: \...\Visual Studio
Version\Projects\ProjectName\ProjectName\Debug\ProjectName.txt
To create a build log file for a managed-code project
1. On the menu bar, choose Build , Build Solution .
2. In the Output window, highlight the information from the build, and then copy it to the Clipboard.
3. Open a text editor, such as Notepad, paste the information into the file, and then save it.
To change the amount of information included in the build log
1. On the menu bar, choose Tools , Options .
2. On the Projects and Solutions page, choose the Build and Run page.
3. In the MSBuild project build output verbosity list, choose one of the following values, and then choose
the OK button.

VERB O SIT Y L EVEL DESC RIP T IO N

Quiet Displays a summary of the build only.

Minimal Displays a summary of the build and errors, warnings, and


messages that are categorized as highly important.

Normal Displays a summary of the build; errors, warnings, and


messages that are categorized as highly important; and
the main steps of the build. You'll use this level of detail
most frequently.

Detailed Displays a summary of the build; errors, warnings, and


messages that are categorized as highly important; all of
the steps of the build; and messages that are categorized
as of normal importance.
VERB O SIT Y L EVEL DESC RIP T IO N

Diagnostic Displays all data that's available for the build. You can use
this level of detail to help debug issues with custom build
scripts and other build issues.

For more information, see Options Dialog Box, Projects and Solutions, Build and Run and LoggerVerbosity.

IMPORTANT
You must rebuild the project for your changes to take effect in the Output window (all projects) and the
ProjectName.txt file (C++ projects only).

See Also
Obtaining Build Logs Building and Cleaning Projects and Solutions in Visual Studio Compiling and Building
How to: Exclude Projects from a Build
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can build a solution without building all projects that it contains. For example, you might exclude a project that
breaks the build. You could then build the project after you investigate and address the issues.
You can exclude a project by taking the following approaches:
Removing it temporarily from the active solution configuration.
Creating a solution configuration that doesn’t include the project.
For more information, see Understanding Build Configurations.
To temporarily remove a project from the active solution configuration
1. On the menu bar, choose Build , Configuration Manager .
2. In the Project contexts table, locate the project you want to exclude from the build.
3. In the Build column for the project, clear the check box.
4. Choose the Close button, and then rebuild the solution.
To create a solution configuration that excludes a project
1. On the menu bar, choose Build , Configuration Manager .
2. In the Active solution configuration list, choose <New> .
3. In the Name box, enter a name for the solution configuration.
4. In the Copy settings from list, choose the solution configuration on which you want to base the new
configuration (for example, Debug ), and then choose the OK button.
5. In the Configuration Manager dialog box, clear the check box in the Build column for the project that you
want to exclude, and then choose the Close button.
6. On the Standard toolbar, verify that the new solution configuration is the active configuration in the
Solution Configurations box.
7. On the menu bar, choose Build , Rebuild Solution .

See Also
Understanding Build Configurations How to: Create and Edit Configurations How to: Build Multiple Configurations
Simultaneously
How to: Suppress Compiler Warnings
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can declutter a build log by specifying one or more kinds of compiler warnings that you don’t want it to
contain. For example, you might use this technique to review some but not all of the information that’s generated
automatically when you set the build-log verbosity to Normal, Detailed, or Diagnostic. For more information about
verbosity, see How to: View, Save, and Configure Build Log Files.
To suppress specific warnings for Visual C# or F#
1. In Solution Explorer , choose the project in which you want to suppress warnings.
2. On the menu bar, choose View , Proper ty Pages .
3. Choose the Build page.
4. In the Suppress warnings box, specify the error codes of the warnings that you want to suppress,
separated by semicolons, and then rebuild the solution.
To suppress specific warnings for Visual C++
1. In Solution Explorer , choose the project or source file in which you want to suppress warnings.
2. On the menu bar, choose View , Proper ty Pages .
3. Choose the Configuration Proper ties category, choose the C/C++ category, and then choose the
Advanced page.
4. Perform one of the following steps:
In the Disable Specific Warnings box, specify the error codes of the warnings that you want to
suppress, separated by a semicolon.
In the Disable Specific Warnings box, choose Edit to display more options.
5. Choose the OK button, and then rebuild the solution.

Suppressing Warnings for Visual Basic


You can hide specific compiler warnings for Visual Basic by editing the .vbproj file for the project. You can also use
the Compile Page, Project Designer to suppress warnings by category. For more information, see Configuring
Warnings in Visual Basic.
To suppress specific warnings for Visual Basic
1. In Solution Explorer , choose the project in which you want to suppress warnings.
2. On the menu bar, choose Project , Unload Project .
3. In Solution Explorer , open the shortcut menu for the project, and then choose Edit ProjectName.vbproj .
The project file is opened in the code editor.
4. Locate the <NoWarn></NoWarn> element in the build configuration with which you’re building.
The following example shows the <NoWarn></NoWarn> element in bold text for the Debug build configuration
on an x86 platform:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">


<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<NoWarn></NoWarn>
<WarningLevel>1</WarningLevel>
</PropertyGroup>

5. Add one or more warning numbers as the value of the <NoWarn> element. If you specify multiple warning
numbers, separate them with a comma, as the following example shows.

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">


<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<ErrorReport>prompt</ErrorReport>
<NoWarn>40059,42024</NoWarn>
<WarningLevel>1</WarningLevel>
</PropertyGroup>

6. Save the changes to the .vbproj file.


7. On the menu bar, choose Project , Reload Project .
8. On the menu bar, choose Build , Rebuild Solution .
The Output window no longer shows the warnings that you specified.
For more information, see /nowarn.

See Also
Walkthrough: Building an Application
How to: View, Save, and Configure Build Log Files
Compiling and Building
Understanding Build Configurations
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can store different configurations of solution and project properties to use in different kinds of builds. To
create, select, modify, or delete a configuration, you can use the Configuration Manager . To open it, on the
menu bar, choose Build , Configuration Manager , or just type Configuration in the Quick Launch box. You
can also use the Solution Configurations list on the Standard toolbar to select a configuration or open the
Configuration Manager .

NOTE
If you can't find solution configuration settings on the toolbar and can't access the Configuration Manager , Visual Basic
development settings may be applied. For more information, see How to: Manage Configurations with Visual Basic
Developer Settings Applied.

By default, Debug and Release configurations are included in projects that are created by using Visual Studio
templates. A Debug configuration supports the debugging of an app, and a Release configuration builds a
version of the app that can be deployed. For more information, see How to: Set Debug and Release
Configurations. You can also create custom solution configurations and project configurations. For more
information, see How to: Create and Edit Configurations.

Solution Configurations
A solution configuration specifies how projects in the solution are to be built and deployed. To modify a solution
configuration or define a new one, in the Configuration Manager , under Active solution configuration ,
choose Edit or New .
Each entry in the Project contexts box in a solution configuration represents a project in the solution. For every
combination of Active solution configuration and Active solution platform , you can set how each project
is used. (For more information about solution platforms, see Understanding Build Platforms.)

NOTE
When you define a new solution configuration and select the Create new project configurations check box, Visual
Studio automatically assigns the new configuration to all of the projects. Likewise, when you define a new solution platform
and select the Create new project platforms check box, Visual Studio automatically assigns the new platform to all of
the projects. Also, if you add a project that targets a new platform, Visual Studio adds that platform to the list of solution
platforms and assigns it to all of the projects.
You can still modify the settings for each project.

The active solution configuration also provides context to the IDE. For example, if you're working on a project and
the configuration specifies that it will be built for a mobile device, the Toolbox displays only items that can be
used in a mobile device project.
Project Configurations
The configuration and platform that a project targets are used together to specify the properties to use when it's
built. A project can have a different set of property definitions for each combination of configuration and
platform. To modify the properties of a project, you can use its Property Pages. (In Solution Explorer , open the
shortcut menu for the project and then choose Proper ties .)
For each project configuration, you can define configuration-dependent properties as needed. For example, for a
particular build, you can set which project items will be included, and what output files will be created, where
they will be put, and how they will be optimized.
Project configurations can differ considerably. For example, the properties of one configuration might specify
that its output file be optimized to occupy the minimum space, while another configuration might specify that its
executable runs at the maximum speed.
Project configurations are stored by solution—not by user—so that they can be shared by a team.
Although project dependencies are configuration-independent, only the projects that are specified in the active
solution configuration will be built.

How Visual Studio Assigns Project Configurations


When you define a new solution configuration and don't copy settings from an existing one, Visual Studio uses
the following criteria to assign default project configurations. The criteria are evaluated in the order shown.
1. If a project has a configuration name (<configuration name> <platform name>) that exactly matches the
name of the new solution configuration, that configuration is assigned. Configuration names are not case-
sensitive.
2. If the project has a configuration name in which the configuration-name part matches the new solution
configuration, that configuration is assigned, whether the platform portion matches or not.
3. If there is still no match, the first configuration that's listed in the project is assigned.

How Visual Studio Assigns Solution Configurations


When you create a project configuration (in the Configuration Manager , by choosing New on the drop-down
menu in the Configuration column for that project) and select the Create new solution configurations
check box, Visual Studio looks for a like-named solution configuration to build the project on each platform it
supports. In some cases, Visual Studio renames existing solution configurations or defines new ones.
Visual Studio uses the following criteria to assign solution configurations.
If a project configuration doesn't specify a platform or specifies just one platform, then a solution
configuration whose name matches that of the new project configuration is either found or added. The
default name of this solution configuration does not include a platform name; it takes the form <project
configuration name>.
If a project supports multiple platforms, a solution configuration is either found or added for each
supported platform. The name of each solution configuration includes both the project configuration
name and the platform name, and has the form <project configuration name> <platform name>.

See Also
Walkthrough: Building an Application Compiling and Building Solutions and Projects C/C++ Building Reference
Devenv Command Line Switches
How to: Create and Edit Configurations
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can create several build configurations for a solution. For example, you can configure a debug build that your
testers can use to find and fix problems, and you can configure different kinds of builds that you can distribute to
different customers.

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the
following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For
more information, see Personalizing the IDE.

Creating Build Configurations


You can use the Configuration Manager dialog box to select or modify existing build configurations, or you can
create new ones.
To open the Configuration Manager dialog box
In Solution Explorer , open the shortcut menu for the solution and then choose Configuration
Manager .

NOTE
If the Configuration Manager command doesn't appear on the shortcut menu, look under the Build menu on
the menu bar. If it doesn't appear there either, on the menu bar, choose Tools , Options , and then in the left pane of
the Options dialog box, expand Projects and Solutions , General, and in the right pane, select the Show
advanced build configurations check box.

In the Configuration Manager dialog box, you can use the Active solution configuration drop-down
list to select a solution-wide build configuration, modify an existing one, or create a new configuration. You
can use the Active solution platform drop-down list to select the platform that the configuration targets,
modify an existing one, or add a new platform. The Project contexts pane lists the projects in the solution.
For each project, you can select a project-specific configuration and platform, modify existing ones, or
create a new configuration or add a new platform. You can also select check boxes that indicate whether
each project is included when you use the solution-wide configuration to build or deploy the solution.
After you set up the configurations you want, you can set project properties that are appropriate for those
configurations.
To set properties based on configurations
In Solution Explorer , open the shortcut menu for a project and then choose Proper ties .
The Proper ty Pages window opens.
You can set properties for your configurations. For example, for a Release configuration, you can specify
that code is optimized when the solution is built, and for a Debug configuration, you can specify that the
DEBUG conditional compilation symbol is included. For more information about property page settings, see
Introduction to the Project Designer.

Creating and Modifying Project Configurations


To create a project configuration
1. Open the Configuration Manager dialog box.
2. Select a project in the Project column.
3. In the Configuration drop-down list for that project, choose New .
The New Project Configuration dialog box opens.
4. In the Name box, enter a name for the new configuration.
5. To use the property settings from an existing project configuration, in the Copy settings from drop-down
list, choose a configuration.
6. To create a solution-wide configuration at the same time, select the Create new solution configuration
check box.
To rename a project configuration
1. Open the Configuration Manager dialog box.
2. In the Project column, select the project that has the project configuration you want to rename.
3. In the Configuration drop-down list for that project, choose Edit .
The Edit Project Configurations dialog box opens.
4. Select the project configuration name you want to change.
5. Select Rename , and then enter a new name.

Creating and Modifying Solution-wide Build Configurations


To create a solution-wide build configuration
1. Open the Configuration Manager dialog box.
2. In the Active solution configuration drop-down list, choose New .
The New Solution Configuration dialog box opens.
3. In the Name text box, enter a name for the new configuration.
4. To use the settings from an existing solution configuration, in the Copy settings from drop-down list,
choose a configuration.
5. If you want to create project configurations at the same time, select the Create new project
configurations check box.
To rename a solution-wide build configuration
1. Open the Configuration Manager dialog box.
2. In the Active solution configuration drop-down list, choose Edit .
The Edit Solution Configurations dialog box opens.
3. Select the solution configuration name you want to change.
4. Select Rename , and then enter a new name.
To modify a solution-wide build configuration
1. Open the Configuration Manager dialog box.
2. In the Active solution configuration drop-down list, select the configuration you want.
3. In the Project contexts pane, for every project, select the Configuration and Platform you want, and
select whether to Build it and whether to Deploy it..

See Also
Understanding Build Configurations Building and Cleaning Projects and Solutions in Visual Studio NIB How to:
Modify Project Properties and Configuration Settings
How to: Manage Build Configurations with Visual
Basic Developer Settings Applied
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

By default, all advanced build configuration options are hidden with Visual Basic Developer settings applied. This
topic explains how to manually enable these settings.

Enabling advanced build configurations


By default, the Visual Basic Developer settings hide the option to open the Configuration Manager dialog box
and the Configuration and Platform lists in the Project Designer.
To enable advanced build configurations
1. On the Tools menu, click Options .
2. Expand Projects and Solutions , and click General .

NOTE
The General node is visible even if the Show all settings option is unchecked. If you want to see every option
available, click Show all settings .

3. Click Show advanced build configurations .


4. Click OK .
On the Build menu, Configuration Manager is now available, and the Configuration and Platform lists
are visible in the Project Designer.

See Also
Understanding Build Configurations Compiling and Building
How to: Build Multiple Configurations Simultaneously
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can build most types of projects with multiple, or even all, of their build configurations at the same time by
using the Batch Build dialog box. However, you can't build the following types of projects in multiple build
configurations at the same time:
1. Windows 8.x Store apps built for Windows using JavaScript.
2. All Visual Basic projects.
For more information about build configurations, see Understanding Build Configurations.
To build a project in multiple build configurations
1. On the menu bar, choose Build , Batch Build .
2. In the Build column, select the check boxes for the configurations in which you want to build a project.

TIP
To edit or create a build configuration for a solution, choose Build , Configuration Manager on the menu bar to
open the Configuration Manager dialog box. After you have edited a build configuration for a solution, choose the
Rebuild button in the Batch Build dialog box to update all build configurations for the projects in the solution.

3. Choose the Build or Rebuild buttons to build the project with the configurations that you specified.

See Also
How to: Create and Edit Configurations Understanding Build Configurations Building Multiple Projects in Parallel
Understanding Build Platforms
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can store different versions of solution and project properties that apply to different target platforms. For
example, you can create a Debug configuration that targets an x86 platform and a Debug configuration that
targets an x64 platform. You can quickly change the active platform so that you can easily build multiple
configurations.

In This Section
How to: Configure Projects to Target Platforms Explains how to configure a project to target a specific platform.
How to: Configure Projects to Target Multiple Platforms Explains how to configure a project to target multiple
platforms.

See Also
Walkthrough: Building an Application Building and Cleaning Projects and Solutions in Visual Studio Compiling and
Building
How to: Configure Projects to Target Platforms
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Visual Studio enables you to set up your applications to target different platforms, including 64-bit platforms. For
more information on 64-bit platform support in Visual Studio, see 64-bit Applications.

Targeting Platforms with the Configuration Manager


The Configuration Manager provides a way for you to quickly add a new platform to target with your project. If
you select one of the platforms included with Visual Studio, the properties for your project are modified to build
your project for the selected platform.
To configure a project to target a 64-bit platform
1. On the menu bar, choose Build , Configuration Manager .
2. In the Active solution platform list, choose a 64-bit platform for the solution to target, and then choose
the Close button.
a. If the platform that you want doesn’t appear in the Active solution platform list, choose New .
The New Solution Platform dialog box appears.
b. In the Type or select the new platform list, choose x64 .

NOTE
If you give your configuration a new name, you may have to modify the settings in the Project Designer to
target the correct platform.

c. If you want to copy the settings from a current platform configuration, choose it, and then choose the
OK button.
The properties for all projects that target the 64-bit platform are updated, and the next build of the project
will be optimized for 64-bit platforms.

Targeting Platforms in the Project Designer


The Project Designer also provides a way to target different platforms with your project. If selecting one of the
platforms included in the list in the New Solution Platform dialog box does not work for your solution, you can
create a custom configuration name and modify the settings in the Project Designer to target the correct
platform.
Performing this task varies based on the programming language you are using. See the following links for more
information:
For Visual Basic projects, see /platform (Visual Basic).
For Visual C# projects, see Build Page, Project Designer (C#).
For Visual C++ projects, see /clr (Common Language Runtime Compilation).

See Also
Understanding Build Platforms /platform (C# Compiler Options) 64-bit Applications Visual Studio IDE 64-Bit
Support
How to: Configure Projects to Target Multiple
Platforms
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Visual Studio provides a way for a solution to target several different CPU architectures, or platforms, at once. The
properties to set these are accessed through the Configuration Manager dialog box.

Targeting a Platform
The Configuration Manager dialog box allows you to create and set solution-level and project-level
configurations and platforms. Each combination of solution-level configurations and targets can have a unique set
of properties associated with it, allowing you to easily switch between, for example, a Release configuration that
targets an x64 platform, a Release configuration that targets an x86 platform, and a Debug configuration that
targets an x86 platform.
To set your configuration to target a different platform
1. On the Build menu, click Configuration Manager .
2. In the Active solution platform box , select the platform you want your solution to target, or select
<New> to create a new platform. Visual Studio will compile your application to target the platform that is
set as the active platform in the Configuration Manager dialog box.

Removing a Platform
If you realize that you have no need for a platform, you can remove it using the Configuration Manager dialog box.
This will remove all solution and project settings that you configured for that combination of configuration and
target.
To remove a platform
1. On the Build menu, click Configuration Manager .
2. In the Active solution platform box , select <Edit> . The Edit Solution Platforms dialog box opens.
3. Click the platform you want to remove, and click Remove .

Targeting Multiple Platforms with One Solution


Because you can change the settings based on the combination of configuration and platform settings, you can set
up a solution that can target more than one platform.
To target multiple platforms
1. Use the Configuration Manager to add at least two target platforms for the solution.
2. Select the platform you want to target from the Active solution platform list.
3. Build the solution.
To build multiple solution configurations at once
1. Use the Configuration Manager to add at least two target platforms for the solution.
2. Use the Batch Build window to build several solution configurations at once.
It is possible to have a solution-level platform set to, for example, x64, and have no projects within that
solution targeting the same platform. It is also possible to have multiple projects in your solution, each
targeting different platforms. It is recommended that if you have one of these situations, you create a new
configuration with a descriptive name to avoid confusion.

See Also
How to: Create and Edit Configurations Understanding Build Configurations Building and Cleaning Projects and
Solutions in Visual Studio
How to: Specify Build Events (Visual Basic)
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Build events in Visual Basic can be used to run scripts, macros, or other actions as a part of the compilation
process. Pre-build events occur before compilation; post-build events occur after compilation.
Build events are specified in the Build Events dialog box, available from the Compile page of the Project
Designer .

NOTE
Visual Basic Express does not support entry of build events. This is supported only in the full Visual Studio product.

How to Specify Pre-Build and Post-Build Events


To specify a build event
1. With a project selected in Solution Explorer , on the Project menu, click Proper ties .
2. Click the Compile tab.
3. Click the Build Events button to open the Build Events dialog box.
4. Enter the command-line arguments for your pre-build or post-build action, and then click OK .

NOTE
Add a call statement before all post-build commands that run .bat files. For example, call C:\MyFile.bat or
call C:\MyFile.bat call C:\MyFile2.bat .

NOTE
If your pre-build or post-build event does not complete successfully, you can terminate the build by having your
event action exit with a code other than zero (0), which indicates a successful action.

Example: How to Change Manifest Information Using a Post-Build


Event
The following procedure shows how to set the minimum operating system version in the application manifest
using an .exe command called from a post-build event (the .exe.manifest file in the project directory). The
minimum operating system version is a four-part number such as 4.10.0.0. To do this, the command will change
the <dependentOS> section of the manifest:
<dependentOS>
<osVersionInfo>
<os majorVersion="4" minorVersion="10" buildNumber="0" servicePackMajor="0" />
</osVersionInfo>
</dependentOS>

To create an .exe command to change the application manifest


1. Create a console application for the command. From the File menu, click New , and then click Project .
2. In the New Project dialog box, in the Visual Basic node, select Windows and then the Console
Application template. Name the project ChangeOSVersionVB .
3. In Module1.vb, add the following line to the other Imports statements at the top of the file:

Imports System.Xml

4. Add the following code in Sub Main :

Sub Main()
Dim applicationManifestPath As String
applicationManifestPath = My.Application.CommandLineArgs(0)
Console.WriteLine("Application Manifest Path: " & applicationManifestPath.ToString)

'Get version name


Dim osVersion As Version
If My.Application.CommandLineArgs.Count >= 2 Then
osVersion = New Version(My.Application.CommandLineArgs(1).ToString)
Else
Throw New ArgumentException("OS Version not specified.")
End If
Console.WriteLine("Desired OS Version: " & osVersion.ToString())

Dim document As XmlDocument


Dim namespaceManager As XmlNamespaceManager
namespaceManager = New XmlNamespaceManager(New NameTable())
With namespaceManager
.AddNamespace("asmv1", "urn:schemas-microsoft-com:asm.v1")
.AddNamespace("asmv2", "urn:schemas-microsoft-com:asm.v2")
End With

document = New XmlDocument()


document.Load(applicationManifestPath)

Dim baseXPath As String


baseXPath = "/asmv1:assembly/asmv2:dependency/asmv2:dependentOS/asmv2:osVersionInfo/asmv2:os"

'Change minimum required OS Version.


Dim node As XmlNode
node = document.SelectSingleNode(baseXPath, namespaceManager)
node.Attributes("majorVersion").Value = osVersion.Major.ToString()
node.Attributes("minorVersion").Value = osVersion.Minor.ToString()
node.Attributes("buildNumber").Value = osVersion.Build.ToString()
node.Attributes("servicePackMajor").Value = osVersion.Revision.ToString()

document.Save(applicationManifestPath)
End Sub

The command takes two arguments. The first argument is the path to the application manifest (that is, the
folder in which the build process creates the manifest, typically Projectname.publish). The second argument
is the new operating system version.
5. On the Build menu, click Build Solution .
6. Copy the .exe file to a directory such as C:\TEMP\ChangeOSVersionVB.exe .
Next, invoke this command in a post-build event to change the application manifest.
To invoke a post-build event to change the application manifest
1. Create a Windows application for the project to be published. From the File menu, click New , and then
click Project .
2. In the New Project dialog box, in the Visual Basic node, select Windows and then the Windows
Application template. Name the project VBWinApp .
3. With the project selected in Solution Explorer , on the Project menu, click Proper ties .
4. In the Project Designer, go to the Publish page and set Publishing location to C:\TEMP\ .
5. Publish the project by clicking Publish Now .
The manifest file will be built and put in C:\TEMP\VBWinApp_1_0_0_0\VBWinApp.exe.manifest . To view the
manifest, right-click the file and click Open with , then click Select the program from a list , and then
click Notepad .
Search in the file for the <osVersionInfo> element. For example, the version might be:

<os majorVersion="4" minorVersion="10" buildNumber="0" servicePackMajor="0" />

6. In the Project Designer, go to the Compile tab and click the Build Events button to open the Build Events
dialog box.
7. In the Post-build Event Command Line box, enter the following command:
C:\TEMP\ChangeOSVersionVB.exe "$(TargetPath).manifest" 5.1.2600.0

When you build the project, this command will change the minimum operating system version in the
application manifest to 5.1.2600.0.
The $(TargetPath) macro expresses the full path for the executable being created. Therefore,
$(TargetPath).manifest will specify the application manifest created in the bin directory. Publishing will copy
this manifest to the publishing location that you set earlier.
8. Publish the project again. Go to the Publish page and click Publish Now .
View the manifest again. To view the manifest, go to the publish directory, right-click the file and click Open
with and then Select the program from a list , and then click Notepad .
The version should now read:

<os majorVersion="5" minorVersion="1" buildNumber="2600" servicePackMajor="0" />

See Also
Managing Compilation Properties Compile Page, Project Designer (Visual Basic) Publish Page, Project Designer
Pre-build Event/Post-build Event Command Line Dialog Box How to: Specify Build Events (C#)
How to: Specify Build Events (C#)
10/18/2019 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use build events to specify commands that run before the build starts or after the build finishes. Build events are
executed only if the build successfully reaches those points in the build process.
When a project is built, pre-build events are added to a file that is named PreBuildEvent.bat and post-build events
are added to a file that is named PostBuildEvent.bat. If you want to ensure error checking, add your own error-
checking commands to the build steps.

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the
following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For
more information, see Personalizing the IDE.

How to Specify Pre-Build and Post-Build Events


To specify a build event
1. In Solution Explorer , select the project for which you want to specify the build event.
2. On the Project menu, click Proper ties .
3. Select the Build Events tab.
4. In the Pre-build event command line box, specify the syntax of the build event.

NOTE
Pre-build events do not run if the project is up to date and no build is triggered.

5. In the Post-build event command line box, specify the syntax of the build event.

NOTE
Add a call statement before all post-build commands that run .bat files. For example, call C:\MyFile.bat or
call C:\MyFile.bat call C:\MyFile2.bat .

6. In the Run the post-build event box, specify under what conditions to run the post-build event.

NOTE
To add lengthy syntax, or to select any build macros from the Pre-build Event/Post-build Event Command Line
Dialog Box, click the Ellipsis button (… ) to display an edit box.
The build event syntax can include any command that is valid at a command prompt or in a .bat file. The
name of a batch file should be preceded by call to ensure that all subsequent commands are executed.
Note If your pre-build or post-build event does not complete successfully, you can terminate the build by
having your event action exit with a code other than zero (0), which indicates a successful action.

Example: How to Change Manifest Information by Using a Post-Build


Event
The following procedure shows how to set the minimum operating system version in the application manifest by
using an .exe command that is called from a post-build event (the .exe.manifest file in the project directory). The
minimum operating system version is a four-part number such as 4.10.0.0. To do this, the command will change
the <dependentOS> section of the manifest:

<dependentOS>
<osVersionInfo>
<os majorVersion="4" minorVersion="10" buildNumber="0" servicePackMajor="0" />
</osVersionInfo>
</dependentOS>

To create an .exe command to change the application manifest


1. Create a console application for the command. From the File menu, point to New , and then click Project .
2. In the New Project dialog box, expand Visual C# , click Windows , and then click the Console
Application template. Name the project ChangeOSVersionCS .
3. In Program.cs, add the following line to the other using statements at the top of the file:

using System.Xml;

4. In the ChangeOSVersionCS namespace, replace the Program class implementation with the following code:
class Program
{
/// <summary>
/// This function will set the minimum operating system version for a ClickOnce application.
/// </summary>
/// <param name="args">
/// Command Line Arguments:
/// 0 - Path to application manifest (.exe.manifest).
/// 1 - Version of OS
///</param>
static void Main(string[] args)
{
string applicationManifestPath = args[0];
Console.WriteLine("Application Manifest Path: " + applicationManifestPath);

// Get version name.


Version osVersion = null;
if (args.Length >=2 ){
osVersion = new Version(args[1]);
}else{
throw new ArgumentException("OS Version not specified.");
}
Console.WriteLine("Desired OS Version: " + osVersion.ToString());

XmlDocument document;
XmlNamespaceManager namespaceManager;
namespaceManager = new XmlNamespaceManager(new NameTable());
namespaceManager.AddNamespace("asmv1", "urn:schemas-microsoft-com:asm.v1");
namespaceManager.AddNamespace("asmv2", "urn:schemas-microsoft-com:asm.v2");

document = new XmlDocument();


document.Load(applicationManifestPath);

string baseXPath;
baseXPath = "/asmv1:assembly/asmv2:dependency/asmv2:dependentOS/asmv2:osVersionInfo/asmv2:os";

// Change minimum required operating system version.


XmlNode node;
node = document.SelectSingleNode(baseXPath, namespaceManager);
node.Attributes["majorVersion"].Value = osVersion.Major.ToString();
node.Attributes["minorVersion"].Value = osVersion.Minor.ToString();
node.Attributes["buildNumber"].Value = osVersion.Build.ToString();
node.Attributes["servicePackMajor"].Value = osVersion.Revision.ToString();

document.Save(applicationManifestPath);
}
}

The command takes two arguments: the path of the application manifest (that is, the folder in which the
build process creates the manifest, typically Projectname.publish), and the new operating system version.
5. Build the project. On the Build menu, click Build Solution .
6. Copy the .exe file to a directory such as C:\TEMP\ChangeOSVersionVB.exe .
Next, invoke this command in a post-build event to modify the application manifest.
To invoke a post-build event to modify the application manifest
1. Create a Windows application for the project to be published. From the File menu, point to New , and then
click Project .
2. In the New Project dialog box, expand Visual C# , click Windows , and then click the Windows Forms
Application template. Name the project CSWinApp .
3. With the project selected in Solution Explorer , on the Project menu, click Proper ties .
4. In the Project Designer, locate the Publish page and set Publishing location to C:\TEMP\ .
5. Publish the project by clicking Publish Now .
The manifest file will be built and put in C:\TEMP\CSWinApp_1_0_0_0\CSWinApp.exe.manifest . To view the
manifest, right-click the file, click Open with , select Select the program from a list , and then click
Notepad .
Search in the file for the <osVersionInfo> element. For example, the version might be:

<os majorVersion="4" minorVersion="10" buildNumber="0" servicePackMajor="0" />

6. In the Project Designer, click the Build Events tab and click the Edit Post-build button.
7. In the Post-build Event Command Line box, type the following command:
C:\TEMP\ChangeOSVersionCS.exe "$(TargetPath).manifest" 5.1.2600.0

When you build the project, this command will change the minimum operating system version in the
application manifest to 5.1.2600.0.
Because the $(TargetPath) macro expresses the full path for the executable being created, the
$(TargetPath) .manifest will specify the application manifest created in the bin directory. Publishing will
copy this manifest to the publishing location that you set earlier.
8. Publish the project again. Go to the Publish page and click Publish Now .
View the manifest again. To view the manifest, open the publish directory, right-click the file, click Open
with , select Select the program from a list , and then click Notepad .
The version should now read:

<os majorVersion="5" minorVersion="1" buildNumber="2600" servicePackMajor="0" />

See Also
Build Events Page, Project Designer (C#) Pre-build Event/Post-build Event Command Line Dialog Box How to:
Specify Build Events (Visual Basic) Compiling and Building
Configuring Warnings in Visual Basic
10/18/2019 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Visual Basic compiler includes a set of warnings about code that may cause run-time errors. You can use that
information to write cleaner, faster, better code with fewer bugs. For example, the compiler will produce a warning
when the user attempts to invoke a member of an unassigned object variable, return from a function without
setting the return value, or execute a Try block with errors in the logic to catch exceptions.
Sometimes the compiler provides extra logic on the user's behalf so that the user can focus on the task at hand,
rather than on anticipating possible errors. In previous versions of Visual Basic, Option Strict was used to limit
the additional logic that the Visual Basic compiler provides. Configuring warnings allows you to limit this logic in a
more granular way, at the level of the individual warnings.
You may want to customize your project and turn off some warnings not pertinent to your application while
turning other warnings into errors. This page explains how to turn individual warnings on and off.

Turning Warnings Off and On


There are two different ways to configure warnings: you can configure them using the Project Designer , or you
can use the /warnaserror and /nowarn compiler options.
The Compile tab of the Project Designer page allows you to turn warnings on and off. Select the Disable All
Warnings check box to disable all warnings; select the Treat All Warnings as Errors to treat all warnings as
errors. Some individual warnings can be toggled as error or warning as desired in the displayed table.
When Option Strict is set to Off , Option Strict related warnings cannot be treated independently of each other.
When Option Strict is set to On , the associated warnings are treated as errors, no matter what their status is.
When Option Strict is set to Custom by specifying /optionstrict:custom in the command line compiler, Option
Strict warnings can be toggled on or off independently.
The /warnaserror command-line option of the compiler can also be used to specify whether warnings are treated
as errors. You can add a comma delimited list to this option to specify which warnings should be treated as errors
or warnings by using + or -. The following table details the possible options.

C O M M A N D- L IN E O P T IO N SP EC IF IES

/warnaserror+ Treat all warnings as errors

/warnsaserror - Do not treat as warnings as errors. This is the default.

/warnaserror+:<warning list > Treat specific warnings as errors, listed by their error ID
number in a comma delimited list r.

/warnaserror-:<warning list> Do not treat specific warnings as errors, listed by their error ID
number in a comma delimited list.
C O M M A N D- L IN E O P T IO N SP EC IF IES

/nowarn Do not report warnings.

/nowarn:<warning list> Do not report specified warnings, listed by their error ID


number in a comma delimited list.

The warning list contains the error ID numbers of the warnings that should be treated as errors, which can be used
with the command-line options to turn specific warnings on or off. If the warning list contains an invalid number,
an error is reported.

Examples
This table of examples of command line arguments describes what each argument does.

A RGUM EN T DESC RIP T IO N

vbc /warnaserror Specifies that all warnings should be treated as errors.

vbc /warnaserror:42024 Specifies that warning 42024 should be treated as an error.

vbc /warnaserror:42024,42025 Specifies that warnings 42024 and 42025 should be treated
as errors.

vbc /nowarn Specifies that no warnings should be reported.

vbc /nowarn:42024 Specifies that warning 42024 should not be reported.

vbc /nowarn:42024,42025 Specifies that warnings 42024 and 42025 should not be
reported.

Types of Warnings
Following is a list of warnings that you might want to treat as errors.
Implicit Conversion Warning
Generated for instances of implicit conversion. They do not include implicit conversions from an intrinsic numeric
type to a string when using the & operator. Default for new projects is off.
ID: 42016
Late bound Method Invocation and Overload Resolution Warning
Generated for instances of late binding. Default for new projects is off.
ID: 42017
Operands of Type Object Warnings
Generated when operands of type Object occur that would create an error with Option Strict On . Default for
new projects is on.
ID: 42018 and 42019
Declarations Require 'As' Clause Warnings
Generated when a variable, function, or property declaration lacking an As clause would have created an error
with Option Strict On . Variables that do not have a type assigned to them are assumed to be type Object .
Default for new projects is on.
ID: 42020 (variable declaration), 42021 (function declaration), and 42022 (property declaration).
Possible Null Reference Exception Warnings
Generated when a variable is used before it has been assigned a value. Default for new projects is on.
ID: 42104, 42030
Unused Local Variable Warning
Generated when a local variable is declared but never referred to. Default is on.
ID: 42024
Access of Shared member through Instance Variable Warning
Generated when accessing a shared member through an instance may have side effects, or when accessing a
shared member through an instance variable is not the right-hand side of an expression or is being passed in as a
parameter. Default for new projects is on.
ID: 42025
Recursive Operator or Property Access Warnings
Generated when the body of a routine uses the same operator or property it is defined in. Default for new projects
is on.
ID: 42004 (operator), 42026 (property)
Function or Operator without Return Value Warning
Generated when the function or operator does not have a return value specified. This includes omitting a Set to
the implicit local variable with the same name as the function. Default for new projects is on.
ID: 42105 (function), 42016 (operator)
Overloads Modifier Used in a Module Warning
Generated when Overloads is used in a Module . Default for new projects is on.
ID: 42028
Duplicate or Overlapping Catch Blocks Warnings
Generated when a Catch block is never reached due to its relation to other Catch blocks that have been defined.
Default for new projects is on.
ID: 42029, 42031

See Also
Exception Assistant Dialog Box Error Types Try...Catch...Finally Statement /nowarn /warnaserror (Visual Basic)
Compile Page, Project Designer (Visual Basic) Compiler Warnings That Are Off by Default
How to: Disable the Hosting Process
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Calls to certain APIs can be affected when the hosting process is enabled. In these cases, it is necessary to disable
the hosting process to return the correct results.
To disable the hosting process
1. Open an executable project in Visual Studio. Projects that do not produce executables (for example, class
library or service projects) do not have this option.
2. On the Project menu, click Proper ties .
3. Click the Debug tab.
4. Clear the Enable the Visual Studio hosting process check box.
When the hosting process is disabled, several debugging features are unavailable or experience decreased
performance. For more information, see Debugging and the Hosting Process.
In general, when the hosting process is disabled:
The time needed to begin debugging .NET Framework applications increases.
Design-time expression evaluation is unavailable.
Partial trust debugging is unavailable.

See Also
Debugging and the Hosting Process Hosting Process (vshost.exe) Builds During Application Development
Hosting Process (vshost.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The hosting process is a feature in Visual Studio that improves debugging performance, enables partial trust
debugging, and enables design time expression evaluation. The hosting process files contain vshost in the file
name and are placed in the output folder of your project. For more information, see Debugging and the Hosting
Process.

NOTE
Hosting process files (.vshost.exe) are for use by Visual Studio and should not be run directly or deployed with your
application.

Improved Debugging Performance


The hosting process creates an application domain and associates the debugger with the application. Performing
these tasks can introduce a noticeable delay between the time debugging is started and the time the application
begins running. The hosting process helps increase performance by creating the application domain and
associating the debugger in the background, and saving the application domain and debugger state between runs
of the application. For more information on application domains, see Application Domains.

Partial Trust Debugging


An application can be specified as a partial trust application in the Security page of the Project Designer .
Debugging a partial trust application requires special initialization of the application domain. This initialization is
handled by the hosting process.

Design-Time Expression Evaluation


Design-time expression evaluation enables you to test code from the Immediate window without having to run
the application. The hosting process executes this code during design time expression evaluation. For more
information, see Immediate Window.

See Also
Debugging and the Hosting Process How to: Disable the Hosting Process Immediate Window Application Domains
Walkthrough: Creating a Multiple-Computer Build
Environment
10/18/2019 • 12 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can create a build environment within your organization by installing Visual Studio on a host computer and
then copying various files and settings to another computer so that it can participate in builds. You don't have to
install Visual Studio on the other computer.
This document does not confer rights to redistribute the software externally or to provide build environments to
third parties.

Disclaimer

This document is provided on a “as-is” basis. While we have tested the steps outlined, we are not able to exhaustively test every
configuration. We will attempt to keep the document current with any additional information learned. Information and views
expressed in this document, including URL and other Internet website references, may change without notice. Microsoft makes no
warranties, express or implied, with respect to the information provided here. You bear the risk of using it.

This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You may copy
and use this document for your internal, reference purposes.

You have no obligation to give Microsoft any suggestions, comments or other feedback ("Feedback") relating to this document.
However, any Feedback you voluntarily provide may be used in Microsoft Products and related specifications or other
documentation (collectively, "Microsoft Offerings") which in turn may be relied upon by other third parties to develop their own
products. Accordingly, if you do give Microsoft Feedback on any version of this document or the Microsoft Offerings to which
they apply, you agree: (a) Microsoft may freely use, reproduce, license, distribute, and otherwise commercialize your Feedback in
any Microsoft Offering; (b) You also grant third parties, without charge, only those patent rights necessary to enable other
products to use or interface with any specific parts of a Microsoft Product that incorporate Your Feedback; and (c) You will not
give Microsoft any Feedback (i) that you have reason to believe is subject to any patent, copyright or other intellectual property
claim or right of any third party; or (ii) subject to license terms which seek to require any Microsoft Offering incorporating or
derived from such Feedback, or other Microsoft intellectual property, to be licensed to or otherwise shared with any third party.

This walkthrough has been validated against the following operating systems, by executing MSBuild on the
command line and by using Team Foundation Build.
Windows 8 (x86 and x64)
Windows 7 Ultimate
Windows Server 2008 R2 Standard
After you complete the steps in this walkthrough, you can use the multiple-computer environment to build
these kinds of apps:
C++ desktop apps that use the Windows 8 SDK
Visual Basic or C# desktop apps that target the .NET Framework 4.5
The multiple-computer environment can't be used to build these kinds of apps:
Windows 8.x Store apps. To build Windows 8.x Store apps, you must install Visual Studio on the build
computer.
Desktop apps that target the .NET Framework 4 or earlier. To build these kinds of apps, you must install
either Visual Studio or the .NET Reference Assemblies and Tools (from the Windows 7.1 SDK) on the build
computer.
This walkthrough is divided into these parts:
Installing software on the computers
Copying files from the host computer to the build computer
Creating registry settings
Setting environment variables on the build computer
Installing MSBuild assemblies to the Global Assembly Cache (GAC) on the build computer
Building projects
Creating the build environment so that it can be checked into source control

Prerequisites
A licensed copy of Visual Studio Ultimate, Visual Studio Premium, or Visual Studio Professional
A copy of the .NET Framework 4.5.1, which you can download from the Microsoft website.

Installing software on the computers


First, set up the host computer and then set up the build computer.
By installing Visual Studio on the host computer, you create the files and settings that you will copy to the build
computer later. You can install Visual Studio on an x86 or an x64 computer, but the architecture of the build
computer must match the architecture of the host computer.
To install software on the computers
1. On the host computer, install Visual Studio.
2. On the build computer, install the .NET Framework 4.5. To verify that it's installed, make sure that the value of
the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework
Setup\NDP\v4\Full@Version starts with "4.5".

Copying files from the host computer to the build computer


This section covers the copying of specific files, compilers, build tools, MSBuild assets, and registry settings from
the host computer to the build computer. These instructions assume that you've installed Visual Studio in the
default location on the host computer; if you installed in another location, adjust the steps accordingly.
On an x86 computer, the default location is C:\Program Files\Microsoft Visual Studio 11.0\
On an x64 computer, the default location is C:\Program Files (x86)\Microsoft Visual Studio 11.0\
Notice that the name of the Program Files folder depends on the operating system that's installed. On an x86
computer, the name is \Program Files\; on an x64 computer, the name is \Program Files (x86)\. Irrespective
of the system architecture, this walkthrough refers to the Program Files folder as %ProgramFiles%.
NOTE
On the build computer, all of the relevant files must be on the same drive; however, the drive letter for that drive can be
different than the drive letter for the drive where Visual Studio is installed on the host computer. In any case, you must
account for the location of files when you create registry entries as described later in this document.

To copy the Windows SDK files to the build computer


1. If you have only the Windows SDK for Windows 8 installed, copy these folders recursively from the host
computer to the build computer:
%ProgramFiles%\Windows Kits\8.0\bin\
%ProgramFiles%\Windows Kits\8.0\Catalogs\
%ProgramFiles%\Windows Kits\8.0\DesignTime\
%ProgramFiles%\Windows Kits\8.0\include\
%ProgramFiles%\Windows Kits\8.0\Lib\
%ProgramFiles%\Windows Kits\8.0\Redist\
%ProgramFiles%\Windows Kits\8.0\References\
If you also have these other Windows 8 kits...
Microsoft Windows Assessment and Deployment Kit
Microsoft Windows Driver Kit
Microsoft Windows Hardware Certification Kit
...they might have installed files into the %ProgramFiles%\Windows Kits\8.0\ folders that are listed in
the previous step, and their license terms might not allow build-server rights for those files. Check the
license terms for every installed Windows kit to verify whether files may be copied to your build
computer. If the license terms don't allow build-server rights, then remove the files from the build
computer.
2. Copy the following folders recursively from the host computer to the build computer:
%ProgramFiles%\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\
%ProgramFiles%\Common Files\Merge Modules\
%ProgramFiles%\Microsoft Visual Studio 11.0\VC\
%ProgramFiles%\Microsoft Visual Studio 11.0\Common7\Tools\ProjectComponents\
%ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\V110\
%ProgramFiles%\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\
%ProgramFiles%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\
3. Copy these files from the host computer to the build computer:
%ProgramFiles%\Microsoft Visual Studio 11.0\Common7\IDE\msobj110.dll
%ProgramFiles%\Microsoft Visual Studio 11.0\Common7\IDE\mspdb110.dll
%ProgramFiles%\Microsoft Visual Studio 11.0\Common7\IDE\mspdbcore.dll
%ProgramFiles%\Microsoft Visual Studio 11.0\Common7\IDE\mspdbsrv.exe
%ProgramFiles%\Microsoft Visual Studio 11.0\Common7\IDE\msvcdis110.dll
%ProgramFiles%\Microsoft Visual Studio 11.0\Common7\Tools\makehm.exe
%ProgramFiles%\Microsoft Visual Studio 11.0\Common7\Tools\VCVarsQueryRegistry.bat
%ProgramFiles%\Microsoft Visual Studio 11.0\Common7\Tools\vsvars32.bat
4. The following Visual C++ runtime libraries are required only if you run build outputs on the build computer
—for example, as part of automated testing. The files are typically located in subfolders under the
%ProgramFiles%\Microsoft Visual Studio 11.0\VC\redist\x86\ or %ProgramFiles%\Microsoft Visual Studio
11.0\VC\redist\x64\ folder, depending on the system architecture. On x86 systems, copy the x86 binaries to
the \Windows\System32\ folder. On x64 systems, copy the x86 binaries to the Windows\SysWOW64\ folder,
and the x64 binaries to the Windows\System32\ folder.
\Microsoft.VC110.ATL\atl110.dll
\Microsoft.VC110.CRT\msvcp110.dll
\Microsoft.VC110.CRT\msvcr110.dll
\Microsoft.VC110.CXXAMP\vcamp110.dll
\Microsoft.VC110.MFC\mfc110.dll
\Microsoft.VC110.MFC\mfc110u.dll
\Microsoft.VC110.MFC\mfcm110.dll
\Microsoft.VC110.MFC\mfcm110u.dll
\Microsoft.VC110.MFCLOC\mfc110chs.dll
\Microsoft.VC110.MFCLOC\mfc110cht.dll
\Microsoft.VC110.MFCLOC\mfc110deu.dll
\Microsoft.VC110.MFCLOC\mfc110enu.dll
\Microsoft.VC110.MFCLOC\mfc110esn.dll
\Microsoft.VC110.MFCLOC\mfc110fra.dll
\Microsoft.VC110.MFCLOC\mfc110ita.dll
\Microsoft.VC110.MFCLOC\mfc110jpn.dll
\Microsoft.VC110.MFCLOC\mfc110kor.dll
\Microsoft.VC110.MFCLOC\mfc110rus.dll
\Microsoft.VC110.OPENMP\vcomp110.dll
5. Copy only the following files from the \Debug_NonRedist\x86\ or \Debug_NonRedist\x64\ folder to the
build computer, as described in Preparing a Test Machine To Run a Debug Executable. No other files may be
copied.
\Microsoft.VC110.DebugCRT\msvcp110d.dll
\Microsoft.VC110.DebugCRT\msvcr110d.dll
\Microsoft.VC110.DebugCXXAMP\vcamp110d.dll
\Microsoft.VC110.DebugMFC\mfc110d.dll
\Microsoft.VC110.DebugMFC\mfc110ud.dll
\Microsoft.VC110.DebugMFC\mfcm110d.dll
\Microsoft.VC110.DebugMFC\mfcm110ud.dll
\Microsoft.VC110.DebugOpenMP\vcomp110d.dll

Creating registry settings


You must create registry entries to configure settings for MSBuild.
To create registry settings
1. Identify the parent folder for registry entries. All of the registry entries are created under the same parent
key. On an x86 computer, the parent key is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\. On an x64
computer the parent key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\. Irrespective of
the system architecture, this walkthrough refers to the parent key as %RegistryRoot%.

NOTE
If the architecture of your host computer differs from that of your build computer, make sure to use the appropriate
parent key on each computer. This is especially important if you're automating the export process.
Also, if you're using a different drive letter on the build computer than the one that you're using on the host
computer, make sure to change the values of the registry entries to match.

2. Create the following registry entries on the build computer. All of these entries are strings (Type ==
“REG_SZ” in the registry). Set the values of these entries the same as the values of the comparable entries on
the host computer.
%RegistryRoot%\.NETFramework\v4.0.30319\AssemblyFoldersEx\VCMSBuild Public
Assemblies@(Default)
%RegistryRoot%\Microsoft SDKs\Windows\v8.0@InstallationFolder
%RegistryRoot%\Microsoft SDKs\Windows\v8.0A@InstallationFolder
%RegistryRoot%\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools@InstallationFolder
%RegistryRoot%\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools-x86@InstallationFolder
%RegistryRoot%\VisualStudio\11.0@Source Directories
%RegistryRoot%\VisualStudio\11.0\Setup\VC@ProductDir
%RegistryRoot%\VisualStudio\SxS\VC7@FrameworkDir32
%RegistryRoot%\VisualStudio\SxS\VC7@FrameworkDir64
%RegistryRoot%\VisualStudio\SxS\VC7@FrameworkVer32
%RegistryRoot%\VisualStudio\SxS\VC7@FrameworkVer64
%RegistryRoot%\VisualStudio\SxS\[email protected]
%RegistryRoot%\VisualStudio\SxS\[email protected]
%RegistryRoot%\Windows Kits\Installed Roots@KitsRoot
%RegistryRoot%\MSBuild\ToolsVersions\4.0\11.0@VCTargetsPath
%RegistryRoot%\MSBuild\ToolsVersions\4.0\11.0@VCTargetsPath10
%RegistryRoot%\MSBuild\ToolsVersions\4.0\11.0@VCTargetsPath11
On an x64 build computer, also create the following registry entry and refer to the host computer to
determine how to set it.
%RegistryRoot%\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools-x64@InstallationFolder
If your build computer is x64 and you want to use the 64-bit version of MSBuild, or if you're using
Team Foundation Server Build Service on an x64 computer, you must create the following registry
entries in the native 64-bit registry. Refer to the host computer to determine how to set these entries.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\11.0\Setup\VS@ProductDir
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0\11.0@VCTargetsPath
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0\11.0@VCTargetsPath10
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0\11.0@VCTargetsPath11

Setting environment variables on the build computer


To use MSBuild on the build computer, you must set the PATH environment variables. You can use vcvarsall.bat to
set the variables, or you can manually configure them.
To use vcvarsall.bat to set environment variables
Open a Command Prompt window on the build computer and run %Program Files%\Microsoft Visual Studio
11.0\VC\vcvarsall.bat. You can use a command-line argument to specify the toolset you want to use—x86,
native x64, or x64 cross-compiler. If you don't specify a command-line argument, the x86 toolset is used.
This table describes the supported arguments for vcvarsall.bat:

VC VA RSA L L . B AT B UIL D C O M P UT ER B UIL D O UT P UT


A RGUM EN T C O M P IL ER A RC H IT EC T URE A RC H IT EC T URE

x86 (default) 32-bit Native x86, x64 x86

x86_amd64 x64 Cross x86, x64 x64

amd64 x64 Native x64 x64

If vcvarsall.bat runs successfully—that is, no error message is displayed—you can skip the next step and
continue at the Installing MSBuild assemblies to the Global Assembly Cache (GAC) on the build computer
section of this document.
To manually set environment variables
1. To manually configure the command-line environment, add this path to the PATH environment variable:
%Program Files%\Microsoft Visual Studio 11.0\Common7\IDE
2. Optionally, you can also add the following paths to the PATH variable to make it easier to use MSBuild to
build your solutions.
If you want to use the native 32-bit MSBuild, add these paths to the PATH variable:
%Program Files%\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools
%windir%\Microsoft.NET\Framework\v4.0.30319
If you want to use the native 64-bit MSBuild, add these paths to the PATH variable:
%Program Files%\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\x64
%windir%\Microsoft.NET\Framework64\v4.0.30319

Installing MSBuild assemblies to the Global Assembly Cache (GAC) on


the build computer
MSBuild requires some additional assemblies to be installed to the GAC on the build computer.
To copy assemblies from the host computer and install them on the build computer
1. Copy the following assemblies from the host computer to the build computer. Because they will be installed
to the GAC, it doesn’t matter where you put them on the build computer.
%ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\v110\Microsoft.Build.CPPTasks.Common.v110.dll
%ProgramFiles%\Microsoft Visual Studio
11.0\Common7\IDE\CommonExtensions\Microsoft\VC\Project\Microsoft.VisualStudio.Project.VisualC
.VCProjectEngine.dll
%ProgramFiles%\Microsoft Visual Studio
11.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.VCProjectEngine.dll
2. To install the assemblies to the GAC, locate gacutil.exe on the build computer—typically, it's in
%ProgramFiles%\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\. If you can't locate this folder, repeat
the steps in the Copying files from the host computer to the build computer section of this walkthrough.
Open a Command Prompt window that has administrative rights and run this command for each file:
gacutil -i <file>

NOTE
A reboot may be required for an assembly to fully install into the GAC.

Building projects
You can use Team Foundation Build to build Visual Studio 2012 projects and solutions, or you can build them on the
command line. When you use Team Foundation Build to build projects, it invokes the MSBuild executable that
corresponds to the system architecture. On the command line, you can use either 32-bit MSBuild or 64-bit MSBuild,
and you can choose the architecture of MSBuild by setting the PATH environment variable or by directly invoking
the architecture-specific MSBuild executable.
To use msbuild.exe at the command prompt, run the following command, in which solution.sln is a placeholder for
the name of your solution.
msbuild solution.sln
For more information about how to use MSBuild on the command line, see Command-Line Reference.

NOTE
To build Visual Studio 2012 projects, you must use the "v110" Platform Toolset. If you don't want to edit the Visual Studio
2012 project files, you can set the Platform Toolset by using this command-line argument:
msbuild solution.sln /p:PlatformToolset=v110

Creating the build environment so that it can be checked into source


control
You can create a build environment that can be deployed to various computers and doesn’t require GAC’ing files or
modifying registry settings. The following steps are just one way to accomplish this. Adapt these steps to the
unique characteristics of your build environment.

NOTE
You must disable incremental building so that tracker.exe will not throw an error during a build. To disable incremental
building, set this build parameter:
msbuild solution.sln /p:TrackFileAccess=false

To create a build environment that can be checked into source control


1. Create a "Depot" directory on the host computer.
These steps refer to the directory as %Depot%.
2. Copy the directories and files as described in the Copying files from the host computer to the build
computer section of this walkthrough, except paste them under the %Depot% directory that you just created.
For example, copy from %ProgramFiles%\Windows Kits\8.0\bin\ to %Depot%\Windows Kits\8.0\bin\.
3. When the files are pasted in %Depot%, make these changes:
In %Depot%\MSBuild\Microsoft.Cpp\v4.0\v110\Microsoft.CPP.Targets,
\Microsoft.Cpp.InvalidPlatforms.targets\, \Microsoft.cppbuild.targets\, and
\Microsoft.CppCommon.targets\, change every instance of
AssemblyName="Microsoft.Build.CppTasks.Common.v110, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
to
AssemblyFile="$(VCTargetsPath11)Microsoft.Build.CppTasks.Common.v110.dll”.
The former naming relies on the assembly being GAC’ed.
In %Depot% \MSBuild\Microsoft.Cpp\v4.0\v110\Microsoft.CPPClean.Targets, change every instance
of
AssemblyName="Microsoft.Build.CppTasks.Common.v110, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
to
AssemblyFile="$(VCTargetsPath11)Microsoft.Build.CppTasks.Common.v110.dll”.
4. Create a .props file—for example, Partner.AutoImports.props—and put it at the root of the folder that
contains your projects. This file is used to set variables that are used by MSBuild to find various resources. If
the variables are not set by this file, they are set by other .props files and .targets files that rely on registry
values. Because we aren’t setting any registry values, these variables would be empty and the build would
fail. Instead, add this to Partner.AutoImports.props:
<?xml version="1.0" encoding="utf-8"?>
<!-- This file must be imported by all project files at the top of the project file. -->
<Project ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VCTargetsPath>$(DepotRoot)MSBuild\Microsoft.Cpp\v4.0\v110\</VCTargetsPath>
<VCTargetsPath11>$(DepotRoot)MSBuild\Microsoft.Cpp\v4.0\v110\</VCTargetsPath11>
<MSBuildExtensionsPath>$(DepotRoot)MSBuild</MSBuildExtensionsPath>
<MSBuildExtensionsPath32>$(DepotRoot)MSBuild</MSBuildExtensionsPath32>
<VCInstallDir_110>$(DepotRoot)Microsoft Visual Studio 11.0\VC\</VCInstallDir_110>
<VCInstallDir>$(VCInstallDir_110)</VCInstallDir>
<WindowsKitRoot>$(DepotRoot)Windows Kits\</WindowsKitRoot>
<WindowsSDK80Path>$(WindowsKitRoot)</WindowsSDK80Path>
<WindowsSdkDir_80>$(WindowsKitRoot)8.0\</WindowsSdkDir_80>
<WindowsSdkDir>$(WindowsSDKDir_80)</WindowsSdkDir>
<WindowsSdkDir_80A>$(DepotRoot)Microsoft SDKs\Windows\v8.0A\</WindowsSdkDir_80A>
</PropertyGroup>
</Project>

5. In each of your project files, add the following line at the top, after the <Project Default Targets…> line.

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),
Partner.AutoImports.props))\Partner.AutoImports.props"/>

6. Change the command-line environment as follows:


Set Depot=location of the Depot directory that you created in step 1
Set path=%path%;location of MSBuild on the
computer;%Depot%\Windows\System32;%Depot%\Windows\SysWOW64;%Depot%\Microsoft
Visual Studio 11.0\Common7\IDE\
For native 64-bit building, point to the 64-bit MSBuild.

See Also
Preparing a Test Machine To Run a Debug Executable Command-Line Reference
Deploying Applications, Services, and Components
1/13/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

By deploying an application, service, or component, you distribute it for installation on other computers, devices,
servers, or in the cloud. You choose the appropriate method in Visual Studio for the type of deployment that you
need.
In the following table, you can find descriptions of different deployment scenarios and links to more information
about how you can successfully complete those scenarios.

In This Section
DEP LO Y M EN T SC EN A RIO SUP P O RT IN G C O N T EN T

Publish to the cloud: You can make applications, services, Publishing Applications to Microsoft Azure
and data available from anywhere by using Visual Studio to
deploy them to Microsoft Azure.

Publish a Windows Store app: You can easily build, Packaging, deployment, and query of Windows Store apps
submit, and sell your apps from the Windows Store to
customers around the world.

Publish a Windows Phone app: You can submit a new app Publish a Windows Phone App
or an update to an existing app for certification on the
Windows Phone Dev Center.

Deploy an ASP.NET application or ser vice: You can Deploying ASP.NET web applications and services
deploy ASP.NET applications and services in a number of
different ways.

Deploy a LightSwitch application or ser vice: After you Deploying LightSwitch Applications
create applications and OData services by using LightSwitch,
you can deploy them to a web server or to Microsoft Azure.

Publish an app for SharePoint: You can publish an app for Publish an app for SharePoint by using Visual Studio
SharePoint to the Office Store or to an app catalog for an
internal organization.

Publish an app for Office: You can publish an app for Publishing your app for Office
Office to the Office Store or to an app catalog for an internal
organization.

Deploy a WCF ser vice: Other applications can use WCF RIA Deploying WCF RIA Services Solutions
services that you deploy to a web server.
DEP LO Y M EN T SC EN A RIO SUP P O RT IN G C O N T EN T

Deploy an OData ser vice: Other applications can use Deploy an OData Service
OData services that you deploy to a web server.

Deploy a desktop application: By using ClickOnce ClickOnce Security and Deployment


deployment, you can publish a desktop application to a web
server or a network file share. Users can then install the
application with a single click.

Create a setup program: You can create a setup program InstallShield Limited Edition
by using InstallShield Limited Edition, which is free.

Maintain an existing setup program: Continue using a Visual Studio Installer Projects Extension
setup program created in an earlier version of Visual Studio by
installing the Visual Studio Installer Projects Extension. Documentation for installer projects is available here: Visual
Studio Installer Deployment

Deploy a Visual C++ application: You can deploy the Deploying Native Desktop Applications (Visual C++)
Visual C++ runtime with an application by using central
deployment, local deployment, or static linking.

Deploy an application for testing: You can enable more Test on a lab environment
sophisticated development and testing by deploying your
applications into virtual environments.

Install prerequisites: You can install prerequisite Application Deployment Prerequisites


components for desktop applications by configuring a generic
installer, which is known as a bootstrapper.
Visual Studio IDE 64-Bit Support
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Visual Studio enables you to set up your applications to target different platforms, including 64-bit platforms. For
more information on 64-bit platform support in Visual Studio, see 64-bit Applications.

Deploying a 64-bit application


The following topics discuss deploying 64-bit applications.
Deploying Prerequisites for 64-bit Applications
How to: Create a Windows Installer for a 64-bit Platform

Configuring projects as 64-bit applications


The following topics discuss configuring projects to be built to 64-bit applications.
How to: Configure Projects to Target Platforms

Debugging a 64-bit application


Edit and Continue does not work when Visual Studio 2005 is running on a 64-bit Windows operating system. The
following topics discuss debugging 64-bit applications.
How to: Debug on 64-bit Platforms
Debug 64-Bit Applications
Using Dump Files

See Also
How to: Configure Projects to Target Platforms
Visual Studio Samples
1/13/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can find Visual Studio samples on the MSDN Code Gallery website.
You can use the New Project dialog box to browse for samples. (To open the dialog box, on the menu bar, choose
File , New , Project .)

Finding Samples
Here are some other places to look for samples.

A REA DESC RIP T IO N

Windows Developer Center Samples Shows how to develop Windows 8.x Store apps.

.NET Framework Samples Shows various aspects of the .NET Framework in C# and Visual
Basic.

C# Samples Shows how to use different features of C#.

Visual Basic Samples Shows how to use different features of Visual Basic.

F# Samples Shows how to use different features of F#.

JavaScript Samples Shows how to use different features in JavaScript.

C++ Samples Shows how to use different features in C++.

DirectX Samples Shows how to use DirectX.

Office Development Samples Shows how to use Office development tools in Visual Studio.

VSSDK Samples Shows how to extend Visual Studio.

See Also
Getting Started with Visual C# and Visual Basic
User accounts and updates
10/16/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

WARNING
Visual Studio 2015 cannot access resources that are configured for conditional access. To work with those resources, upgrade
to Visual Studio 2019 version 16.6 or later and follow the How to use Visual Studio with accounts that require multi-factor
authentication guidance.

Visual Studio itself is a connected environment. By signing-in you enable access to all the services associated with
your user account as well as all the accounts that are linked to that account. Your account settings roam with you
wherever you use Visual Studio. You can configure permissions levels on a specific Visual Studio instance for
individual users. Also, Visual Studio informs you when any component of your installation, such as an SDK, had an
update available.

In this section
T IT L E DESC RIP T IO N

Signing in to Visual Studio Describes how and why to sign in to Visual Studio.

Work with multiple user accounts Describes how to associate multiple Microsoft accounts and/or
work or school accounts to enable access to resources and
services from all your accounts.

Synchronized Settings Describes how settings roam.

How to Unlock Visual Studio Describes how to unlock Visual Studio in various scenarios.

Notifications Describes how Visual Studio notifies you when components


such as SDKs, or Visual Studio itself, have an update available.

See also
Visual Studio IDE
Signing in to Visual Studio
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can personalize and optimize your development experience in Visual Studio if you set your Personalization
account by signing in to the IDE.

Why should I sign in to Visual Studio?


You gain the following benefits by signing in to Visual Studio:
Grants access to a broad range of benefits from the Visual Studio Dev Essentials program, including
free software, training, support, and more. See Visual Studio Dev Essentials for more information.
Synchronizes your Visual Studio settings – Settings that you customize, such as key bindings, window
layout and color theme, apply immediately when you sign in to Visual Studio on any device. See
Synchronized Settings in Visual Studio.
Permanently unlocks Visual Studio Express Edition – You can use any edition of Visual Studio Express
for as long as you like, instead of being limited to the trial period of 30 days.
Unlocks the Visual Studio Community Edition instead of being limited to the trial period of 30 days.
Extends the Visual Studio trial period – You can use Visual Studio Professional or Visual Studio
Enterprise for an additional 90 days, instead of being limited to the trial period of 30 days.
Unlocks Visual Studio if you use an account that's associated with an MSDN or VSO
subscription . See How to Unlock Visual Studio.
Automatically connects to ser vices such as Azure and Visual Studio Team Ser vices in the IDE
without prompting again for credentials for the same account.

How to sign in to Visual Studio


When you start Visual studio for the first time, you're asked to sign in and provide some basic registration
information. You should choose a Microsoft account or a work or school account that best represents you. If you
don't have any of these accounts, you can create a Microsoft account for free. See How do I sign up for a Microsoft
account?
Next, choose the UI settings and color theme that you want to use in Visual Studio. Visual Studio remembers these
settings and synchronizes them across all Visual Studio environments you have signed in to. For a list of the
settings that are synchronized, see Synchronized Settings. You can change the settings later if you open the Tools |
Options menu in Visual Studio.
After you provide the settings, Visual Studio starts, and you're signed in and ready to get started. To verify whether
you're signed in, look for your name in the upper-right corner of the Visual Studio environment.
Unless you sign out, you'll be automatically signed in to Visual Studio whenever you start it, and any changes to
synchronized settings are automatically applied. To sign out, choose the down arrow next to your profile name in
the Visual Studio environment, choose the Account settings command, and then choose the Sign out link. To
sign in again, choose the Sign in command in the upper-right corner of the Visual Studio environment.

To change your profile information


In File | Account Settings, you can see and update information about your Visual Studio profile and license. To
edit your profile information, such as your account name, avatar picture, or email address:
1. Go to File | Account Settings .
2. In the Account Settings dialog box, Manage Visual Studio profile link.
3. On the My Microsoft Information page in the browser, choose the Edit Information button.
4. Change the settings that you want.
5. When you're done, choose the Save changes button.
Work with multiple user accounts
1/13/2020 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

If you have multiple Microsoft accounts and/or work or school accounts, you can add them all to Visual Studio so
that you can access the resources from any account without having to sign in to it separately. As of the Visual
Studio 2015 RTM date, Azure, Application Insights, Team Foundation Server, and Office 365 services support the
streamlined sign-in experience. Additional services may become available as time goes by.
After you add multiple accounts on one machine, that set of accounts will roam with you if you sign in to Visual
Studio on another machine. It is important to note that, although the account names roam, the credentials do not.
Therefore, you will be prompted to enter credentials for those other accounts the first time you attempt to use their
resources on the new machine.
This walkthrough shows how to add multiple accounts to Visual Studio, and how to see that the resources
accessible from those accounts are reflected in places such as the Add Connected Ser vice dialog, Ser ver
Explorer , and Team Explorer .
Sign in to Visual Studio
1. Sign into Visual Studio 2015 with a Microsoft account or an organizational account. You should see your
user name reflected in the upper right corner of the window, similar to this:

Access your Azure account in Server Explorer


Press Ctrl + Alt + S to open Ser ver Explorer . Click on the Azure icon and when it expands you should see the
resources available in the Azure account that is associated with the ID that you used to log in to Visual Studio 2015.
It should look something like this, except that you see your own resources, not Mr. Guido’s:
The first time you use Visual Studio on any specific device, the dialog will only show the subscriptions registered
under the ID that you signed in to the IDE with. You can access resources for any of your other accounts directly
from Ser ver Explorer by right-clicking on the Azure node and choosing Manage and Filter Subscriptions and
adding your accounts from the account picker control. You can then choose another account, if desired, by clicking
the down arrow and choosing from the list of accounts. After choosing the account, you can choose which
subscriptions under that account you want to display in Server Explorer.

The next time you open Server Explorer, the resources for that subscription(s) are displayed.
Access your Azure account via Add Connected Service dialog
1. Create a Universal App project in C#.
2. Right click on the project node in Solution Explorer and choose Add > Connected Ser vice . The Add
Connected Service wizard appears and shows you the list of services in the Azure account that is associated
with your Visual Studio login ID. Note that you do not have to sign in separately to Azure. However, you do
need to sign in to the other accounts the first time you attempt to access their resources from a given
computer.

WARNING
If this is the first time you are creating a Store app in Visual Studio 2015 on a specific computer, you will be prompted
to enable your device for development mode by going to Settings | . Updates and Security | For Developers
on your computer. For more information, see Enable Your Device for Development.

Access Azure Active Directory in a Web project


Azure AD enables support for end-user single Sign-In in ASP.NET MVC web applications, or AD Authentication in
Web API services. Domain authentication is different from individual user account authentication; users that have
access to your Active Directory domain can use their existing Azure AD accounts to connect to your web
applications. Office 365 apps can also use domain authentication. To see this in action, create a web application
(File > New Project > C# > Cloud > ASP.NET Web Application ). In the New ASP.NET Project dialog choose
Change Authentication . The authentication wizard appears and enables you to choose what kind of
authentication to use in your application.
For more information about the different kinds of authentication in ASP.NET, see Creating ASP.NET Web Projects in
Visual Studio 2013 (the information about authentication is still relevant for Visual Studio 2015).
Access your Visual Studio Team Services account
From the main menu, choose Team > Connect to Team Foundation Ser ver to bring up the Team Explorer
window. Click on Select Team Projects , and then in the list box under Select a Team Foundation Ser ver , you
should see the URL for your Visual Studio Team Services account. When you select the URL you will be logged in
without having to re-enter your credentials.

Add a second user account to Visual Studio


Click on the down arrow next to your user name in the upper right corner of Visual Studio. Then click on the
Account Settings menu item. The Account Manager dialog appears and displays the account you signed in
with. Click the Add an account link in the lower left of the dialog to add a new Microsoft account or a new work
or school account.

Follow the prompts to enter the new account credentials. The following illustration shows the Account Manager
after a user has added his Contoso.com work account.
Revisit the Add Connected Services Wizard and Server Explorer
Now go to Ser ver Explorer again, right-click on the Azure node and choose Manage and filter subscriptions .
Choose the new account by clicking the drop down arrow next to the current account, and then choose which
subscriptions you want to display in Server Explorer. You should see all the services associated with the specified
subscription.Even though you are not currently signed in to the Visual Studio IDE with the second account, you are
signed in to that account's services and resources. The same is true for Project > Add Connected Ser vice and
Team > Connect to Team Foundation Ser ver .
How to Unlock Visual Studio
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can evaluate Visual Studio for free up to 30 days. When you sign into the IDE you can extend the trial period by
90 days. To continue using Visual Studio you can unlock the IDE by
1. using an online subscription.
2. entering a product key.

To Unlock Visual Studio using an online subscription


To unlock Visual Studio using an MSDN or Visual Studio online subscription associated with a Microsoft account, or
a work or school account:
1. Click on the “Sign in” button in the upper right corner of the IDE (or go to File > Account Settings to open
the Account Settings dialog and click on the “Sign in” button.)
2. Enter the credentials for either a Microsoft account or a work or school account. Visual Studio will find an
MSDN subscription or Visual Studio Team Services subscription associated with your account.

IMPORTANT
Visual Studio automatically looks for associated online subscriptions when you connect to a Visual Studio Team Services
account from the Team Explorer tool window. When you connect to a Visual Studio Team Services account, you can sign in
using both Microsoft and work or school accounts. If an online subscription exists for that user account, Visual Studio will
automatically unlock the IDE for you.

To unlock Visual Studio with a product key


1. Select File > Account Settings to open the Account Settings dialog and click on the “License with a
Product Key ” link.
2. Enter the product key in the space provided.

TIP
Prerelease versions of Visual Studio do not have product keys. You must sign in to the IDE to use prerelease versions.

Addressing License Problem States


Updating stale licenses
You may have seen the below message that your license is going stale in Visual Studio.
This message indicates that while your subscription may still be valid, the license token Visual Studio uses to keep
your subscription up to date hasn’t been refreshed and has gone stale due to one of the following reasons:
1. You have not used Visual Studio or have had no internet connection for an extend period of time.
2. You signed out of Visual Studio.
Before the license token goes stale, Visual Studio will first show a warning message asking you to re-enter
your credentials.
If you do not reenter your credentials the token starts to go stale. When this happens, the Account Settings
dialog tells you how many days you have left before your token will fully expire. After your token expires,
you will need to reenter your credentials for this account or license with another method above before you
can continue using Visual Studio.

IMPORTANT
If you are using Visual Studio for extended periods in environments with limited or no internet access, you should use a
product key to unlock Visual Studio in order to avoid interruption.

Updating Expired Licenses


If your subscription has expired completely, and you no longer have access rights to Visual Studio, you must:
1. Renew your subscription. To see more information about the license you are using, go to File > Account
Settings dialog, and look at the license information on the right side of the dialog.
2. If you have another subscription associated with a different account, add that account to the All Accounts list
on the left side of File > Account Settings dialog by clicking on the “Add an account…” link.

See Also
Signing in to Visual Studio
Visual Studio Notifications
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Visual Studio has a notification system which alerts you to various events:
1. An update is available for a component within Visual Studio
2. Visual Studio itself has an update available
3. There has been an environment event that you might be interested in
Visual Studio notifies you when an update is available for Visual Studio itself or for any of the components
that have been installed. It also provides notifications about certain kinds of events that occur in the Visual
Studio environment. The notification icon is a flag in the upper right of the Visual Studio title bar; when the
icon is red, it means that there is a problem with your license. When it’s yellow there is a Visual Studio
Product Update available for you to install. When it is “normal” or black you’ll see messages that are
informational or optional, such as crashes for which you might want to find a workaround. You can click on
the icon to open the Notifications Hub and choose which ones to act on. You can choose to do a one-time
dismiss on a notification or always ignore a notification (by hovering over it), and Visual Studio will never
show you that message again.
If you choose to always ignore a notification, Visual Studio will stop showing it. You can reset the list of
ignored notifications in the Notifications, Environment, Options Dialog Box.
See Also
Visual Studio IDE
Personalizing the Visual Studio IDE
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This section describes how to personalize Visual Studio in various ways to best support your own development
style and requirements. You can define and save multiple window layouts and switch between them. For
example, you can define a layout for coding and one for debugging. You can customize colors, fonts and
formatting in the code editor for each language. You can choose between the blue, dark or light environment
color themes, or you can create custom themes by downloading and installing the Visual Studio theme editor
from the Visual Studio Code Gallery. Many other options are also exposed through the Environment Options
Dialog Box.
Many of your settings roam with you across Visual Studio instances. See Synchronized Settings for more
information.
Window layouts
To arrange window positions and behavior, and save custom layouts, see Customizing window layouts.
General environment options
To customize many environment settings, type environment in QuickLaunch . When the property page appears,
you can press F1 for more help on the various settings on that page. See also Environment Options Dialog Box.
External tools
To customize which external tools appear in menus and toolbars, see Managing External Tools.
Start page
To create a custom start page for you and your team, see Customizing the Start Page
Environment color themes
To change the color theme between light, dark and blue, type environment in QuickLaunch and choose
Environment | General . To change colorization options in the editor, type environment in QuickLaunch and
choose Environment | Fonts and Colors . see also How to: Change Fonts and Colors.
Menus and toolbars
To add or remove menu or toolbar items, see How to: Customize Menus and Toolbars.
Main menu casing
Due to popular demand, you can change the main menu casing between Title Case and ALL CAPS by typing
environment in QuickLaunch and choosing Environment | General .

See Also
Visual Studio IDE
How to: Change Fonts and Colors in Visual Studio
11/21/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can customize the color of the IDE frame and tool windows in Visual Studio in several ways.

TIP
For information about how to change the colors of the code editor, see How to: Change Fonts and Colors in the Editor.

Change the Color Theme of the IDE


1. On the menu bar, choose Tools , Options .
2. In the options list, choose Environment , General .
3. In the Color theme list, choose either the default Blue theme, Dark or Light .

IMPORTANT
When you change a color theme, text in the IDE reverts to the default or previously customized fonts and sizes.
If you have Visual Studio Professional, Visual Studio Premium, or Visual Studio Ultimate, you can install additional
predefined color themes and create your own by downloading and installing the Visual Studio 2013 Color Theme
Editor.

Use Windows High Contrast Colors


Choose the Left Alt + Left Shift + Print Screen keys.

WARNING
This option sets high contrast for all applications and UI on the current computer.

Change IDE Fonts


You can change the font and text size for all windows and dialog boxes in the IDE. You can choose to customize
only certain windows and other text elements.
To change the font and size of all text in the IDE
1. On the menu bar, choose Tools , Options .
2. In the options list, choose Environment , Fonts and Colors .
3. In the Show settings for list, choose Environment Font .
TIP
If you want to change the font for tool windows only, in the Show settings for list, choose [All Text Tool
Windows] .

4. In the Font list, choose a font.


5. In the Size list, choose a text size, and then choose the OK button.

See Also
Accessibility Features of Visual Studio How to: Change Fonts and Colors in the Editor
How to: Customize Menus and Toolbars in Visual
Studio
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can customize Visual Studio not only by adding and removing toolbars and menus on the menu bar but also
by adding and removing commands on any given toolbar or menu.

WARNING
After you customize a toolbar or menu, make sure that its check box remains selected in the Customize dialog box.
Otherwise, your changes won't persist after you close and reopen Visual Studio.

In this topic:
Adding, removing, or moving a menu on the menu bar
Adding, removing, or moving a toolbar
Customizing a menu or a toolbar
Resetting a menu or a toolbar

Adding, removing, or moving a menu on the menu bar


1. On the menu bar, choose Tools , Customize .
The Customize dialog box opens.
2. On the Commands tab, leave the Menu bar option button selected, leave Menu Bar selected in the list
next to that option, and then perform one of the following sets of steps:
To add a menu, choose the Add New Menu button, choose the Modify Selection button, and then
name the menu that you want to add.
To remove a menu, choose it in the Controls list, and then choose the Delete button.
To move a menu within the menu bar, choose the menu in the Controls list, and then choose the
Move Up or Move Down button.

Adding, removing, or moving a toolbar


1. On the menu bar, choose Tools , Customize .
The Customize dialog box opens.
2. On the Toolbar tab, perform one of the following sets of steps:
To add a toolbar, choose the New button, specify a name for the toolbar that you want to add, and
then choose the OK button.

To remove a custom toolbar, choose it in the Toolbars list, and then choose the Delete button.

IMPORTANT
You can delete toolbars that you create but not default toolbars.
To move a toolbar to a different docking location, choose it in the Toolbars list, choose the Modify
Selection button, and then choose a location in the list that appears.
You can also drag a toolbar by its left edge to move it anywhere in the main docking area.

NOTE
For more information about how to improve the usability and accessibility of toolbars, see How to: Set IDE
Accessibility Options.

Customizing a menu or a toolbar


1. On the menu bar, choose Tools , Customize .
The Customize dialog box opens.
2. On the Commands tab, choose the option button for the type of element that you want to customize.
3. In the list for that type of element, choose the menu or toolbar that you want to customize, and then
perform one of the following sets of steps:
To add a command, choose the Add Command button.
In the Add Command dialog box, choose an item in the Categories list, choose an item in the
Commands list, and then choose the OK button.

To delete a command, choose it in the Controls list, and then choose the Delete button.
To reorder commands, choose a command in the Controls list, and then choose the Move Up or
Move Down button.
To separate commands into groups, choose a command in the Controls list, choose the Modify
Selection button, and then choose Begin a Group in the menu that appears.

Resetting a menu or a toolbar


1. On the menu bar, choose Tools , Customize .
The Customize dialog box opens.
2. On the Commands tab, choose the option button for the type of element that you want to reset.
3. In the list for that type of element, choose the menu or toolbar that you want to reset.
4. Choose the Modify Selection button, and then choose Reset in the menu that appears.
You can also reset all menus and toolbars by choosing the Reset All button.
Customizing window layouts in Visual Studio
10/18/2019 • 10 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In Visual Studio you can customize the position, size and behavior of windows to create window layouts that work
best for various development workflows. When you customize the layout, the IDE remembers it. For example, if
you change the docking location of Solution Explorer and then close Visual Studio, the next time that you start,
even if you are working on another computer, Solution Explorer will be docked in that same location. You can
also give a custom layout a name and save it, and then switch between layouts with a single command. For
example you could create a layout for editing, and another for debugging, and switch between them by using the
Window | Apply Window Layout menu command.

Kinds of Windows
Tool and Document Windows
The IDE has two basic window types, tool windows and document windows. Tool windows include Solution
Explorer, Server Explorer, Output Window, Error List, the designers, the debugger windows, and so on. Document
windows contain source code files, arbitrary text files, config files, and so on. Tool windows can be resized and
dragged by their title bar. Document windows can be dragged by their tab. Right-click on the tab or title bar to set
other options on the window.
The Window menu shows options for docking, floating and hiding windows in the IDE. Right click on a window
tab or title bar to see additional options for that specific window. You can display more than one instance of
certain tool windows at a time. For example, you can display more than one web browser window, and you can
create additional instances of some tool windows by choosing New Window on the Window menu.
Preview tab (document windows)
In the Preview tab, you can view files in the editor without opening them. You can preview files by choosing them
in Solution Explorer , during debugging when you step into files, with Go to Definition, and when you browse
through results of a search. Preview files appear in a tab on the right side of the document tab well. The file opens
for editing if you modify it or choose the Open .
Tab Groups
Tab Groups extend your ability to manage limited workspace while you are working with two or more open
documents in the IDE. You can organize multiple document windows and tool windows into either vertical or
horizontal Tab Groups and shuffle documents from one Tab Group to another.
Split Windows
When you have to view or edit two locations at once in a document, you can split windows. To divide your
document into two independently scrolling sections, click Split on the Window menu. Click Remove Split on
the Window menu to restore the single view.
Toolbars
Toolbars can be arranged by dragging, or by using the Customize dialog box. For more information about how
to position and customize toolbars, see How to: Customize Menus and Toolbars.
Arranging and Docking Windows
Both document windows and tool windows can be docked, so that it has a position and size within the IDE
window frame, or floating as a separate window independent of the IDE. Tool windows can be docked anywhere
inside the IDE frame; some tool windows can be docked as tabbed windows in the editor frame. Document
windows can be docked within the editor frame, and they can be pinned to their current position in the tab order.
You can dock multiple windows to float together in a “raft” over or outside of the IDE. Tool windows can also be
hidden or minimized.
You can arrange windows in the following ways:
Pin document windows to the left of the tab well.
Tab-dock windows to the editing frame.
Dock tool windows to the edge of a frame in the IDE.
Float document or tool windows over or outside the IDE.
Hide tool windows along the edge of the IDE.
Display windows on different monitors.
Reset window placement to the default layout or to a saved custom layout.
Tool and document windows can be arranged by dragging, by using commands on the Window menu,
and by right-clicking the title bar of the window to be arranged.

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the
following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For
more information, see Customizing Development Settings in Visual Studio.

Docking Windows
When you click and drag the title bar of a tool window, or the tab of document window, a guide diamond appears.
During the drag operation, when the mouse cursor is over one of the arrows in the diamond, a shaded area will
appear that shows you where the window will be docked if you release the mouse button now.
To move a dockable window without snapping it into place, choose the Ctrl key while you drag the window.
To return a tool window or document window to its most recent docked location, press CTRL while you double-
click the title bar or tab of the window.
The following illustration shows the guide diamond for document windows, which can only be docked within the
editing frame:

Tool windows can be fastened to one side of a frame in the IDE or within the editing frame. A guide diamond
appears when you drag a tool window to another location to help you to easily re-dock the window.
Guide diamond for tool windows
The following illustration shows Solution Explorer being docked in a new location, which is shown by the blue
shaded area:

Closing and auto -hiding tool windows


You can close a tool window by clicking the X in the upper right of the title bar; to reopen the window, use its
keyboard shortcut or menu command. Tool windows support a feature named Auto Hide, which causes a window
to slide out of the way when you use a different window. When a window is auto-hidden, its name appears on a
tab at the edge of the IDE. To use the window again, point to the tab so that the window slides back into view.

NOTE
To set whether Auto Hide operates on tool windows individually or as docked groups, select or clear Auto Hide button
affects active tool windows only in the Options dialog box. For more information, see General, Environment, Options
Dialog Box.
NOTE
Tool windows that have Auto Hide enabled may temporarily slide into view when the window has focus. To hide the window
again, select an item outside of the current window. When the window loses focus, it slides back out of view.

Specifying a Monitor
If you have a second monitor and your operating system supports it, you can choose which monitor displays a
window. You can even group multiple windows together in “rafts” on other monitors.

TIP
You can create multiple instances of Solution Explorer and move them to another monitor. Right-click the window and
choose New Solution Explorer View . You can return all windows back to the original monitor by double-clicking while
choosing the Ctrl key.

Reset, name, and switch between window layouts


You can return the IDE to the original window layout for your settings collection by using the Reset Window
Layout command. When you run this command, the following actions occur:
All windows are moved to their default positions.
Windows that are closed in the default window layout are closed.
Windows that are open in the default window layout are opened.
Create and save custom layouts
Visual Studio 2015 enables you to save up to 10 custom window layouts and quickly switch between them. The
following steps show how to create, save, invoke, and manage custom layouts that take advantage of multiple
monitors with both docked and floating tool windows.
First, create a test solution that has two projects, each with a different optimal layout.
C r e a t e a U I p r o j e c t a n d c u st o m i z e t h e l a y o u t

1. In the New Project dialog, create a Visual C# WPF Desktop Application and call it whatever you like.
Pretend that this is the project where we’ll be working on the user interface, so we want to maximize the
space for the designer window and move other tool windows out of the way.
2. If you have multiple monitors, pull the Solution Explorer window and the Proper ties window over to
your second monitor. On a single monitor system, try closing all the windows except the designer.
3. Press Ctrl + Alt + X to display the Toolbox. If the window is docked, drag it so that it floats somewhere
where you’d like to position it, on either monitor.
4. Press F5 to put Visual Studio into debugging mode. Adjust the position of the Autos, Call Stack and Output
debugging windows the way you want them. The layout you are about to create will apply to both editing
mode and debugging mode.
5. When your layouts in both debugging mode and editing mode are how you want them, from the main
menu choose Window > Save Window Layout . Call this layout “Designer.”
Note that your new layout is assigned the next Keyboard shortcut from the reserved list of Ctrl + Alt + 1...0.
C r e a t e a d a t a b a se p r o j e c t a n d l a y o u t

1. Add a new SQL Ser ver Database project to the solution.


2. Right-click on the new project in Solution Explorer and choose View in Object Explorer . This displays the
SQL Ser ver Object Explorer window, which enables you to access tables, views and other objects in
your database. You can either float this window or leave it docked. Adjust the other tool windows the way
you want them. For added realism, you can add an actual database, but it’s not necessary for this
walkthrough.
3. When your layout is how you want it, from the main menu choose Window > Save Window Layout .
Call this layout “DB Project.” (We won’t bother with a debug mode layout for this project.)
Sw i t c h b e t w e e n t h e l a y o u t s

1. To switch between layouts, use the Keyboard shortcuts, or from the main menu choose Window > Apply
Window Layout .

After applying the UI layout, note how the layout is preserved both in editing mode and in debug mode.
If you have a multi monitor setup at work and a single monitor laptop at home, you can create layouts that
are optimized for each machine.
Note: If you apply a multi-monitor layout on a single-monitor system, the floating windows that you placed
on the second monitor will now be hidden behind the Visual Studio window. You can bring these windows
to the front by pressing Alt + Tab. If you later open Visual Studio with multiple monitors, you can restore
the windows to their specified positions by re-applying the layout.
Man age an d roam you r layou t s

1. You can remove, rename or reorder your custom layout by choosing Window > Manage Window
Layouts . If you move a layout, the key binding is automatically adjusted to reflect the new position in the
list. The bindings cannot be otherwise modified, and so you can store a maximum of 10 layouts at a time.

To remind yourself which keyboard shortcut is assigned to which layout, choose Window > Apply
Window Layout .
These layouts automatically roam between Visual Studio editions, and also between Blend instances on
separate machines, and from any Express edition to any other Express organization. However, layouts do
not roam across Visual Studio, Blend and Express.

Related Topics
T IT L E DESC RIP T IO N

Kinds of Windows Discusses the differences between tool windows and


document windows in the IDE.

How to: Arrange and Dock Windows Describes how to dock, auto hide, and tile windows, and also
how to reset the window layout.

How to: Move Around in the IDE Describes how you can cycle through open windows in the
IDE, by order of usage. Also describes how you can jump to
specific documents.

Customizing Development Settings in Visual Studio Contains information about settings combinations and how
settings affect window layouts, keyboard shortcuts, and other
elements in the IDE.
Customizing the Start Page for Visual Studio
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can customize the start page for Visual Studio in several default ways, such as showing the Open Project
dialog box or opening the solution that was loaded most recently. You can also show a custom start page, which is
a Windows Presentation Foundation (WPF) XAML page that runs in a tool window and can run commands that are
internal to Visual Studio.

Customizing the default start page


1. On the menu bar, choose Tools , Options .
2. Expand Environment , and then choose Star tup .
3. In the At star tup list, choose the item for the customization that you want.

Show a custom start page


1. Install a custom start page in one of the following ways:
Install it from the Visual Studio Marketplace, another website, or a page on your local intranet.

NOTE
If you like a page that's targeted for an earlier version of Visual Studio, you can upgrade the page by using
the Visual Studio SDK. See How to: Upgrade a Visual Studio Custom Start Page.

Open a .vsix file that contains a custom start page, or copy and paste the start-page files into the
%USERPROFILE% \My Documents\Visual Studio 2015\Star tPages folder on your computer.
Create your own start page if you've installed the Visual Studio SDK.
See Creating Your Own Start Page.
2. On the menu bar, choose Tools , Options .
3. Expand Environment , and then choose Star tup .
4. In the Customize Star t Page list, choose the page that you want.

NOTE
If an error in a custom start page causes Visual Studio to crash, you can start Visual Studio in safe mode and then set it to
use the default start page. See /SafeMode (devenv.exe).

See Also
Customizing Development Settings in Visual Studio Creating Your Own Start Page
Managing External Tools
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can call external tools from inside Visual Studio. A few default tools are available from the Tools menu, but you
can add other executables of your own.

Tools Available on the Visual Studio Tools Menu


You can call the following tools from the Tools menu in Visual Studio. You can also call them by name from the
Quick Launch window. For example, to call GuidGen.exe, type Create GUID .
1. Create GUID: generates a GUID.
2. Error Lookup: gets an error message from the value entered. For more information, see ERRLOOK
Reference.
3. ATL/MFC Trace Tool: shows debug trace messages in the ATL and MFC sources.
4. PreEmptive Protection - Dotfuscator: Protects .NET programs against reverse engineering.
5. SPY++: Displays processes, threads, windows, and window messages graphically.
6. WCF Service Configuration Editor: Allows you to create and modify configuration settings for WCF services.

WARNING
You may see a different list of external tools, depending on which Visual Studio edition you have installed and the settings
profile you have applied. For more information, see Customizing Development Settings in Visual Studio.

Adding New Tools


You can add an external tool to the Tools menu. Open the External Tools dialog box and click Add , then fill in the
information. For example, the following entry causes Windows Explorer to open at the directory of the file you
currently have open in Visual Studio:
1. Title: Open File Location
2. Command: explorer.exe
3. Arguments: /root, "$(ItemDir)"

Arguments for external tools


The following arguments are Visual Studio variables that are assigned when you launch an external tool. Links to
external tools such as Notepad or Spy++ can be listed on the Tools menu using the External Tools dialog box.
NOTE
The IDE status bar displays the Current Line and Current Column variables to indicate where the insertion point is located in
the active Code Editor. The Current Text variable returns the text or code selected at that location.

NAME A RGUM EN T DESC RIP T IO N

Item Path $(ItemPath) The complete file name of the current


file (drive + path + file name).

Item Directory $(ItemDir) The directory of the current file (drive +


path).

Item File Name $(ItemFilename) The file name of the current file (file
name).

Item Extension $(ItemExt) The file name extension of the current


file.

Current Line $(CurLine) The current line position of the cursor in


the code window.

Current Column $(CurCol) The current column position of the


cursor in the code window.

Current Text $(CurText) The selected text.

Target Path $(TargetPath) The complete file name of the item to


be built (drive + path + file name).

Target Directory $(TargetDir) The directory of the item to be built.

Target Name $(TargetName) The file name of the item to be built.

Target Extension $(TargetExt) The file name extension of the item to


be built.

Binary Directory $(BinDir) The final location of the binary that is


being built (defined as drive + path).
For example:\...\My
Documents\Visual Studio
<Version>\
<ProjectName>\bin\debug

Project Directory $(ProjDir) The directory of the current project


(drive + path).

Project file name $(ProjFileName) The file name of the current project
(drive + path + file name).

Solution Directory $(SolutionDir) The directory of the current solution


(drive + path).

Solution file name $(SolutionFileName) The file name of the current solution
(drive + path + file name).
See Also
C/C++ Build Tools
Synchronized Settings in Visual Studio
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

When you use the same personalization account to sign in to Visual Studio on multiple computers, by default your
settings are synchronized on all computers.

Synchronized settings
By default, the following settings are synchronized.
Development settings (You have to select a set of settings the first time you run Visual Studio, but you can
change the selection anytime. For more information, see Customizing Development Settings in Visual
Studio.)
The following options in the Tools | Options pages:
Theme and menu bar casing settings, on the Environment , General options page
All settings on the Environment , Fonts and Colors options page
All keyboard shortcuts, on the Environment , Keyboard options page
All settings on the Environment, Tabs and Windows options page
All settings on the Environment , Star tUp options page
All settings on the Text Editor options pages
All settings on the XAML Designer options pages
User-defined command aliases. For more information about how to define command aliases, see Visual
Studio Command Aliases.
User-defined window layouts in Window | Manage Window Layouts page

Turning synchronized settings off for a particular computer


Synchronized settings for Visual Studio are turned on by default. You can turn off synchronized settings on a
computer by going to the Tools | Options | Environment | Synchronized Settings page and unchecking the
checkbox. For example, if you decide not to synchronize Visual Studio’s settings on Computer A, any setting
changes made on Computer A do not appear on Computer B or Computer C. Computer B and C will continue to
synchronize with each other, but not with Computer A.

Synchronizing settings across Visual Studio family products and


editions
Settings can be synchronized across any edition of Visual Studio 2015, including Express and Community editions.
Settings are also synchronized across Visual Studio family products, such as Blend. However, each of these family
products may have its own settings that are not shared with Visual Studio. For example, settings specific to Blend
on Computer A will be shared with Blend on Computer B, but not with Visual Studio on Computer A or B.

WARNING
Settings are not synchronized between Visual Studio 2013 and Visual Studio 2015. The first time you open Visual Studio
2015, your settings from Visual Studio 2013 are migrated, but they cannot be migrated back to Visual Studio 2013 after
that.

See Also
Personalizing the IDE
Security in Visual Studio
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You should consider security in all aspects of your application development, from design to deployment. Start by
running Visual Studio as securely as possible. See User Permissions.
To help you effectively develop secure applications, you should have a fundamental understanding of security
concepts and the security features of the platforms for which you develop. You should also understand secure
coding techniques.

Understanding Security
Security Describes .NET Framework code access security, role-based security, security policy, and security tools.

Coding for Security


Most coding errors that result in security vulnerabilities occur because developers make incorrect assumptions
when working with user input or because they don't fully understand the platform for which they're developing.
Secure Coding Guidelines Provides guidelines for classifying your components to address security issues.
Security Best Practices Discusses buffer overruns and the complete picture of the Microsoft Visual C++ security
checks feature provided by the /GS compile-time flag.
Securing Applications
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

While most applications possess common security challenges, each application domain possesses security
challenges of its own.

General Security Considerations


Each language has its own security considerations and challenges.
Security Best Practices Provides information on security features and practices available when working in Visual
C++.
NOT IN BUILD: Security and Programming (C# and Visual Basic) Provides information about the top three security
concerns for Visual Basic and C# developers: privileges, Web applications, and Visual Studio setup.

Securing Mobile Applications


As the popularity of mobile devices increases, the security of the information and data on these devices becomes
more important.
Security Considerations for Devices Describes several factors influencing security policy for devices.
Security Goals for the .NET Compact Framework Describes goals for .NET Compact Framework security.
Designing Secure Mobile Web Form Pages Discusses planning, implementing, and supporting security in wireless
networks and mobile devices.

Securing Web Applications


A poorly written Web page can compromise the integrity and security of an entire server and potentially an entire
network. Therefore, you must review security considerations in planning your Web application.
ASP.NET Security Architecture Provides an overview of ASP.NET infrastructure and subsystem relationships, as
related to security.
ASP.NET Web Application Security Details how to address authorization and authentication issues in ASP.NET.
Security Considerations for JScript Details some security pitfalls that JScript programmers may encounter.
How to: Use Transport Security Describes how to use transport security for authentication when you connect to a
WCF service.

Securing Desktop Applications


Designing security for desktop applications is an essential step in application development.
Windows Forms Security Provides an overview of the Windows Forms security implementation.
See Also
Security
Maintaining Security
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

It is often said that the price of security is constant vigilance. Despite your best dedication to security during the
design and development of your application, you should assume that security flaws will arise after deployment. By
auditing your application and analyzing event logs, you may discover some previously hidden flaws.
In addition, not only must you remain vigilant about your own application, you must also keep current on security
threats and flaws for the platform on which your application runs and for other products on which your application
depends.
Security, Privacy, and Accounts Get help with security, privacy, and user accounts, including info about viruses,
passwords, parental controls, firewalls, and drive encryption..
Microsoft Security Bulletin Search This page makes it easy to find previously released bulletins. Intended for IT
professionals, security bulletins provide detailed information regarding security updates.
[Windows Server 2003 Security Guide](/previous-versions/tn-archive/cc163140(v=technet.10) Delivers the
guidance necessary for IT Professionals to securely operate a Windows Server 2003 environment while ensuring
the right access to the right content by the right people.
Best Practices for Enterprise Security A collection of whitepapers focusing on the different aspects of security in
enterprise networks.
Microsoft Baseline Security Analyzer The Microsoft Baseline Security Analyzer (MBSA) is a tool that enables an
individual home user, a corporate user, or an administrator to scan one or more Windows-based computers for
common security configuration mistakes.
User Permissions and Visual Studio
1/13/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

For reasons of security you should run Visual Studio as a normal user whenever possible.

WARNING
You should also make sure not to compile, launch, or debug any Visual Studio solution that does not come from a trusted
person or a trusted location.

You can do nearly everything in the Visual Studio IDE as a normal user, but, you need administrator permissions to
complete the following tasks:

A REA TA SK F O R M O RE IN F O RM AT IO N

Installation Installing Visual Studio. Installing Visual Studio 2015

Upgrading from a trial edition of Visual How to: Upgrade from a Trial Edition of
Studio. Visual Studio

Installing, updating, or removing local Install and Manage Local Content


Help content.

Application types Developing solutions for SharePoint Requirements for Developing


2010. SharePoint Solutions

Acquiring a developer license for Get a developer license (Windows Store


Windows Store. apps)

Toolbox Adding classic COM controls to the Using the Toolbox


Toolbox.

Add-ins Installing and using add-ins that were Creating Add-ins and Wizards
written by using classic COM in the IDE.

Building Using post-build events that register a Understanding Custom Build Steps and
component. Build Events

Including a registration step when you Understanding Custom Build Steps and
build C++ projects. Build Events

Debugging Debugging applications that run with Debugger Settings and Preparation
elevated permissions.
A REA TA SK F O R M O RE IN F O RM AT IO N

Debugging applications that a run Debugging ASP.NET and AJAX


under a different user account, such as Applications
ASP.NET websites.

Debugging in Zone for XAML Browser WPF Host (PresentationHost.exe)


Applications (XBAP).

Using the emulator to debug cloud Debugging a Cloud Service in Visual


service projects for Microsoft Azure. Studio

Configuring a firewall for remote Set Up the Remote Tools on the Device
debugging.

Performance tools Profiling an application. Beginners Guide to Performance


Profiling

Deployment Deploying a web application to Internet Deploying an ASP.NET Web Application


Information Services (IIS) on a local to a Hosting Provider using Visual
computer. Studio or Visual Web Developer:
Deploying to IIS as a Test Environment

Providing feedback to Microsoft Changing how you participate in the How to: Send Feedback
Visual Studio Customer Experience
Program.

Running Visual Studio as an Administrator


You can launch Visual Studio with administrative permissions each time you start the IDE, or you can modify the
application shortcut to always run with administrative permissions. For more information, see Windows Help.
To run Visual Studio with administrative permissions on Windows 8, Windows 8.1, Windows Server 2012, or Windows Server 2012 R2
1. On the Star t screen, type Visual Studio . You should see the version or versions of Visual Studio you have
installed.
2. Select the version of Visual Studio you want to start, and then bring up the shortcut menu (it appears at the
bottom of the screen). Choose Run as administrator .
When Visual Studio starts, (Administrator) appears after the product name in the title bar.
To run Visual Studio with administrative permissions on Windows 7 or Windows Server 2008 R2
1. On the Star t menu, choose All Programs .
2. In the Microsoft Visual Studio Version folder select Visual Studio Version open the shortcut menu, and
then choose Run as administrator .
When Visual Studio starts, (Administrator) appears after the product name in the title bar.

See Also
Porting, Migrating, and Upgrading Visual Studio Projects Installing Visual Studio 2015
Security Bibliography
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Following are selected resources available online and in print on the subject of developing secure applications and
configuring secure environments:

Microsoft Web sites


Microsoft Security Learn how Microsoft is working to help you keep your applications and systems secure, from the
desktop to network-level systems, with links to security resources for IT professionals, developers, and home users.
Security Resources on MSDN Guides you to developer-oriented documentation, code samples, technical articles,
and other resources for developing secure applications.
Microsoft TechNet Security Contains pointers to the most important technical information about security for
information technology professionals and "Power Users".
Visual Studio Samples
1/13/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can find Visual Studio samples on the MSDN Code Gallery website.
You can use the New Project dialog box to browse for samples. (To open the dialog box, on the menu bar, choose
File , New , Project .)

Finding Samples
Here are some other places to look for samples.

A REA DESC RIP T IO N

Windows Developer Center Samples Shows how to develop Windows 8.x Store apps.

.NET Framework Samples Shows various aspects of the .NET Framework in C# and
Visual Basic.

C# Samples Shows how to use different features of C#.

Visual Basic Samples Shows how to use different features of Visual Basic.

F# Samples Shows how to use different features of F#.

JavaScript Samples Shows how to use different features in JavaScript.

C++ Samples Shows how to use different features in C++.

DirectX Samples Shows how to use DirectX.

Office Development Samples Shows how to use Office development tools in Visual Studio.

VSSDK Samples Shows how to extend Visual Studio.

See Also
Getting Started with Visual C# and Visual Basic
Microsoft Help Viewer
10/16/2020 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can install and view content for various products and technologies on your local computer by using Microsoft
Help Viewer.

WARNING
When you install Visual Studio, you get the Help Viewer. To start reading help topics in the Help Viewer rather than on the
MSDN download site, go to the Help menu in Visual Studio, select Set Help Preference , and then select Launch in Help
Viewer . The off-line help topics for a given version of Visual Studio are available only after the final release of that version.

You can do the following:


Find and download sets of content, which are also referred to as books.
Browse and search the table of contents to find topics by title.
Look up subjects in the index.
Find information by using full-text search.
View, bookmark, and print topics.

Navigating the Help Viewer


You can find information in installed content by using the navigation tabs, view installed content in the topic tab or
tabs, and manage content by using the Manage Content tab. You can also perform additional tasks by using the
buttons on the toolbar and find additional information in the lower-right corner of the window.

SC EN A RIO DESC RIP T IO N

Navigation By using the Contents tab, you can display installed content
as a hierarchy and specify criteria to filter the titles that
appear.

By using the Search tab, you can search for terms anywhere
in the content, including code and topic titles.

By using the Index tab, you can search the index, specify
criteria to filter the entries, and require that index entries
either contain or start with text that you specify.

By using the Favorites tab, you can save links to topics that
you use frequently, and you can display a list of topics that
you've viewed recently.
SC EN A RIO DESC RIP T IO N

Topic viewing Each topic appears in a tab, and you can open multiple topics
at the same time.

Managing content You can install, update, move, and delete content by using the
Manage Content tab. At the top of the tab, you can use the
Installation source control to specify whether to install
books from a network location or from a disk or URI. The
Local store path box shows where books are installed on
the local computer, and you can move them to a different
location by choosing the Move button.

The content list shows which books you can install or have
already installed, whether an update is available, and how
large each book is. You can install or remove one or more
books by choosing the appropriate Add or Remove links and
then choosing the Update button under the Pending
changes pane. If updates are available for any books that
you've already installed, you can refresh that content by
choosing the Click here to download now link at the
bottom of the window. In addition, all installed books will be
refreshed if updates are available when you install additional
books. Note: The functionality of the Manage Content tab
may differ if the Help Viewer administrator deactivates these
features, or if no internet access is available.

The toolbar in the Help Viewer window contains the following buttons:
The Show Topic in Contents button shows the location of the topic in the Contents tab.
The Add to Favorites button adds the active topic to the Favorites tab.
The Find in Topic button highlights search text in the active topic.
The Print button prints or shows a preview of the active topic.
The Viewer Options button displays settings such as how large the text appears, how many search results
to return, how many topics to show in history, and whether to check for updates online.
The Manage Content button makes the Manage Content tab active.
The small triangle opens a list of tabs, including topic tabs and the Manage Content tab. You can make any
of those tabs active by choosing it.
The lower area of the Help Viewer window contains information about the total size of pending downloads,
the amount of disk space that they require, and the amount of disk space that's available. This area also
contains information about errors that may have occurred and a link that you can choose to refresh
installed content, if updates are available.

See Also
Help Viewer Administrator Guide Install and Manage Local Content Locate Information Troubleshooting the Help
Viewer
Microsoft Help Viewer Installation
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Several products display Help in Microsoft Help Viewer. Installation instructions will vary based on which product
installed the Help Viewer.

Locating setup information


For information that's specific to your product, see its readme file.
Help Viewer Administrator Guide
10/18/2019 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Help Viewer allows you to manage local Help installations for network environments with or without internet
access. Local help content is configured on a per machine basis. By default, users must have administrator rights to
update their local Help installation.
If your network environment allows clients to access the internet, the Help Viewer allows you to use command line
scripts to deploy local Help content from the internet.
If your network environment does not allow clients to access the internet, the Help Viewer can deploy local Help
content from the intranet or a network share. You can also disable Visual Studio IDE Help options, such as
online/offline help, content installation at first launch of the IDE, specifying an intranet content service, and
managing content, using registry key overrides.
The basic syntax is as follows:
<path to>\HlpCtntmgr.exe /operation <argument> /catalogname <name> /locale <locale> /sourceuri <.msha
path or URL>
For more information about HlpCtntMgr.exe command line syntax, see Command-Line Arguments for the Help
Content Manager.
For more information about creating content, creating an intranet service endpoint, and similar types of activities,
see the Help Viewer SDK.

Deploying Local Help Content from the Internet


You can use the MSDN Content Package service to deploy local Help content from the Internet to client computers.
Use the following syntax:
\<path to>\v2.2\HlpCtntmgr.exe /operation <name> /catalogname <catalog name> /locale <locale>
For more information about HlpCtntMgr.exe command line syntax, see Command-Line Arguments for the Help
Content Manager.
Requirements:
Client computers must have access to the Internet.
Users must have administrator rights to update, add, or remove the local Help content after it has been
installed.
Caveats:
The default source for Help will still be Online.
TIP
You can change the default source for Help by modifying the
HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\help\UseOnlineHelp registry key. For more
information, see Help Content Manager Overrides.

Clients will still be prompted to install the basic Help content on the first launch of Visual Studio. You can
disable this prompt by modifying the
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\Help\DisableFirstRunHel
pSelection registry key.
Example
The following example installs English content for Visual Studio to a client computer.
To i n st a l l En g l i sh c o n t e n t fr o m t h e I n t e r n e t

1. Choose Star t and then choose Run .


2. Type the following:
C:\Program Files (x86)\Microsoft Help Viewer\v2.2\hlpctntmgr.exe /operation install /catalogname
VisualStudio14 /locale en-us
3. Press ENTER.

Deploying Pre-Installed Local Help Content on Client Computers


You can install a set of content from online to one computer, and then copy that installed set of content to other
computers.
Requirements:
The computer you install the set of content to must have access to the Internet.
Users must have administrator rights to update, add, or remove the local Help content after it has been
installed.

TIP
If users do not have administrator rights, it is recommended that you disable the Manage Content tab in the Help
Viewer. For more information, see Help Content Manager Overrides.

Caveats:
If users do not have administrator rights, it is recommended that you disable the Manage Content tab in the
Help Viewer. For more information, see Help Content Manager Overrides.
The default source for Help will still be Online.
Clients will still be prompted to install the basic Help content on the first launch of Visual Studio. For more
information, see Help Content Manager Overrides.
Create the content set
Before you can create the base content set, you must first uninstall all local Visual Studio content on the target
computer.
To u n i n st a l l l o c a l h e l p

1. In the Help Viewer, choose the Manage Content tab.


2. Under Available Documentation , navigate to the Visual Studio document set.
3. Choose Remove next to each sub-item.
4. Choose Star t to uninstall
5. Browse to n:\ProgramData\Microsoft\HelpLibrary2\Catalogs\VisualStudio12 and verify that the folder only
contains the file catalogType.xml.
Once you have removed all previously installed local Visual Studio Help content, you are ready to download
the base content set.
To d o w n l o a d t h e c o n t e n t

1. In the Help Viewer, choose the Manage Content tab.


2. Under Available Documentation , navigate to the documentation sets you want to download and then
choose Add .
3. Choose Star t .
Next, you need to package the content so it can be deployed to client computers.
To p a c k a g e t h e c o n t e n t

1. Create a folder to copy the content to for later deployment.


For example: c:\VS12Help.
2. Open cmd.exe with Administrator permissions.
3. Navigate to the folder you created in step 1.
4. Type the following:
Xcopy %SYSTEMDRIVE%\ProgramData\Microsoft\HelpLibrary2 <foldername>\ /y /e /k /o
For example: Xcopy %SYSTEMDRIVE%\ProgramData\Microsoft\HelpLibrary2 c:\VS12Help\ /y /e /k /o

Deploying the content


To d e p l o y t h e c o n t e n t

1. Create a network share and copy theee help content to that location.
For example, copy the content in c:\VS12Help to \\myserver\VS12Help.
2. Create a .bat file to contain the deployment script for the help content. Since the client could possibly have a
read lock on any of the files being deleted as part of the push, you should have the client shut down prior to
pushing updates.
For example:
REM - copy pre-ripped content to ProgramData
Xcopy %~dp0HelpLibrary2 %SYSTEMDRIVE%\ProgramData\Microsoft\HelpLibrary2\ /y /e /k /o
if ERRORLEVEL 1 ECHO *** ERROR COPYING Help Library files to Programdata (%ERRORLEVEL%)

REM - get processor type and create/run registry update file


IF "%PROCESSOR_ARCHITECTURE%"=="AMD64" GOTO AMD64

@echo Architecture type is x86

ECHO Windows Registry Editor Version 5.00 > x86.reg

ECHO [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Help\v2.2\Catalogs] >> x86.reg


ECHO "ContentStore"="%SYSTEMDRIVE%\\ProgramData\\Microsoft\\HelpLibrary2\\Catalogs\\" >> x86.reg

ECHO [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Help\v2.2\Catalogs\VisualStudio12] >> x86.reg


ECHO "LocationPath"="%SYSTEMDRIVE%\\ProgramData\\Microsoft\\HelpLibrary2\\Catalogs\\VisualStudio12\\"
>> x86.reg
ECHO "FirstTimeRun"="False" >> x86.reg

ECHO [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Help\v2.2\Catalogs\VisualStudio12\en-US] >> x86.reg


ECHO "ContentStore"="%SYSTEMDRIVE%\\ProgramData\\Microsoft\\HelpLibrary2\\Catalogs\\VisualStudio12\\"
>> x86.reg
ECHO "catalogName"="Visual Studio version Help Documentation" >> x86.reg

ECHO [HKEY_LOCAL_MACHINE\Software\Microsoft\VSWinExpress\14.0\help] >> x86.reg


ECHO "UseOnlineHelp"=dword:00000000 >> x86.reg

regedit.exe /s x86.reg
if ERRORLEVEL 1 ECHO *** ERROR inserting the x86 reg (%ERRORLEVEL%)

GOTO CONTINUE

:AMD64
@echo Architecture type is AMD64

ECHO Windows Registry Editor Version 5.00 > x64.reg

ECHO [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Help\v2.2\Catalogs] >> x64.reg


ECHO "ContentStore"="%SYSTEMDRIVE%\\ProgramData\\Microsoft\\HelpLibrary2\\Catalogs\\" >> x64.reg

ECHO [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Help\v2.2\Catalogs\VisualStudio14] >> x64.reg


ECHO "LocationPath"="%SYSTEMDRIVE%\\ProgramData\\Microsoft\\HelpLibrary2\\Catalogs\\VisualStudio14\\"
>> x64.reg
ECHO "FirstTimeRun"="False" >> x64.reg

ECHO [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Help\v2.2\Catalogs\VisualStudio14\en-US] >>


x64.reg
ECHO "ContentStore"="%SYSTEMDRIVE%\\ProgramData\\Microsoft\\HelpLibrary2\\Catalogs\\VisualStudio12\\en-
US\\" >> x64.reg
ECHO "catalogName"="Visual Studio version Help Documentation" >> x64.reg

ECHO [HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VSWinExpress\14.0\help] >> x64.reg


ECHO "UseOnlineHelp"=dword:00000000 >> x64.reg

regedit.exe /s x64.reg
if ERRORLEVEL 1 ECHO *** ERROR inserting the x64 reg (%ERRORLEVEL%)

:CONTINUE

3. Run the bat file on the local machines that the Help content is to be installed onto.

See Also
Command-Line Arguments for the Help Content Manager Help Content Manager Overrides
Command-Line Arguments for the Help Content
Manager
10/18/2019 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can specify how to deploy and manage local Help content by using command-line arguments for Help
Content Manager (HlpCtntmgr.exe). You must run scripts for this command-line tool with administrator
permissions, and you can’t run these scripts as a service. You can perform the following tasks by using this tool:
Add or update local Help content from a disk or the cloud.
Remove local Help content.
Move the local Help content store.
Add, update, remove, or move local Help content silently.
Syntax:

HlpCtntmgr.exe /operation Value /catalogname CatalogName /locale Locale /sourceuri InstallationPoint

For example:

hlpctntmgr.exe /operation install /catalogname VisualStudio14 /locale en-us /sourceuri


d:\productDocumentation\HelpContentSetup.msha

Switches and Arguments


The following table defines the switches and arguments that you can use for the command-line tool for Help
Content Manager:

SW ITC H REQ UIRED? A RGUM EN T S


SW ITC H REQ UIRED? A RGUM EN T S

/operation Yes - Install--Adds books from the


specified installation source to the local
content store.
This switch requires the /booklist
argument, the /sourceURI argument, or
both. If you don’t specify the
/sourceURI argument, the default Visual
Studio URI is used as the installation
source. If you don’t specify the /booklist
argument, all books on the /sourceUri
are installed.
- Uninstall--Removes the books that
you specify from the local content
store.
This switch requires the /booklist
argument or the /sourceURI argument.
If you specify the /sourceURI argument,
all books are removed, and the
/booklist argument is ignored.
- Move --Moves the local store to the
path that you specify. The default local
store path is set by Help setup under
%PROGRAMDATA%
This switch requires the /locationPath
and /catalogName arguments. Error
messages will be logged in the event
log if you specify a path that isn’t valid
or if the drive doesn’t contain enough
free space to hold the content.
- Refresh --Updates topics that have
changed since they were installed or
most recently updated.
This switch requires the /sourceURI
argument.

/catalogName Yes Specifies the name of the content


catalog.

/locale No Specifies the product locale that’s used


to view and manage content for the
current instance of the Help viewer. For
example, you specify EN-US for
English-United States.

If you don’t specify a locale, the locale


of the operating system is used. If that
locale can’t be determined, EN-US is
used.

If you specify a locale that isn’t valid, an


error message is logged in the event
log.

/e No Elevates the Help Content Manager to


Administrative priviledges if the current
user has administrative credentials.
SW ITC H REQ UIRED? A RGUM EN T S

/sourceURI No Specifies the URL from which content is


installed (Service API) or the path to the
content installation file (.msha). The URL
can point to the Product Group (top-
level node) or to the Product Books
(leaf-level node) in a Visual Studio 2010
style endpoint. You don’t need to
include a slash (/) at the end of the URL.
If you do include a trailing slash, it will
be handled appropriately.

An error message is logged in the event


log if you specify a file that isn’t found,
isn't valid, or isn't accessible or if a
connection to the Internet isn’t
available or is interrupted while content
is being managed.

/vendor No Specifies the vendor for the product


content that will be removed (for
example, Microsoft ). The default
argument for this switch is Microsoft.

/productName No Specifies the product name for the


books that will be removed. The
product name is identified in the
helpcontentsetup.msha or books.html
files that shipped with the content. You
can remove books from only one
product at a time. To remove books
from multiple products, you must
perform multiple installations.

/booklist No Specifies the names of the books to be


managed, separated by spaces. Values
must match the book names as listed
on the installation media.

If you don’t specify this argument, all


recommended books for the specified
product in the /sourceURI are installed
if the installation source is in Visual
Studio 2012 format.

If the name of a book contains one or


more spaces, surround it with double
quotes (“) so that the list is delimited
appropriately.

Error messages will be logged if you


specify a /sourceURI that isn’t valid or
isn't reachable.

/skuId No Specifies the stock keeping unit (SKU) of


the product from the installation
source, and filters books that the
/SourceURI switch identifies.
SW ITC H REQ UIRED? A RGUM EN T S

/membership No - Minimum -- Installs a minimum set


of Help content based on the SKU that
you specify by using the /skuId switch.
The mapping between the SKU and the
content set is exposed in the Service
API.
- Recommended —Installs a set of
recommended books for the SKU that
you specify by using the /skuId
argument. The Installation source is the
service API or .MSHA.
- Full-- Installs the entire set of books
for the SKU that you specify by using
the /skuId argument. The Installation
source is the service API or .MSHA.

/locationpath No Specifies the default folder for local Help


content. You must use this switch only
to install or move content. If you
specify this switch, you must also
specify the /silent switch.

/silent No Installs or removes Help content


without prompting the user or
displaying any UI, including the icon in
the status notification area. Output is
logged to a file in the %Temp%
directory. Impor tant: To install content
silently, you must use digitally signed
.cab files, not .mshc files.

/launchingApp No Defines the application and catalog


context when the Help viewer is
launched without the parent
application. The arguments for this
switch are CompanyName,
ProductName, and VersionNumber (for
example,
/launchingApp
Microsoft,VisualStudio,11.0
).

This is required for installing content


with the /silent parameter.”

/wait Seconds No Pauses install, uninstall, and refresh


operations. If an operation is already in
progress for the catalog, the process
will wait up to the given number of
seconds to continue. Use 0 to wait
indefinitely.

/? No Lists the switches and their descriptions


for the command-line tool for Help
Content Manager.

Exit Codes
When you run the command-line tool for the Help Content Manager in silent mode, it returns the following exit
codes:
Success = 0,

FailureToElevate = 100
InvalidCmdArgs = 101,
FailOnFetchingOnlineContent = 110,
FailOnFetchingContentFromDisk = 120,
FailOnFetchingInstalledBooks = 130,
NoBooksToUninstall = 200,
NoBooksToInstall = 300,
FailOnUninstall = 400,
FailOnInstall = 500,
FailOnMove = 600,
FailOnUpdate = 700,
FailOnRefresh = 800,
Cancelled = 900,
Others = 999,
ContentManagementDisabled = 1200,
OnlineHelpPreferenceDisabled = 1201
UpdateAlreadyRunning = 1300 – (Signals that the update didn't run because another was in progress.)

See Also
Help Viewer Administrator Guide Help Content Manager Overrides
Help Content Manager Overrides
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can modify the registry to change the default behavior of the Help Viewer and Help-related features in the
Visual Studio IDE.

TA SK REGIST RY K EY VA L UE A N D DEF IN IT IO N

Define unique service endpoint HKEY_LOCAL_MACHINE\SOFTWARE\M NewContentAndUpdateService-


icrosoft\VSWinExpress\14.0\Help -HTTPValueForTheServiceEndpoint.

Define online/offline default HKEY_LOCAL_MACHINE\Software\Micr UseOnlineHelp--Enter 0 to specify


osoft\VSWinExpress\14.0\help local Help, and enter 1 to specify
online Help.

Define unique F1 endpoint HKEY_LOCAL_MACHINE\SOFTWARE\M OnlineBaseUrl-


icrosoft\VSWinExpress\14.0\Help -HTTPValueForTheServiceEndpoint

Override BITS job priority HKEY_LOCAL_MACHINE\SOFTWARE\W BITSPriority--Use one of the following


ow6432Node (on a 64-bit values: foreground , high , normal, or
machine)\Microsoft\Help\v2.2 low .

Disable Online (and IDE Online option) HKEY_LOCAL_MACHINE\SOFTWARE\W OnlineHelpPreferenceDisabled--Set to


ow6432Node (on a 64-bit 1 to disable access of online Help
machine)\Microsoft\VisualStudio\14.0\ content.
Help

Disable Manage Content HKEY_LOCAL_MACHINE\SOFTWARE\W ContentManagementDisabled--Set to


ow6432Node (on a 64-bit 1 to disable the Manage Content tab
machine)\Microsoft\VisualStudio\14.0\ in Help Viewer.
Help

Point to local content store on network HKEY_LOCAL_MACHINE\SOFTWARE\M LocationPath=”ContentStoreNetworkSh


share icrosoft\Help\v2.2\Catalogs\VisualStudi are”
o11

Disable installation of content at first HKEY_LOCAL_MACHINE\SOFTWARE\W DisableFirstRunHelpSelection--Set to 1


launch of Visual Studio feature. ow6432Node (on a 64-bit to disable help features that are
machine)\Microsoft\VisualStudio\14.0\ configured the first time that Visual
Help Studio starts.

See Also
Help Viewer Administrator Guide
Install and Manage Local Content
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

By using the Microsoft Help Viewer, you can add, remove, update, and move the Help content that is installed on
your computer to fit your software-development needs.
To manage content on your local computer, you must log on with an account that has administrative permissions.
In addition, you might not be able to manage local content if you work in an enterprise environment because
system administrators might make those decisions for your organization. For more information, see the Help
Viewer Administrator Guide.

Changing the content installation source


By default, the Help Viewer installs content by using a Microsoft online service as the source. You generally
shouldn't change your content source unless you work in an enterprise environment for which a system
administrator has already installed content in another location.
To change the content installation source
1. On the Manage Content tab, choose the Disk option button.

NOTE
The Disk option won't be available if your administrator has prevented you from modifying the content installation
source. For more information, see the Help Viewer Administrator Guide.

2. Perform one of the following steps:


Enter the path of an .msha file or the URL of a service endpoint.
Choose the Browse (… ) button to navigate to an .msha file.
In the list, choose the entry that was used most recently.

Download and install content locally


You can view topics without an Internet connection if you download and install content on your local computer.

IMPORTANT
To install content, you must log on with an account that has administrative permissions.

If the Visual Studio IDE is set to a language other than English, you can install English content, localized content, or
both. However, no content will appear if you install only the English version and the Include English content in
all navigation tabs and F1 requests check box in the Viewer Options dialog box is cleared.
To download and install content
1. Choose the Manage Content tab.
2. In the content list, choose the Add link next to the book or books that you want to download and install.
The book is added to the Pending changes list, and the estimated size of the book or books that you
specified appears below that list. Because some books share topics, the total download size of multiple
books might be smaller than the result of adding together the sizes of every book that you specified.
3. Choose the Update button.
The book or books that you specified are installed along with any updates for books that you already have
on your computer. Installation times vary, but you can view the progress in the status bar.

Removing local content


You can save disk space by removing unwanted content from your computer.

IMPORTANT
You must have administrative permissions to remove content.

No content will appear if the Visual Studio IDE is set to a language other than English, you remove localized
content, and the Include English content in all navigation tab and F1 requests check box in the Viewer
Options dialog box is cleared.
To remove content
1. Choose the Manage Content tab.
2. In the content list, choose the Remove link next to the book or books that you want to remove.
The book is added to the Pending changes list.
3. Choose the Update button.
The book or books that you specified are removed from your computer.

Updating local content


The status bar indicates when updates to your installed content are available.

IMPORTANT
If you want the Help Viewer to automatically check for online updates, you must open the Viewer Options dialog box and
then select the Go online to check for content updates check box.

To update local content


In the lower-right corner of the status bar, choose the Click here to download now link.
Update times can vary, but you can view the update progress in the status bar.

Moving local content


You can save disk space by moving installed content from your local computer to a network share or to another
partition on your local computer.
IMPORTANT
To move content, you must log on with an account that has administrative permissions.

To move local content


1. On the Manage Content tab, choose the Move button under Local Store Path .
The Move Content dialog box opens.
2. In the To text box, enter a different location for the content, and then choose the OK button.
3. Choose the Close button when the content has been moved.

See Also
Microsoft Help Viewer
Locate Information
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Help Viewer provides several different ways for you to locate information in Help. Depending on what kind of
information you're looking for, certain strategies might be more effective than others.

F O R IN F O RM AT IO N A B O UT T RY

An element of the user interface The F1 key

Other topics that are in the same area of the table of contents The Show Topic in Contents button on the toolbar
as the current topic

A feature or technology Index

Language elements such as methods and events Search

In this Section
Full-Text Search Tips
How to: Find Topics in the Table of Contents
How to: Find Topics in the Index
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The index contains a list of keywords that are associated with topics in the installed content. Each topic might have
more than one keyword associated with it, and each keyword might be associated with more than one topic. Use
this index in the same way as you would use an index in a book.
To find a topic by using the index
1. On the Index tab, perform either of the following tasks:
Specify the keyword to search for in the text box. For example, specify "update" to find topics with
keywords such as "update," "updated," and "updating."
By choosing the filter button near the top of the tab, you can display either all entries that contain the
text that you specify or only those entries that start with the text that you specify.

NOTE
When the filter button appears on a darker background with a border, entries must contain the text that you
specify. If the background and border don't appear, entries must start with the text that you specify.

Scroll through the index, and choose a keyword.


If the keyword that you specify is associated with only one topic, it appears. Otherwise, a list of all
topics that are associated with that keyword appears.

See Also
Index Search Tips
Index Search Tips
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can locate information in the Index by entering keywords. This topic suggests useful ways to search Help using
the Index.

Index Search Tips


Using the index is a straight-forward process; however, understanding how to best enter keywords can make your
index searches more productive.
General Guidelines
Scroll through the index entries. Not all topics are indexed the same way, and the one that could most help
you might be higher or lower in the list than you expected.
Omit articles such as "an" or "the" because the index ignores them.
Reverse the words you enter if you do not find the entries you expect.
For example, if "debugging inline assembly code" did not display any relevant entries, try typing, "assembly
code, debugging inline".
Use filters with the Index tab to decrease the number of results.
Syntax Tips
If you do not find an entry for the word or phrase you entered, try the following:
Type the first few letters, or root, of the word. By entering a partial string, you can get to topics that have
been indexed with keywords that are singular or plural.
For example, enter "propert" to start your search above properties and property.
Enter gerund (-ing) forms of the verb for the task you want to complete. To find more specific index entries,
append a word that describes exactly what you want.
For example, type "running" to get more entries or "running programs" to get fewer.
Enter standalone adjectives. To narrow the results, append a word that describes exactly what you want.
For example, enter "COM+" to get a wide range of entries or "COM+ components" to get fewer.
Enter a synonym of the word or verb you are looking for.
For example, if you entered the gerund "building" try "creating" instead.

See Also
Full-Text Search Tips Locate Information
How to: Find Topics in the Table of Contents
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In the Contents tab, you can use the table of contents (TOC) to find information. The table of contents is an
expandable list that contains all of the topics in the installed books. For accessibility information about how to
navigate through the TOC, see Shortcut Keys (Help Viewer).

IMPORTANT
The scope of topics available in the TOC depends on the filter you have selected.

Filter the TOC


You can filter the TOC to narrow the scope of topics that appear in the Contents tab. Titles appear in the list only if
they contain the root of the term that you specify. For example, if you specify "troubleshooting" as a filter, only titles
that contain "troubleshoot" or "troubleshooting" appear. Nodes whose titles don't contain the term are collapsed to
a single node with an ellipsis (...).
To filter the TOC
1. Choose the Contents tab.
2. In the Filter Contents text box, enter a term.

NOTE
If the filter takes a long time to run, you might display results more quickly by using the title: advanced search operator.

Synchronize a topic with the TOC


If you have opened a topic using the index or full-text search features, you can determine where this topic is in the
TOC by synchronizing the TOC with the topic window.
To synchronize the TOC with the topic window
1. View a topic.
2. Click the Show Topic in Contents button on the toolbar, or press Ctrl+S.
The Contents tab opens and displays the topic's location in the TOC.

See Also
Locate Information Microsoft Help Viewer
How to: Search for Topics
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can use the full-text search feature to locate all topics that contain a particular word. You can also refine and
customize your search by using wildcard expressions, logical operators, and advanced search operators.
To open the Search tab
Choose the Search tab in the Help Viewer window, or choose the Ctrl + E keys.
To perform a full-text search
1. In the search box, type the word that you want to find.
2. In the search query, specify which logical or advanced search operators to apply to the search, if any. To
search all available Help, don't use operators.

NOTE
In the Viewer Options dialog box, you can specify additional preferences such as the maximum number of search
results to display at a time and whether to include English content if your primary locale is not English.

3. Choose the Enter key.


A search returns a maximum of 200 hits, by default, and displays them in the search results area.
Additional version information for each result may appear depending on the content.
4. To view a topic, choose its title from the results list.

See Also
Full-Text Search Tips Logical Operators in Search Expressions Advanced Search Operators in Search Expressions
How to: Customize Search Results
Full-Text Search Tips
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

One of the more useful methods of locating information in Help is by performing a full-text search. To refine and
customize your results, you must understand how syntax affects your query. This topic provides tips, procedures,
and detailed syntax information to help you better craft your queries.

Full-Text Search Tips


You can create more targeted searches that return only those topics that interest you if you understand how Help
interprets the formatting that you use in queries. These formats include special characters, reserved words, and
filters.
General Guidelines
The following table includes some basic rules and guidelines for developing search queries in Help.

SY N TA X DESC RIP T IO N

Case sensitivity Searches aren't case-sensitive. Develop your search criteria


using uppercase or lowercase characters. For example, "OLE"
and "ole" return the same results.

Character combinations You can't search only for individual letters (a–z) or numbers
(0–9). If you try to search for certain reserved words, such as
”and”, ”from”, and ”with”, they will be ignored. For more
information, see "Words Ignored in Searches (Stop Words)"
later in this topic.

Evaluation order Search queries are evaluated from left to right.

Search Syntax
If you specify a search string that includes multiple words, such as "word1 word2," that string is equivalent to
typing "word1 AND word2", which returns only topics that contain all of the individual words in the search string.

IMPORTANT
1. Phrase searches are not supported. If you specify more than one word in a search string, returned topics will contain all
of the words that you specified but not necessarily the exact phrase that you specified. 2. Use logical operators to specify
the relationship between words in your search phrase. You can include logical operators, such as AND, OR, NOT, and
NEAR, to further refine your search. For example, if you search for "declaring NEAR union", search results will include
topics that contain the words "declaring" and "union" no more than a few words apart from each other. For more
information, see Logical Operators in Search Expressions.

Filters
You can further restrict search results by using advanced search operators. Help includes three categories that you
can use to filter results of a full-text search: Title, Code, and Keyword. For more information, see Advanced Search
Operators in Search Expressions.
Ranking of Search Results
The search algorithm applies certain criteria to help rank search results higher or lower in the results list. In
general:
1. Content that includes search words in the title is ranked higher than content that doesn't.
2. Content that includes search words in close proximity is ranked higher than content that doesn't.
3. Content that contains a higher density of the search words is ranked higher than content that has a lower
density of the search words.
Words Ignored in Searches (Stop Words)
Commonly occurring words or numbers, which are sometimes called stop words, are automatically ignored
during a full-text search. For example, if you search for the phrase "pass through", search results will display topics
that contain the word "pass" but not "through".

See Also
Locate Information Logical Operators in Search Expressions
Logical Operators in Search Expressions
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

By using logical operators, you can refine your search for content by creating more complicated search
expressions from simpler ones. As the following table shows, logical operators specify how multiple search terms
should be combined in a search query.

IMPORTANT
You must enter logical operators in all capital letters for the search engine to recognize them.

TO SEA RC H F O R USE EXA M P L E RESULT

Both terms in the same AND dib AND palette Topics that contain both
topic "dib" and "palette".

Either term in a topic OR raster OR vector Topics that contain either


"raster" or "vector".

First term without the NOT "operating system" NOT Topics that contain
second term in the same DOS "operating system" but not
topic "DOS".

Both terms, close together NEAR user NEAR kernel Topics that contain "user"
in a topic within close proximity of
"kernel".

See Also
Full-Text Search Tips Locate Information
Advanced Search Operators in Search Expressions
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

By using advanced search operators, you can refine your search for content by creating more complicated search
expressions from simpler ones. As the following table shows, these operators restrict the context in which a query
runs.

WARNING
You must enter advanced search operators with a final colon and no intervening space before the colon for the search
engine to recognize them.

TO SEA RC H F O R USE EXA M P L E RESULT

A term in the title of the title: title:binaryreader Topics that contain


topic “binaryreader” in their titles.

A term in a code example code: code:readdouble Topics that contain


"readdouble" in a code
example.

A term in an example of a code:vb: code:vb:string Topics that contain “string” in


specific programming a Visual Basic example.
language

A topic that is associated keyword: keyword:readbyte Topics that are associated


with a specific index keyword with the “readbyte” index
keyword.

You can use the code: operator to find content about any of several programming languages, but it returns results
only for content that is marked up with a specific programming language. The following table lists the
programming languages that this operator supports:

P RO GRA M M IN G L A N GUA GE USE

Visual Basic code:vb

or

code:visualbasic
P RO GRA M M IN G L A N GUA GE USE

C# code:c#

or

code:csharp

C++ code:cpp

or

code:c++

or

code:cplusplus

F# code:f#

or

code:fsharp

JavaScript code:javascript

or

code:js

XAML code:xaml

See Also
Logical Operators in Search Expressions Full-Text Search Tips
How to: Customize Search Results
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can customize how search results appear in the Search tab in several ways.

Change the number of topics that appear on a search results page


You can specify the number of topics that appear on a single search results page.
To change the number of topics displayed at a time
1. On the Toolbar , choose Viewer Options .
The Viewer Options dialog box appears.
2. In the Maximum Search Results list, choose 25, 50, 100, or 200.

Search for content by language


Documentation may include content in a language other than English. You can narrow your search results to
content in a particular language. You can also include any content in English that matches your search query.

WARNING
This feature is enabled only if the primary language of installed content isn't English.

To include English content alongside content in another language


1. On the Toolbar , choose Viewer Options .
The Viewer Options dialog box appears.
2. Select the Include English content in all navigation tabs and F1 requests check box.

See Also
Full-Text Search Tips
Manage the Help Viewer Window
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In the Help Viewer you can customize the window layout.

Docking Tabs
The Help Viewer supports standard docking functionality. By default, all tabs in the Help Viewer are docked, but you
can move them, resize them, dock them in other locations, and "float" them so that they appear as independent
child windows.
To restore the Help Viewer window to its default layout, open the Viewer Options dialog box, and then choose the
Reset button.

Opening a Topic in a New Tab


Choose the topic in any navigation tab, and then choose the Ctrl + Enter keys.

Minimize a Navigation Tab


Create more space for viewing topics by choosing the pin icon for the navigation tabs. When these tabs are
minimized, only their labels appear on the closest edge of the window. To restore the tabs, choose the label of any
tab, and then choose the pin icon again.
Retain Topics for Later Use
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

When you locate a useful topic, you can access it later by copying it and pasting it into a text file, printing it, or
saving it as a favorite. For example, you can retain content for later use by opening the shortcut menu for topics
and the choosing the Copy , Print , Print Preview , and Add to Favorites options.

Using the Favorites tab


On the Favorites tab, you can open the shortcut menu for any entry and then rename it, delete it, or organize
entries into folders.

See Also
Shortcut Keys (Help Viewer)
Customize the Help Viewer
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can configure several features of the Help Viewer by using the Viewer Options dialog box.

Setting Viewer Options


You open the Viewer Options dialog box by choosing the Viewer Options button on the toolbar.

TO P ERF O RM T H IS TA SK : TA K E T H IS ST EP :

Change the size of the font in which text appears Choose a size in the Text Size list.

Change the maximum number of search results that appear in Choose a value in the Maximum Search Results list.
the Search tab

Change the maximum number of history entries that appear Choose a value in the Maximum Histor y entries saved
in the Favorites window list.

Include or exclude English content when you view content for Select or clear the Include English content in all
a non-English version of a product. navigation tabs and F1 requests check box. Caution:
This feature also controls whether you can download English
content in the Manage Content tab.
Troubleshooting the Help Viewer
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This topic discusses issues that you might encounter with the Help Viewer.

Audio doesn't work.


The Help Viewer doesn't include an audio player. If you download content that contains audio and nothing happens
when you choose Play , install an audio player.

Search doesn't work in Windows Server 2008, Windows Server 2008


with SP1, or Windows Server 2008 R2.
The search and filter features in the Help Viewer require the Windows Search service to be installed and on. By
default, this service is off in Windows Server 2008, Windows Server 2008 with Service Pack 1 (SP1), and Windows
Server 2008 R2.
To activate Windows Search service
1. Start Server Manager.
2. In the left navigation pane, choose Roles .
3. In the Roles Summary pane, choose Add Role .
4. Choose the File Services role, and then choose the Next button.
5. Choose the Windows Search role service.

Additional Resources
You can get more information and provide feedback on the Help Viewer by using the following resources:
To provide feedback, see Microsoft Connect on the Microsoft website or send email to
[email protected].
For more information, see the Developer Documentation and Help System forum and The Help Guy blog.

See Also
Help Viewer 2.1 Administrator Guide
Accessibility Features of the Help Viewer
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Microsoft is committed to making its products and services easier for everyone to use. This topic includes
information about the features, products, and services that help make Microsoft Help Viewer 2.2 accessible for
people with a wide range of abilities.

Keyboard access
You can access all features of the Help Viewer by using the keyboard. For more information, see Shortcut Keys
(Help Viewer).

Font size
You can modify the font size in which topic text appears in the document window. For more information, see
Customize the Help Viewer.

Window size
You can change the width of the navigation or document windows by pointing to the divider between the two
windows. When the cursor changes to a double-headed arrow, use the primary mouse button to drag the divider to
the right or left.

Help Viewer position


You can reposition the Help Viewer by dragging its title bar to a different position.

Internet Explorer options


You can make the Help Viewer more accessible by changing Internet Explorer options that relate to how webpages
appear. For more information, see Customize the Help Viewer.

See Also
Microsoft Help Viewer
Shortcut Keys (Help Viewer)
10/16/2020 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can navigate in the Microsoft Help Viewer by using the shortcut keys in the following table:

A REA K EY ST RO K E A C T IO N

General Application Space Use instead of Enter anywhere except in


edit fields.

General Application F1 Open Help about current UI element.

General Application F11 Toggle between full-screen view and


regular view.

Toolbar Backspace Display the previous page.

-OR-

Alt + Left Arrow

Toolbar Alt + Right Arrow Display the next page.

Toolbar Alt + Home Display the Help Reviewer Home page.

Toolbar Ctrl + S Highlight the current topic in the table


of contents (on the Contents tab).

Toolbar Ctrl + D Add the current topic to the Favorites


tab.

Toolbar Ctrl + F Display the Find bar in the topic area so


that you can search for text within the
current topic.

Toolbar Ctrl + P Print the current page.

Toolbar Ctrl + F2 Display a print preview of the current


page.

Toolbar Ctrl + O Display the Viewer Options dialog


box.

Toolbar Ctrl + Shift + M Display the Manage Contents tab.


A REA K EY ST RO K E A C T IO N

Navigators Alt + C Display the Contents tab.

-OR-

Ctrl + Shift + C

Navigators Alt + I Display the Index tab.

-OR-

Ctrl + Shift + I

Navigators Alt + F Display the Favorites tab.

-OR-

Ctrl + Shift + F

Navigators Alt + S Display the Search tab.

-OR-

Ctrl + E

-OR-

Ctrl + Shift + S

Navigators Alt + M Display the Manage Content tab.

-OR-

Ctrl + Shift + M

Topic Shortcut Menu key Display the shortcut menu for the
current UI element.
OR

Shift + F10

Topic Up Arrow Scroll toward the start of the document


one line at a time.

Topic Down Arrow Scroll toward the end of the document


one line at a time.

Topic Page Up Scroll toward the start of the document


one screen at a time.

Topic Page Down Scroll toward the end of the document


one screen at a time.

Topic Home Move to the start of the document.

Topic End Move to the end of the document.


A REA K EY ST RO K E A C T IO N

Topic Ctrl + F Find search text on this page.

Topic F5 Refresh the current page.

Topic Ctrl + P Print the current page.

Topic Ctrl + F2 Display a print preview of the current


page.

Topic F4 Display the Proper ties dialog box for


the current page.

Topic Ctrl + T Open another content tab in the


foreground.

Topic Ctrl + Click Open a link on a new tab in the


foreground.

Topic Ctrl + Tab Switch among tabs from left to right.

Topic Ctrl + Shift + Tab Switch among tabs from right to left.

Topic Ctrl + W Close the current tab.

Topic Ctrl + Number Switch to a specific tab where Number


is between 1 and 9 and indicates which
tab in sequence.

Topic Ctrl +Alt + F4 Close other content tabs.

Topic Ctrl + Shift + Plus Sign Increase zoom by 10%.

Topic Ctrl + Minus Sign Decrease zoom by 10%.

Topic Ctrl + 0 (zero) Change zoom to 100%.

Index Tab Shift focus from keyword entry to


keyword list.

Index Ctrl + K Switch between showing entries that


contain the keyword that you specify
and entries that start with the keyword
that you specify.

Favorites Ctrl + Shift + Del Clear your browsing history.

Favorites Del Delete the specified item.

Favorites Ctrl + N Create a folder within Favorites.

Favorites F2 Rename the specified favorite or folder.


A REA K EY ST RO K E A C T IO N

Contents & Index & Search Ctrl + D Add the specified topic to the
Favorites tab.

Contents & Index & Search & Favorites Ctrl + P Print the specified topic.

Contents & Index & Search & Favorites Ctrl + F2 Display a print preview of the specified
topic.

Contents & Index & Search & Favorites Ctrl + Click Open the topic in a new tab.

Search Esc Clear the search text box.

Viewer Options Alt + T Change focus to the Text Size list.

Viewer Options Alt + S Change focus to the Maximum


Search Results list.

Viewer Options Alt + H Change focus to the Maximum


Histor y entries saved list.

Viewer Options Alt + E Select or clear the Include English


content in all navigation tabs and
F1 requests check box if it is enabled.

Viewer Options Alt + O Select or clear the Go online to check


for content updates check box.

Find Enter Change focus to the next item.

Find Shift + Enter Change focus to the previous item.

Find Esc Hides the Find text box.

Status bar Alt + E Open the Error dialog box if the status
bar shows that an error has occurred.

Status bar Alt + U Download content if the status bar


shows that updates are available

Window Management

K EY ST RO K E A C T IO N

Ctrl + L Reset the Help Viewer layout to the default layout, and close
all topic tabs.

Ctrl + Tab The first keystroke gives focus to the Tab Selection menu.
The next keystroke gives focus to the top menu item, and
subsequent keystrokes give focus to the menu items in
sequence from top to bottom. When a menu item has focus,
the Enter key makes that item the active tab.
K EY ST RO K E A C T IO N

Ctrl + Shift + Tab The first keystroke gives focus to the Tab Selection menu.
The next keystroke gives focus to the bottom menu item, and
subsequent keystrokes give focus to the menu items in
sequence from bottom to top. When a menu item has focus,
the Enter key makes that item the active tab.

Alt + I, Alt + S, Alt + C, Alt + F, Alt + M These shortcut keys don't work when the navigation and
content-management tabs are undocked.

Manage Content

K EY ST RO K E A C T IO N

Alt + D Change the installation source to disk.

Alt + O Change the installation source to online.

Tab Change focus to the Local store path text box.

Tab Change focus to the Move… button.

Alt + V Open the Move Content dialog box.

Ctrl + Alt + F Change focus to the Filter Documentation text box.

Tab Change focus to the documentation list.

Up Arrow and Down Arrow Scroll through the documentation list.

Space Add an item to the Pending changes list.

Tab Change focus to the Pending changes list.

Up Arrow and Down Arrow Scroll through the Pending changes list.

Space Remove an item from the Pending changes list.

Alt + T Apply all pending changes.


Globalizing and Localizing Applications
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

If you plan on distributing your application to an international audience, you'll need to keep several things in mind
during the design and development phases. Even if you don't have such plans, a small effort up front can make
things considerably easier should your plans change in future versions of your application. Services built into the
.NET Framework make it easy to develop a single application that can adapt to different locales using managed
development with Visual Studio.
Visual Studio was designed from the start to make developing for an international audience easy by taking
advantage of services built into the .NET Framework. The following pages will help introduce you to the
internationalization features built into Visual Studio.

In This Section
Introduction to International Applications Based on the .NET Framework Introduces the concepts related to
developing software for an international market using Visual Studio and the .NET Framework.
Localizing Applications Provides links to pages about customizing applications for a given culture.
Globalizing Applications Provides links to pages about creating applications that support multiple cultures.

Related Sections
Globalizing your app (Windows Store apps using JavaScript and HTML) Contains how-to topics and guidelines to
help you globalize and localize your Windows 8.x Store app built using JavaScript and HTML.
Globalizing your app (Windows Store apps using C#/VB/C++ and XAML) Contains how-to topics and guidelines
to help you globalize and localize your Windows 8.x Store app built using XAML and Visual C#, Visual Basic, or
Visual C++.
Best Practices for Developing World-Ready Applications Provides background information on programming for
an international audience.
Class Library Overview Introduces the classes, interfaces, and value types that expedite and optimize the
development process and provide access to system functionality.
System.Globalization Points out the classes in this namespace, which define culture-related information, including
the language, the country/region, the calendars in use, the format patterns for dates, currency and numbers, and
the sort order for strings.
System.Resources Points out the classes and interfaces in this namespace, which allows developers to create, store,
and manage various culture-specific resources used in an application.
Introduction to International Applications Based on
the .NET Framework
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In Visual Studio, there are two parts to creating a world-ready application: globalization, the process of designing
applications that can adapt to different cultures, and localization, the process of translating resources for a specific
culture. For general information on designing applications for an international audience, see Best Practices for
Developing World-Ready Applications.
The .NET Framework localization model consists of a main assembly that contains both the application code and
the fallback resources — strings, images, and other objects for the language in which the application is originally
developed. Each localized application will have satellite assemblies, or assemblies which contain only the localized
resources. Because the main assembly always contains the fallback resources, if a resource is not found in the
localized satellite assembly, the ResourceManager will attempt to load it in a hierarchical manner, eventually falling
back to the resource in the main assembly. The resource fallback system is explained in greater detail in
Hierarchical Organization of Resources for Localization.
One localization resource you should consider using is the glossary for all Microsoft localized products. This CSV
file contains over 12,000 English terms plus the translations of the terms in up to 59 different languages. The
glossary is available for download on the Microsoft Terminology Translations Web page.
The project system for Windows Forms applications can generate resource files for both the fallback and each
desired additional UI culture. The fallback resource file is built into the main assembly, and the culture-specific
resource files are then built into satellite assemblies, one for each UI culture. When you build a project, the
resource files are compiled from the Visual Studio XML format (.resx) to an intermediate binary format
(.resources), which are then embedded in satellite assemblies.
The project system for both Windows Forms and Web Forms allows you to build resource files using an Assembly
Resource File template, access the resources, and build your project. Satellite assemblies will be created along with
the main assembly.
When a localized application executes, its appearance is determined by two culture values. (A culture is a set of
user preference information related to the user's language, environment, and cultural conventions.) The UI culture
setting determines which resources will be loaded. The UI culture is set as UICulture in Web.config files and page
directives, and CurrentUICulture in Visual Basic or Visual C# code. The culture setting determines formatting of
values such as dates, numbers, currency, and so on. The culture is set as Culture in Web.config files and page
directives, CurrentCulture in Visual Basic or Visual C# code.

See Also
System.Globalization System.Resources Globalizing and Localizing Applications Security and Localized Satellite
Assemblies
Localizing Applications
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Localization is the process of customizing your application for a given culture or locale. Localization consists
primarily of translating the user interface.

In This Section
Hierarchical Organization of Resources for Localization Explains how localized resources are stored and accessed
in Visual Studio.
Security and Localized Satellite Assemblies Discusses signing satellite assemblies with public-private key pairs.
Version Numbers for Main and Localized Satellite Assemblies Introduces the SatelliteContractVersionAttribute
class, which determines which satellite assemblies work with an application's main assembly.
Neutral Resources Languages for Localization Introduces the NeutralResourcesLanguageAttribute class, which
specifies the culture of the resources included in an application's main assembly.

Related Sections
Introduction to International Applications Based on the .NET Framework Discusses the concepts related to
developing software for an international market using Visual Basic or Visual C#.
Globalizing Windows Forms Provides links to pages about creating Windows applications that support multiple
cultures.
Globalization and Localization Provides links to pages about creating Web applications that support multiple
cultures.
Best Practices for Developing World-Ready Applications Provides information on programming for an
international audience, such as design issues and terminology.
Hierarchical Organization of Resources for
Localization
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In Visual Studio, localized resources (data such as strings and images appropriate to each culture) are stored in
separate files and loaded according to the UI culture setting. To understand how localized resources are loaded, it is
useful to think of them as organized in a hierarchical manner.

Kinds of Resources in the Hierarchy


At the top of the hierarchy sit the fallback resources for your default culture, for example English ("en").
These are the only resources that do not have their own file; they are stored in the main assembly.
Below the fallback resources are the resources for any neutral cultures. A neutral culture is associated with a
language but not a country/region. For example, French ("fr") is a neutral culture. (Note that the fallback
resources are also for a neutral culture, but a special one.)
Below those are the resources for any specific cultures. A specific culture is associated with a language and a
country/region. For example, French Canadian ("fr-CA") is a specific culture.
If an application tries to load any localized resource, such as a string, and does not find it, it will travel up the
hierarchy until it finds a resource file containing the requested resource.
The best way to store your resources is to generalize them as much as possible. That means to store
localized strings, images, and so forth in resource files for neutral cultures rather than specific cultures
whenever possible. For instance, if you have resources for the French Belgian ("fr-BE") culture and the
resources immediately above are the fallback resources in English, a problem may result when someone
uses your application on a system configured for the French Canadian culture. The system will look for a
satellite assembly for "fr-CA", not find it, and load the main assembly containing the fallback resource, which
is English, instead of loading the French resources. The following picture shows this undesirable scenario.

If you follow the recommended practice of placing as many resources as possible in a neutral resource file
for the "fr" culture, the French Canadian user would not see resources marked for the "fr-BE" culture, but he
or she would be shown strings in French. The following situation shows this preferred scenario.
See Also
Neutral Resources Languages for Localization Security and Localized Satellite Assemblies Localizing Applications
Globalizing and Localizing Applications How to: Set the Culture and UI Culture for Windows Forms Globalization
How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization
Security and Localized Satellite Assemblies
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

If your main assembly uses strong naming, satellite assemblies must be signed with the same private key as the
main assembly. If the public/private key pair does not match between the main and satellite assemblies, your
resources will not be loaded. For more information on signing assemblies, see How to: Sign an Assembly with a
Strong Name.
In general, you may need to have your organization's signing group or an external signing organization sign with
the private key. This is due to the sensitive nature of the private key: access is often restricted to a few individuals.
You can use delayed signing during development. For more information, see Delay Signing an Assembly.

See Also
Assembly Security Considerations Key Security Concepts Introduction to International Applications Based on the
.NET Framework Localizing Applications Globalizing and Localizing Applications
Version Numbers for Main and Localized Satellite
Assemblies
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The SatelliteContractVersionAttribute class provides versioning support for a main assembly that uses localized
resources by means of the resource manager. Applying the SatelliteContractVersionAttribute to an application's
main assembly allows you to update and re-deploy the assembly without updating its satellite assemblies. For
example, you can use the SatelliteContractVersionAttribute class with a service pack that doesn't introduce new
resources without rebuilding and redeploying your satellite assemblies. For your localized resources to be
available, the satellite contract version of your main assembly must match the AssemblyVersionAttribute class of
your satellite assemblies. You must specify an exact version number in the SatelliteContractVersionAttribute;
wildcard characters such as "*" are not allowed. For more information, see Retrieving Resources.

Updating Assemblies
The SatelliteContractVersionAttribute class allows you to update a main assembly without having to update your
satellite assembly, or vice versa. When the main assembly is updated, its assembly version number is changed. If
you want to continue using the existing satellite assemblies, change the main assembly's version number but leave
the satellite contract version number the same. For example, in your first release your main assembly version may
be 1.0.0.0. The satellite contract version and the assembly version of the satellite assembly will also be 1.0.0.0. If
you need to update your main assembly for a service pack, you can change the assembly version to 1.0.0.1, while
keeping the satellite contract version and the satellite's assembly version as 1.0.0.0.
If you need to update a satellite assembly but not your main assembly, you change the AssemblyVersionAttribute
of the satellite assembly. Along with your satellite assembly, you will have to ship a policy assembly that states that
your new satellite assembly is compatible with your old satellite assembly. For more information on policies, see
How the Runtime Locates Assemblies.
The following code shows how to set the satellite contract version. The code can be placed in either a build script or
in the AssemblyInfo.vb or AssemblyInfo.cs file.

<Assembly: SatelliteContractVersionAttribute("4.3.2.1")>

[assembly: SatelliteContractVersionAttribute("4.3.2.1")]

See Also
How the Runtime Locates Assemblies Setting Assembly Attributes Security and Localized Satellite Assemblies
Localizing Applications Globalizing and Localizing Applications
Neutral Resources Languages for Localization
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The NeutralResourcesLanguageAttribute class specifies the culture of the resources included in the main assembly.
This attribute is used as a performance enhancement, so that the ResourceManager object does not search for
resources that are included in the main assembly.
The following code shows how to set the neutral resources language. The code can be placed in either a build
script or in the AssemblyInfo.vb or AssemblyInfo.cs file.

' Set neutral resources language for assembly.


<Assembly: NeutralResourcesLanguageAttribute("en")>

// Set neutral resources language for assembly.


[assembly: NeutralResourcesLanguageAttribute("en")]

See Also
ResourceManager Introduction to International Applications Based on the .NET Framework Hierarchical
Organization of Resources for Localization Localizing Applications Globalizing and Localizing Applications
Globalizing Applications
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Globalization is the process of designing and developing a software product that functions for multiple cultures.
This section applies to both Windows Forms and Web Forms pages.

In This Section
Culture-Specific Classes for Global Windows Forms and Web Forms Discusses classes that format dates, time,
numbers, currency, and other information according to the culture setting.

Related Sections
Globalizing Windows Forms Provides links to Help pages about globalization of Windows Forms.
Globalization and Localization Provides links to Help pages about globalization of Web Forms pages.
Introduction to International Applications Based on the .NET Framework Discusses the essential concepts about
developing software for an international market using Visual Basic or Visual C#.
Best Practices for Developing World-Ready Applications Provides information on programming for an
international audience, such as design issues and terminology.
Culture-Specific Classes for Global Windows Forms
and Web Forms
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Each culture has different conventions for displaying dates, time, numbers, currency, and other information. The
System.Globalization namespace contains classes that can be used to modify how culture-specific values are
displayed, such as DateTimeFormatInfo, Calendar , and NumberFormatInfo.

Using the Culture Setting


But most of the time you will use the culture setting, stored either in the application or in the Regional Options
control panel, to automatically determine the conventions at run time and format the information accordingly. For
more information on setting the culture, see How to: Set the Culture and UI Culture for Windows Forms
Globalization or How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization. Classes that
automatically format information according to the culture setting are called culture-specific. Some culture-specific
methods are System.IFormattable.ToString, System.Console.WriteLine, and System.String.Format. Some culture-
specific functions (in the Visual Basic language) are MonthName and WeekDayName .
For example, the following code shows how you can use the ToString method to format currency for the current
culture:

' Put the Imports statements at the beginning of the code module
Imports System.Threading
Imports System.Globalization
' Display a number with the culture-specific currency formatting
Dim MyInt As Integer = 100
Console.WriteLine(MyInt.ToString("C", Thread.CurrentThread.CurrentCulture))

// Put the using statements at the beginning of the code module


using System.Threading;
using System.Globalization;
// Display a number with the culture-specific currency formatting
int myInt = 100;
Console.WriteLine(myInt.ToString("C", Thread.CurrentThread.CurrentCulture));

If the culture is set to "fr-FR", you will see this in the output window:
100,00

If the culture is set to "en-US", you will see this in the output window:
$100.00

See Also
System.IFormattable.ToString DateTimeFormatInfo NumberFormatInfo Calendar System.Console.WriteLine
System.String.Format Globalizing and Localizing Applications
Creating Applications in Bi-directional Languages
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can use Visual Studio to create applications that correctly display text in languages written right-to-left,
including Arabic and Hebrew. For some features, you can simply set properties. In other cases, you must implement
features in code.

NOTE
In order to enter and display bi-directional languages, you must be working with a version of Windows that is configured
with the appropriate language. This can either be an English version of Windows with the appropriate language pack installed,
or the appropriately localized version of Windows.

Types of Application that Support Bi-Directional Languages


1. Windows applications. You can create fully bi-directional applications that include support for bi-directional
text, right-to-left reading order, and mirroring (reversing the layout of windows, menus, dialog boxes, and so
on). Except for mirroring, these features are available by default or as property settings. Mirroring is
supported inherently for some features, such as message boxes. However, in other cases you must
implement mirroring in code. For more information, see Bi-Directional Support for Windows Forms
Applications.
2. Web applications. Web services support and receiving sending UTF-8 and Unicode text, making them
suitable for applications involving bi-directional languages. Web client applications rely on browsers for
their user interface, so the degree of bi-directional support in a Web application is dependent on how well
the user's browser supports those bi-directional features. In Visual Studio, you can create applications with
support for Arabic or Hebrew text, right-to-left reading order, file encoding, and local culture settings. For
more information, see Bidirectional Support for ASP.NET Web Applications.
3. Console applications. Console applications do not include text support for bi-directional languages. This is a
consequence of how Windows works with console applications.

Visual Studio Features That Are Fully Supported


At design time in Visual Studio, you can use bi-directional languages in these ways:
Text entr y Visual Studio supports Unicode, so if your system is set to the appropriate locale and input
language, you can enter text in Arabic or Hebrew. (Arabic support includes Kashida and Diacritics.)
Object names You can use bi-directional languages to assign names to solutions, projects, files, folders, and
so on. In code, you can use bi-directional languages for the names of variables, classes, object, attributes,
metadata, and other elements.
File encoding You can save and open files with a language-specific or Unicode encoding. For more
information, see How to: Save and Open Files with Encoding.
Features with Limited or No Support
Other features common to bi-directional language applications are not fully supported in Visual Studio, or in some
cases, not at all. These include:
Right-to-left reading order By default, text-entry controls you use in Visual Studio use left-to-right
reading order. In most cases, you can use standard Windows gestures to switch reading order. For example,
you can press Ctrl+Right Shift to switch the Properties window to support right-to-left reading order for
property values.
However, right-to-left reading order is not supported everywhere in Visual Studio. Exceptions include:
Check boxes, drop-down lists, and other controls in Visual Studio dialog boxes always use left-to-right
reading order.
The code editor (and text editor) does not support right-to-left reading order. You can enter text in a
bi-directional language, but the reading order is always left-to-right.

Naming Things Using Arabic or Hebrew Text


You can use Arabic or Hebrew text to assign names to folders, variables, or other objects. When working with
Arabic, you can use any Arabic characters including Kashida and Diacritics.
The following elements can be named using Arabic or Hebrew and will be handled correctly in Visual Studio:
Solution, project, and file names, including any folders you include in the project path. Solution Explorer will
display solution and element names correctly.
File contents. You can open or save files with Unicode encoding or with a selected code page.

NOTE
The code editor is a special case. For details, see below.

Data elements. Ser ver Explorer will display these elements correctly and allow you to edit them.
Elements copied to the Windows Clipboard.
Attributes and metadata.
Property values. You can use Arabic or Hebrew text in the Properties window. The window allows you to
switch between right-to-left and left-to-right reading order using standard Windows keystrokes
(CTRL+RightShift for right-to-left, and CTRL+LeftShift for left-to-right).
Code and literal text. In the code editor (which is also the text editor), you can use Arabic or Hebrew to name
classes, functions, variables, properties, string literals, attributes, and so on. However, the editor does not
support right-to-left reading order; text always starts at the left margin.

TIP
It is recommended that you place string literals in resource files instead of hard-coding them into your programs. For
more information, see Walkthrough: Localizing Windows Forms.
NOTE
You must be consistent in how you refer to objects named in these languages. For example, if you use Kashida in
naming an Arabic variable, you must always use Kashida when referring to that variable, or errors will result.

Code comments. You can create comments in Arabic or Hebrew. You can also use these languages in the
comment builder tool.

See Also
Bi-Directional Support for Windows Forms Applications Bidirectional Support for ASP.NET Web Applications
Globalizing Applications Localizing Applications
How to: Save and Open Files with Encoding
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can save files with specific character encoding to support bi-directional languages. You can also specify an
encoding when opening a file, so that Visual Studio displays the file correctly.
To save a file with encoding
1. From the File menu, choose Save File As , and then click the drop-down button next to the Save button.
The Advanced Save Options dialog box is displayed.
2. Under Encoding , select the encoding to use for the file.
3. Optionally, under Line endings , select the format for end-of-line characters.
This option is useful if you intend to exchange the file with users of a different operating system.
If you want to work with a file that you know is encoded in a specific way, you can tell Visual Studio to use
that encoding when opening the file. The method you use depends on whether the file is part of your
project.
To open an encoded file that is part of a project
1. In Solution Explorer , right-click the file and choose Open With .
2. In the Open With dialog box, choose the editor to open the file with.
Many Visual Studio editors, such as the forms editor, will auto-detect the encoding and open the file
appropriately. If you choose an editor that allows you to choose an encoding, the Encoding dialog box is
displayed.
3. In the Encoding dialog box, select the encoding that the editor should use.
To open an encoded file that is not part of a project
1. On the File menu, point to Open , choose File or File From Web , and then select the file to open.
2. Click the drop-down button next to the Open button and choose Open With .
3. Follow Steps 2 and 3 from the preceding procedure.

See Also
Encoding and Windows Forms Globalization Globalizing and Localizing Applications
Adding Visual Studio editor support for other
languages
10/16/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Learn about how the Visual Studio editor supports reading and navigating through different computer languages
and how you can add Visual Studio editor support for other languages.

Syntax colorization, statement completion, and Navigate To support


Features in the Visual Studio editor such as syntax colorization, statement completion, and Navigate To can help you
more easily read, create, and edit your code. The following screenshot shows an example of editing a Perl script in
Visual Studio. The syntax is automatically colorized. For example, remarks in the code are colored green, code is
black, paths are red, and statements are blue. The Visual Studio editor automatically applies syntax colorization to
any language it supports. In addition, when you begin to enter a known language keyword or object, statement
completion displays a list of possible statements and objects. Statement completion can help you create code more
quickly and easily.

Visual Studio currently provides syntax colorization and basic statement completion support for the following
languages using TextMate Grammars. If your favorite language isn't in the table, though, don't worry - you can add
it.
Bat
F#
Java
Markdown
Rust
Visual Basic
Clojure
Go
JavaDoc
Objective-C
ShaderLab
C#
CMake
Groovy
JSON
Perl
ShellScript
Visual C++
CoffeeScript
HTML
LESS
Python
SQL
VBNet
CSS
INI
LUA
R
Swift
XML
Docker
Jade
Make
Ruby
TypeScript
YAML
In addition to syntax colorization and basic statement completion, Visual Studio also has a feature called Navigate
To. This feature enables you to quickly search code files, file paths and code symbols. Visual Studio provides
Navigate To support for the following languages.
Go
Java
JavaScript
PHP
TypeScript
Visual Basic
Visual C++
Visual C#
All of these file types have the features described earlier even if support for a given language hasn't yet been
installed. Installing specialized support for some languages may provide additional language support, such
as IntelliSense or other advanced language features such as Light Bulbs.

Adding support for non-supported languages


Visual Studio 2015 Update 1 and later versions provide language support in the editor by using TextMate
Grammars. If your favorite programming language currently isn't supported in the Visual Studio editor, first, search
the web - a TextMate bundle for the language may already exist. If you can't find one, though, you can add support
for it yourself in Visual Studio 2015 Update 1 or later by creating a TextMate bundle model for language grammars
and snippets.
Add any new TextMate Grammars for Visual Studio in the following folder:
%userprofile%\.vs\Extensions
Under this base path, add the following folder(s) if they apply to your situation:

F O L DER N A M E DESC RIP T IO N

\<language name> The language folder. Replace <language name> with the name
of the language. For example, \Matlab .

\Syntaxes The grammar folder. Contains the grammar .json files for the
language, such as Matlab.json .

\Snippets The snippets folder. Contains snippets for the language.

In Windows, %userprofile% resolves to the path: c:\Users\<user name>. If the extensions folder does not exist on
your system, you will need to create it. If the folder already exists, it will be hidden.
For details about how to create TextMate Grammars, see TextMate – Introduction to Language Grammars: How to
add source code syntax highlighting embedded in HTML and Notes on how to create a Language Grammar and
Custom Theme for a Textmate Bundle.

See Also
Visual Studio 2013 Navigate To Improvements Walkthrough: Creating a Code Snippet Walkthrough: Displaying
Statement Completion
General User Interface Elements (Visual Studio)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This section describes some user interface elements of the integrated development environment (IDE).

In This Section
Call Hierarchy Represents the set of caller/callee relationships in code.
Code Snippet Picker Allows you to pick a snippet from a set of snippets for your language.
Error List Window Displays compile errors and warnings.
Go To Line Allows you to navigate to a specific line in a file.
Options Dialog Box Allows you to specify options.
Options, Text Editor, General Allows you to specify general options for the text editor.
Options, Text Editor, File Extension Allows you to specify file extensions for the editor.
Options, Text Editor, All Languages Allows you to specify options that are common to all programming languages.
Options, Text Editor, All Languages, Tabs Allows you to specify tab options that can be common to all programming
languages.
Options, Text Editor, Basic (Visual Basic) Allows you to specify options for Visual Basic files.
Options, Text Editor, C/C++, Formatting Allows you to specify formatting options for C or C++ files.
Options, Text Editor, C/C++, Advanced Allows you to specify advanced options for C or C++ files.
Options, Text Editor, C#, Formatting Allows you to specify formatting options for C# files.
Options, Text Editor, C#, Advanced Allows you to specify advanced options for C# files.
Options, Text Editor, C#, IntelliSense Allows you to specify IntelliSense options for C# files.
Options, Text Editor, XAML, Formatting Allows you to specify formatting options for XAML files.
Project Properties Reference Allows you to specify properties of your project.
Projects and Solutions, Options Dialog Box Allows you to specify project and solution options.
Properties Window Displays properties for projects, files, controls, and fields in IDE windows and designers.
Quick Launch, Environment, Options Dialog Box Provides a quick way for you to find Visual Studio windows,
commands, options, and menus.
Toolbox Allows you to add controls to a design surface.
Toolbox, Components Tab Allows you to add components to a design surface.
Toolbox, Data Tab Allows you to add data controls to a design surface.
Toolbox, HTML Tab Allows you to add html tags to a design surface.
General, CSS, Text Editor, Options Dialog Box Allows you to specify options for CSS files.
Validation, HTML, Text Editor, Options Dialog Box Allows you to specify options for HTML pages.
Call Hierarchy
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Call Hierarchy enables you to navigate through your code by displaying all calls to and from a selected method,
property, or constructor. This enables you to better understand how code flows and to evaluate the effects of
changes to code. You can examine several levels of code to view complex chains of method calls and additional
entry points to the code, which enables you to explore all possible execution paths.
Call Hierarchy is available at design time, unlike the call stack that is displayed by the debugger.

Using Call Hierarchy


To display the Call Hierarchy window, right-click the name of a method, property, or constructor call, and then
click View Call Hierarchy .
The member name appears in a tree view pane in the Call Hierarchy window. If you expand the member node,
Calls To member name and Calls From member name subnodes appear. The following illustration shows these
nodes in the Call Hierarchy window.

Call Hierarchy window


If you expand the Calls To node, all members that call the selected member are displayed.
If you expand the Calls From node, all members that are called by the selected member are displayed.
You can then expand each of these subnode members into Calls To and Calls From nodes. This enables
you to navigate into the stack of callers, as shown in the following illustration.

Call
Hierarchy window
For members that are defined as either virtual or abstract, an Overrides method name node appears. For
interface members, an Implements method name node appears. These expandable nodes appear at the
same level as the Calls To and Calls From nodes.
The Search Scope box on the toolbar contains choices for My Solution , Current Project , and Current
Document .
When you select a child member in the Call Hierarchy tree view pane:
The Call Hierarchy details pane displays all lines of code in which that child member is called from the
parent member.
The Code Definition Window , if open, displays the code for the selected member. This window is
available in C# and C++. For more information about this window, see Viewing the Structure of Code.

NOTE
Call Hierarchy does not find method group references, which includes places where a method is added as an event handler
or is assigned to a delegate. To find all references to a method, you can use the Find All References command.

Shortcut Menu Items


The following table describes several shortcut menu options that are available when you right-click a node in the
tree view pane.

C O N T EXT M EN U IT EM DESC RIP T IO N

Add As New Root Adds the selected node to the tree view pane as a new root
node. This enables you to focus your attention on a specific
subtree.

Remove Root Removes the selected root node from the tree view pane. This
option is available only from a root node.

You can also use the Remove Root toolbar button to remove
the selected root node.

Go To Definition Runs the Go To Definition command on the selected node.


This navigates to the original definition for a member call or
variable definition.

To run the Go To Definition command, you can also double-


click the selected node or press F12 on the selected node.

Find All References Runs the Find All References command on the selected node.
This finds all the lines of code in your project that reference a
class or member.

You can also use SHIFT+F12 to run the Find All References
command on the selected node.

Copy Copies the contents of the selected node (but not its
subnodes).

Refresh Collapses the selected node so that re-expanding it displays


current information.
Choose Toolbox Items, WPF Components
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This tab of the Choose Toolbox Items dialog box displays a list of Windows Presentation Foundation (WPF)
controls available on your local computer. To display this list, select Choose Toolbox Items from the Tools menu
to display the Choose Toolbox Items dialog box, and then select its WPF Components tab. To sort the
components listed, select any column heading.
When the check box next to a component is selected, an icon for that component will be displayed in the
Toolbox .

TIP
To add an instance of a WPF control to a project document open for editing, drag its Toolbox icon onto the Design
view surface. Default markup and code for the component are inserted into your project, ready for you to modify. For
more information, see How to: Manage the Toolbox Window and How to: Manipulate Toolbox Tabs.

When the check box next to a component is cleared, the corresponding icon will be removed from the
Toolbox.

NOTE
The .NET Framework components installed on your computer remain available whether or not icons for them are
displayed in the Toolbox.

The columns on the WPF Components tab contain the following information:
Name Lists the names of WPF controls for which entries exist in your computer's registry.
Namespace Displays the hierarchy of the NIB: .NET Framework Class Library namespace that defines the
structure of the component. Sort on this column to list the available components within each .NET
Framework namespace installed on your computer.
Assembly Name Displays the name of the .NET Framework assembly that includes the namespace for each
component. Sort on this column to list the namespaces contained in each .NET Framework assembly
installed on your computer.
Directory Displays the location of the .NET Framework assembly. The default location for all assemblies is the
Global Assembly Cache. For further information on the Global Assembly Cache, see Working with
Assemblies and the Global Assembly Cache.

UIElement List
Filter Filters the list of WPF controls based on the string you provide in the text box. All matches from any of the
four columns are shown.
Clear Clears the filter string.
Browse Opens the Open dialog box, which lets you navigate to assemblies which contain WPF controls. Use this to
load assemblies which are not located in the Global Assembly Cache.
Language Shows the localized language of the assembly which contains the selected WPF control.

Limitations
Adding a custom control or UserControl to the Toolbox has the following limitations.
Works only for custom controls defined outside the current project.
Does not update correctly when you change the solution configuration from Debug to Release, or from
Release to Debug. This is because the reference is not a project reference, but is for the assembly on disk
instead. If the control is part of the current solution, when you change from Debug to Release, your project
continues to reference the Debug version of the control.
In addition, if design-time metadata is applied to the custom control and this metadata specifies that the
ToolboxBrowsableAttribute is set to false , the control does not appear in the Toolbox.
You can reference your controls directly in XAML view by mapping the namespace and assembly for your
control. For more information, see How to: Import a Namespace into XAML.

See also
Choose Toolbox Items Dialog Box (Visual Studio)
Toolbox
How to: Use a Third-Party WPF Control in a WPF Application
WPF Designer
Code Snippet Picker
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Visual Studio Code Editor provides a Code Snippet Picker that allows you, in a few mouse clicks, to insert
ready-made blocks of code into the active document.
The procedure to display the Code Snippet Picker varies according to the language you are using.
Visual Basic - Right-click at the desired location in the Code Editor to display the Shortcut menu, and select
Inser t Snippet .
Visual C# - Right-click at the desired location in the Code Editor to display the Shortcut menu, and click
Inser t Snippet or Surround With .
Visual C++ - The Code Snippet Picker is not available.
Visual F# - The Code Snippet Picker is not available.
JScript -- Right-click at the desired location in the Code Editor to display the Shortcut menu, and click Inser t
Snippet or Surround With .
XML - Right-click at the desired location in the Code Editor to display the Shortcut menu, and click Inser t
Snippet or Surround With .
HTML - Right-click at the desired location in the Code Editor to display the Shortcut menu, and click Inser t
Snippet or Surround With .
SQL - Right-click at the desired location in the Code Editor to display the Shortcut menu, and click Inser t
Snippet .
In most Visual Studio development languages, you can use the Code Snippets Manager to add folders to
the Folder List that the Code Snippet Picker scans for XML snippet files. You can also create your own
snippets to add to the list. For more information, see Walkthrough: Creating a Code Snippet.

UIElement List
Item Name An editable text field that displays the name of the item selected in the Item List . To perform an
incremental search for the item you want, begin typing its name in this field. Continue adding letters until the
desired item is selected in the Item List .
Item List A list of code snippets available for insertion, or a list of folders containing code snippets. To insert a
snippet or expand a folder, select the item you want and press Enter.

See Also
Best Practices for Using Code Snippets Visual Basic IntelliSense Code Snippets Setting Bookmarks in Code How to:
Use Surround-with Code Snippets
Command Window
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Command window is used to execute commands or aliases directly in the Visual Studio integrated
development environment (IDE). You can execute both menu commands and commands that do not appear
on any menu. To display the Command window, choose Other Windows from the View menu, and select
Command Window .

Displaying the Values of Variables


To check the value of a variable varA , use the Print Command:

>Debug.Print varA

The question mark (?) is an alias for Debug.Print , so this command can also be written:

>? varA

Both versions of this command will return the value of the variable varA .

Entering Commands
The greater than symbol ( > ) appears at the left edge of the Command window as a prompt for new lines. Use
the UP ARROW and DOWN ARROW keys to scroll through previously issued commands.

TA SK SO L UT IO N EXA M P L E

Evaluate an expression. Preface the expression with a question ? myvar


mark ( ? ).

Switch to an Immediate window. Enter immed into the window immed


without the greater than sign (>)

Switch back to the Command window Enter cmd into the window. >cmd
from an Immediate window.

The following shortcuts help you navigate while in Command mode.

A C T IO N C URSO R LO C AT IO N K EY B IN DIN G

Cycle through the list of previously Input line UP ARROW & DOWN ARROW
entered commands.
A C T IO N C URSO R LO C AT IO N K EY B IN DIN G

Scroll up the window. Command window contents CTRL+UP ARROW

Scroll down the window. Command window contents DOWN ARROW or CTRL+DOWN
ARROW

TIP
You can copy all or part of a previous command to the input line by scrolling to it, highlighting all or part of it, and then
pressing ENTER.

Mark Mode
When you click on any previous line in the Command window, you shift automatically into Mark mode. This
allows you to select, edit, and copy the text of previous commands as you would in any text editor, and paste
them into the current line.

The Equals (=) Sign


The window used to enter the EvaluateStatement command determines whether an equals sign (=) is
interpreted as a comparison operator or as an assignment operator.
In the Command window, an equals sign (=) is interpreted as a comparison operator. You cannot use
assignment operators in the Command window. So, for example, if the values of variables varA and varB
are different, then the command

>Debug.EvaluateStatement(varA=varB)

will return a value of False .


In the Immediate window, by contrast, an equals sign (=) is interpreted as an assignment operator. So, for
example, the command

>Debug.EvaluateStatement(varA=varB)

will assign to variable varA the value of variable varB .

Parameters, Switches, and Values


Some Visual Studio commands have required and optional arguments, switches and values. Certain rules
apply when dealing with such commands. The following is an example of a rich command to clarify the
terminology.

Edit.ReplaceInFiles /case /pattern:regex var[1-3]+ oldpar

In this example,
Edit.ReplaceInFiles is the command
/case and /pattern:regex are switches (prefaced with the slash [/] character)
regex is the value of the /pattern switch; the /case switch has no value
var[1-3]+ and oldpar are parameters

NOTE
Any command, parameter, switch, or value that contains spaces must have double quotation marks on either
side.

The position of switches and parameters can be interchanged freely on the command line with the
exception of the Shell command, which requires its switches and parameters in a specific order.
Nearly every switch supported by a command has two forms: a short (one character) form and a long
form. Multiple short-form switches can be combined into a group. For example, /p /g /m can be
expressed alternately as /pgm .
If short-form switches are combined into a group and given a value, that value applies to every switch.
For example, /pgm:123 equates to /p:123 /g:123 /m:123 . An error occurs if any of the switches in the
group does not accept a value.

Escape Characters
A caret (^) character in a command line means that the character immediately following it is interpreted
literally, rather than as a control character. This can be used to embed straight quotation marks ("), spaces,
leading slashes, carets, or any other literal characters in a parameter or switch value, with the exception of
switch names. For example,

>Edit.Find ^^t /regex

A caret functions the same whether it is inside or outside quotation marks. If a caret is the last character on the
line, it is ignored. The example shown here demonstrates how to search for the pattern “^t”.

Use Quotes for Path Names with Spaces


If, for example, you want to open a file that has a path containing spaces, you must put double quotes around
the path or path segment that contains spaces: C:\"Program Files" or "C:\Program Files" .

See Also
Visual Studio Command Aliases Visual Studio Commands
Convert Dialog Box
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Conver t dialog box allows you to select a conversion tool to create a new project from an old one, such as
creating a Visual Basic 2005 project from a Visual Basic 6 project. You can also use the Visual Studio Project
Converter, available on the CodePlex web site, to upgrade projects created in previous versions of Visual Studio.

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following
instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more
information, see Personalizing the IDE.

Opening the Convert Dialog Box


To access the Convert dialog box
1. On the menu bar, choose File , Open , Conver t .
You will see a list of the code-conversion tools that are currently available.
2. Select the tool that is appropriate for your application.

See Also
NOTINBUILD - How to: Upgrade a Project from Visual Basic 6.0 Porting, Migrating, and Upgrading Visual Studio
Projects
Error List Window
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

NOTE]

The Error List displays information about a specific error message. You can copy the error number or error
string text from the Output window. To display the Output window, press Ctrl+Alt+O. See Output Window.

You can develop apps faster by using the Error List window. For example, you can perform the following tasks:
Display the errors, warnings, and messages produced while you write code.
Find syntax errors noted by IntelliSense.
Find deployment errors, certain Static Analysis errors, and errors detected while applying Enterprise
Template policies.
Double-click any error message entry to open the file where the problem occurs, and move to the error
location.
Filter which entries are displayed, and which columns of information appear for each entry.
Search for specific terms and scope the search to just the current project or document.
To display the Error List , click View / Error List , or CTRL+\+E .
You can choose the Errors , Warnings , and Messages tabs to see different levels of information.
To sort the list, click any column header. To sort again by an additional column, hold down the SHIFT key and
click another column header. To select which columns are displayed and which are hidden, choose Show
Columns from the shortcut menu. To change the order in which columns are displayed, drag any column
header to the left or right.

NOTE
The dialog boxes and menu commands you see might differ from those described here, depending on your active settings or
edition. To change your settings, click Tools / Impor t and Expor t Settings . For more information, see Customizing
Development Settings in Visual Studio.

Error List Filters


There are two types of filter in two dropdown boxes, one on the right side of the toolbar and one to the left of the
toolbar. The dropdown list on the left side of the toolbar specifies the set of code files to use (Entire Solution ,
Open Documents , Current Project , Current Document ).
You can restrict the scope of the search to analyze and act on groups of errors. For example, you might want to
focus on core errors that are preventing a project from compiling. The scoping options include:
1. Open Documents : Show errors, warnings, and messages for the open documents.
2. Current Project : Show errors, warnings, and messages from the project of the currently selected document
in the Editor or the selected project in Solution Explorer .

NOTE
The filtered list of errors, warnings, and messages will change if the project of the currently selected document is
different from the project selected in Solution Explorer .

3. Current Document : Show errors, warnings, and messages for the currently selected document in the
Editor or Solution Explorer .
If a filter is currently applied to the search result, the name of the filter appears in the Error List title bar. The
Errors , Warnings , and Messages buttons then display the number of filtered items being shown along
with the total number of items; for example, the buttons show x of y Errors. If no filter is applied, the title bar
says only “Error List”.
The list on the right side of the toolbar specifies whether to show errors from the build (errors resulting
from a build operation) or from IntelliSense (errors detected before running a build), or from both.

Search
Use the Search Error List text box on the right side of the Error List toolbar to find specific errors in the error
list. You can search on any visible column in the error list, and search results are always sorted based on the
column that has sort priority instead of on the query or the filter applied. If you choose the Esc key while the focus
is in the Error List , you can clear the search term and filtered search results. You can also click the X on the right
side of the text box to clear it.

Save
You can copy the error list and save it to a file. Select the errors you want to copy and right-click the selection, then
on the context menu select Copy . You can then paste the errors into a file. If you paste the errors to an Excel
spreadsheet, the fields appear as different columns.

UI Element List
Severity Displays the different types of Error List entry (Error , Message , Warning , Warning (active) , Warning
(inactive) .
Code Displays the error code.
Description Displays the text of the entry.
Project Displays the name of the current project.
File Displays the file name.
Line Displays the line where the problem occurs.
File Properties, JavaScript
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can use file properties to indicate what actions the project system should perform on the files. For example, you
can set file properties to indicate whether a file should be added to the package as a resource file.
You can select any file in Solution Explorer and then examine its properties in the Properties window. JavaScript
files have four properties: Copy to Output Director y , Package Action , File Name , and File Path .

File Properties
This section describes properties common to JavaScript files.
Copy to Output Directory Property
This property specifies the conditions under which the selected source file will be copied to the output directory.
Select Do not copy if the file is never to be copied to the output directory. Select Copy always if the file is always
to be copied to the output directory. Select Copy if newer if the file is to be copied only when it is newer than an
existing file of the same name in the output directory.
Package Action
The Package Action property indicates what Visual Studio does with a file when a build is executed. Package
Action can have one of several values:
None - The file is not included in the package manifest. An example is a text file that contains
documentation, such as a Readme file.
Content - The file is included in the package manifest. For example, this setting is the default value for an
.htm, .js, .css, image, audio, or video file.
Manifest – The file is not included in the package manifest. Instead, the file is used for input when
generating the package manifest. This is the default value for the package.appxmanifest file.
Resource - The file is not included in the package manifest. Instead, the contents of the file are indexed in
the Package Resource Index (PRI) that goes into the package manifest. It is typically used for resource files.
The default value for Package Action depends on the extension of the file that you add to the solution.
File Name Property
Displays the file name as a read-only value. To rename the file, you must right-click in Solution Explorer and select
Rename .
Full Path Property
Displays the full path to the file as a read-only value. To change the path of the file, you can drag-and-drop the file
in Solution Explorer.

Reference File Properties


This section describes properties common to files referenced from a Windows Store app built for Windows using
JavaScript. When you select a reference such as a .winmd file, an SDK reference, a project-to-project reference, or an
assembly reference in Solution Explorer, other properties may display in the Properties window, according to the
file type.
Culture
Displays the language associated with the reference.
File Type
Displays the file type of the reference.
File Version
Displays the file version of the reference.
Identity
Displays the identity of the reference that is used in the project, which is stored in the project file.
Package
Displays the name of the package manifest associated with the reference.
Resolved Path
Displays the path to the reference that is used in the project.
SDK Path
Displays the path to the referenced SDK file.
Uri
Displays the URI that must be included in the project’s HTML or JavaScript files to include the file as a source file.
Version
Displays the version of the reference.

See Also
NIB: Project Properties (Visual Studio)
Go To Line
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This dialog box allows you to move to a specific line in the active document. To access this dialog box, open a
document for editing, then select Go To on the Edit menu.
Line number (1 - n ) Allows you to enter the number of the line in the active document to which you want to
move. The number entered must fall between 1 and n , the number of lines in the current document.

See Also
Setting Bookmarks in Code Finding and Replacing Text Writing Code
Immediate Window
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Immediate window is used to debug and evaluate expressions, execute statements, print variable values, and
so forth. It allows you to enter expressions to be evaluated or executed by the development language during
debugging. To display the Immediate window, open a project for editing, then choose Windows from the
Debug menu and select Immediate , or press CTRL+ALT+I.
You can use this window to issue individual Visual Studio commands. The available commands include
EvaluateStatement , which can be used to assign values to variables. The Immediate window also supports
IntelliSense.

Displaying the Values of Variables


This window can be particularly useful while debugging an application. For example, to check the value of a
variable varA , you can use the Print Command:

>Debug.Print varA

The question mark (?) is an alias for Debug.Print , so this command can also be written:

>? varA

Both versions of this command will return the value of the variable varA .

NOTE
To issue a Visual Studio command in the Immediate window, you must preface the command with a greater than sign (>).
To enter multiple commands, switch to the Command window.

Design Time Expression Evaluation


You can use the Immediate window to execute a function or subroutine at design time.
To execute a function at design time
1. Copy the following code into a Visual Basic console application:
Module Module1

Sub Main()
MyFunction(5)
End Sub

Function MyFunction(ByVal input as Integer) As Integer


Return input * 2
End Function

End Module

2. On the Debug menu, click Windows , and then click Immediate .


3. Type ?MyFunction(2) in the Immediate window and press Enter.
The Immediate window will run MyFunction and display 4 .
If the function or subroutine contains a breakpoint, Visual Studio will break execution at the appropriate
point. You can then use the debugger windows to examine your program state. For more information see
Walkthrough: Debugging at Design Time.
You cannot use design time expression evaluation in project types that require starting up an execution
environment, including Visual Studio Tools for Office projects, Web projects, Smart Device projects, and
SQL projects.
Design Time Expression Evaluation in Multi-Project Solutions
When establishing the context for design time expression evaluation, Visual Studio references the currently
selected project in Solution Explorer. If no project is selected in Solution Explorer, Visual Studio attempts to
evaluate the function against the startup project. If the function cannot be evaluated in the current context, you
will receive an error message. If you are attempting to evaluate a function in a project that is not the startup
project for the solution and you receive an error, try selecting the project in Solution Explorer and attempt the
evaluation again.

Entering Commands
You must enter the greater than sign (>) when issuing Visual Studio commands in the Immediate window. Use
the UP ARROW and DOWN ARROW keys to scroll through previously issued commands.

TA SK SO L UT IO N EXA M P L E

Evaluate an expression. Preface the expression with a question ? a+b


mark (?).

Temporarily enter Command mode Enter the command, prefacing it with a >alias
while in Immediate mode (to execute a greater than sign (>).
single command).

Switch to the Command window. Enter cmd into the window, prefacing >cmd
it with a greater than sign (>).

Switch back to the Immediate window. Enter immed into the window without immed
the greater than sign (>).

Mark Mode
When you click on any previous line in the Immediate window, you shift automatically into Mark mode. This
allows you to select, edit, and copy the text of previous commands as you would in any text editor, and paste them
into the current line.

The Equals (=) Sign


The window used to enter the EvaluateStatement command determines whether an equals sign (=) is interpreted
as a comparison operator or as an assignment operator.
In the Immediate window, an equals sign (=) is interpreted as an assignment operator. So, for example, the
command

>Debug.EvaluateStatement(varA=varB)

will assign to variable varA the value of variable varB .


In the Command window, by contrast, an equals sign (=) is interpreted as a comparison operator. You cannot use
assignment operations in the Command window. So, for example, if the values of variables varA and varB are
different, then the command

>Debug.EvaluateStatement(varA=varB)

will return a value of False .

First-Chance Exception Notifications


In some settings configurations, first-chance exception notifications are displayed in the Immediate window.
To toggle first-chance exception notifications in the Immediate window
1. On the View menu, click Other Windows , and click Output .
2. Right-click on the text area of the Output window, and select or deselect Exception Messages .

See Also
Navigating through Code with the Debugger Command Window Debugging in Visual Studio Debugger Basics
Walkthrough: Debugging at Design Time Visual Studio Command Aliases Using Regular Expressions in Visual
Studio
Miscellaneous Files
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You might want to use the Visual Studio editors to work independently on files from a project or from a solution.
While you have a solution open, you can open and modify files without adding them to a solution or to a project.
Files you want to work with independently from the containers are called miscellaneous files. Miscellaneous files
are external to solutions and projects, are not included in builds, and cannot be included with a solution under
source control.
Opening files independently from a container is useful for a variety of reasons. You might have a file that you want
to view while developing a project-based solution but that is not integral to the solution's development. Common
examples include development notes or instructions, database schema, and code clips. In addition, you might want
to create a stand-alone file.

Solution Explorer can display a Miscellaneous Files folder for the files if the options for the folder are enabled. The
options can be set from the Documents, Environment, Options Dialog Box. After you close a miscellaneous file, it is
not associated with any particular solution or project unless an option is enabled for that as well.
The Miscellaneous Files folder represents the files as links. Although this folder is not part of a solution, when you
open a solution, some or all of the miscellaneous files that were opened when the solution was last closed are re-
opened, depending upon the settings for the folder.

NOTE
Some of the files that do not appear in the Miscellaneous Files folder are files that you cannot modify within the IDE, such as
.zip files and .doc files. The IDE will not track files that can only be modified through an external editor.

Commands Available in the IDE


The menus, toolbars, and the commands they contain change based on the format of the file you open. When you
open a text file, for example, the Text Editor toolbar appears and its commands are available. If you then open an
XML Schema file, the XML Schema toolbar appears. While editing your XML Schema, the Text Editor toolbar's
commands (or the toolbar itself) are unavailable. The XML Schema is the active window and as such, has current
selection context. When you switch between a project file and a miscellaneous file, all project-related commands
disappear and only those that are directly related to the miscellaneous file appear.
Folder Display Options
You can set display options for the Miscellaneous Folder so that the folder appears even though you have not
opened any Miscellaneous Files. The solution file does not permanently manage a list of miscellaneous files. It uses
an optional feature that allows it to remember a per-user most recently used (MRU) list of files.

See Also
Solutions and Projects Documents, Environment, Options Dialog Box
Options Dialog Box (Visual Studio)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Options dialog box enables you to configure the integrated development environment (IDE) to your needs.
For example, you can establish a default save location for your projects, alter the default appearance and behavior
of windows, and create shortcuts for commonly used commands. There are also options specific to your
development language and platform. You can access Options from the Tools menu.

NOTE
The options available in dialog boxes, and the names and locations of menu commands you see, might differ from what is
described in Help depending on your active settings or edition. To change your settings, choose Impor t and Expor t
Settings on the Tools menu. For more information, see Customizing Development Settings in Visual Studio.

Layout of the Options dialog box


The Options dialog box is divided into two parts: a navigation pane on the left and a display area on the right. The
tree control in the navigation pane includes folder nodes, such as Environment, Text Editor, Projects and Solutions,
and Source Control. Expand any folder node to list the pages of options that it contains. When you select the node
for a particular page, its options appear in the display area.
Options for an IDE feature do not appear in the navigation pane until the feature is loaded into memory. Therefore,
the same options might not be displayed as you begin a new session that were displayed as you ended the last.
When you create a project or run a command that uses a particular application, nodes for relevant options are
added to the Options dialog box. These added options will then remain available as long as the IDE feature
remains in memory.

NOTE
Some settings collections scope the number of pages that appear in the navigation pane of the Options dialog box. You can
choose to view all possible pages by selecting Show all settings .

How options are applied


Clicking OK in the Options dialog box saves all settings on all pages. Clicking Cancel on any page cancels all
change requests, including any just made on other Options pages. Some changes to option settings, such as
those made on Fonts and Colors, Environment, Options Dialog Box, will only take effect after you close and reopen
Visual Studio.
Show all settings
Selecting or unselecting Show all settings applies all changes you have made in the Options dialog box, even
though you have not yet clicked OK .
See Also
Customizing the Editor
Environment Options Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can use the pages in the Environment folder in the Options dialog box to set how certain elements of the
integrated development environment (IDE) display and behave. You can access the Environment pages by, on the
menu bar, choosing Tools , Options , and then selecting Environment .

NOTE
The dialog boxes and menu commands that appear on your computer might differ from those that are described in Help,
depending on your active settings and the edition of Visual Studio that you are using. To change your settings, choose
Impor t and Expor t Settings on the Tools menu. For more information, see Customizing Development Settings in
Visual Studio.

F O R IN F O RM AT IO N A B O UT H O W TO SEE

Customize the appearance and behavior of windows, menus, General, Environment, Options Dialog Box
and other elements of the IDE.

Specify security for add-ins. Add-in Security, Environment, Options Dialog Box

Change the settings for automatic saving and restoration of AutoRecover, Environment, Options Dialog Box
files.

Establish document display and management settings that Documents, Environment, Options Dialog Box
include the behavior of Miscellaneous files.

Customize how updates occur and how extensions are Extensions and Updates, Environment, Options Dialog Box
managed.

Customize when message boxes appear and how the Find Find and Replace, Environment, Options Dialog Box
and Replace window acts during a Quick Find or Quick
Replace, and also auto-populate Find What.

Set the font and color in certain editors, dialog boxes, tools Fonts and Colors, Environment, Options Dialog Box
windows, and other user interface (UI) elements.

Customize the location of vssettings files that store user Import and Export Settings, Environment, Options Dialog
setting information. Box

Select a default language for Visual Studio. International Settings, Environment, Options Dialog Box

To set keyboard mapping options. Keyboard, Environment, Options Dialog Box


F O R IN F O RM AT IO N A B O UT H O W TO SEE

To specify whether notifications are enabled. Notifications, Environment, Options Dialog Box

To specify options for Quick Launch window. Quick Launch, Environment, Options Dialog Box

To specify start page options. Startup, Environment, Options Dialog Box

To specify whether to roam settings across machines. Synchronized Settings, Environment, Options Dialog Box

Learn how to set options for tasks and task lists Task List, Environment, Options Dialog Box

Change your default Home and Search pages, changing the Web Browser, Environment, Options Dialog Box
system source editor, and configuring Internet Explorer
options.

See Also
Options Dialog Box
General, Environment, Options Dialog Box
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use this page to change color themes, status bar settings, and file extension associations, among other options,
for the integrated development environment (IDE). You can access the Options dialog box by opening the Tools
menu, choosing Options , opening the Environment folder and then choosing the General page. If this page
does not appear in the list, select the Show all settings check box in the Options dialog box.

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active
settings or edition. To change your settings, open the Tools menu, and then choose Impor t and Expor t Settings . For
more information, see Customizing Development Settings in Visual Studio.

Visual Experience
Color theme Choose the Blue , Light or Dark color theme for the IDE.
You can install additional predefined themes, and create custom themes, by downloading and installing the
Visual Studio 2015 Color Theme Editor from the Visual Studio Marketplace. After you install this tool,
additional color themes appear in the Color theme list box.
Apply title casing in menu bar Menus are in Title Casing by default in Visual Studio 2015. Un-check this option
to set them to ALL CAPS .
Automatically adjust visual experience based on client performance Specifies whether Visual Studio sets
the adjustment to the visual experience automatically or you set the adjustment explicitly. This adjustment may
change the display of colors from gradients to flat colors, or it may restrict the use of animations in menus or
popup windows.
Enable rich client experience Enables the full visual experience of Visual Studio, including gradients and
animations. Clear this option when using Remote Desktop connections or older graphics adapters, because these
features may have poor performance in those cases. This option is available only when you clear the
Automatically adjust visual experience based on client option.
Use hardware graphics acceleration if available Uses hardware graphics acceleration if it is available,
rather than software acceleration.

Other
Items shown in Window menu Customizes the number of windows that appear in the Windows list of the
Window menu. Type a number between 1 and 24. By default, the number is 10.
Items shown in recently used lists Customizes the number of most recently used projects and files that
appear on the File menu. Type a number between 1 and 24. By default, the number is 10. This is an easy way to
retrieve recently used projects and files.
Show status bar Displays the status bar. The status bar is located at the bottom of the IDE window and displays
information about the progress of ongoing operations.
Close button affects active tool window only Specifies that when the Close button is clicked, only the tool
window that has focus is closed and not all of the tool windows in the docked set. By default, this option is
selected.
Auto Hide button affects active tool window only Specifies that when the Auto Hide button is clicked,
only the tool window that has focus is hidden automatically and not all of the tool windows in the docked set. By
default, this option is not selected.
Manage File Associations Displays the Windows Set Program Associations dialog box, where you can
view file extensions for items that are typically associated with Visual Studio and the current default program for
opening each type of file. To make Visual Studio the default application for types of files that are not already
associated with it, choose the file extension, and then choose Save .
This option can be useful if you have two versions of Visual Studio installed on the same computer and you later
uninstall one of the versions. After you uninstall, the icons for Visual Studio files no longer appear in File Explorer.
In addition, Windows no longer recognizes Visual Studio as the default application for editing these files. This
option restores those associations.

See Also
Environment Options Dialog Box Customizing window layouts
AutoRecover, Environment, Options Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use this page of the Options dialog box to specify whether or not files are automatically backed up. This page also
allows you to specify whether or not modified files are restored when the integrated development environment
(IDE) shuts down unexpectedly. You can access this dialog box by selecting the Tools menu and choosing Options ,
and then selecting the Environment folder and choosing the AutoRecover page. If this page does not appear in
the list, select Show all setting in the Options dialog box.

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

Save AutoRecover information ever y <n> minutes Use this option to customize how often a file is
automatically saved in the editor. For previously saved files, a copy of the file is saved in \...\My Documents\Visual
Studio <version>\Backup Files\<projectname>. If the file is new and has not been manually saved, the file is auto-
saved using a randomly generated file name.
Keep AutoRecover information for <n> days Use this option to specify how long Visual Studio keeps files
created for autorecovery.

See Also
Options Dialog Box
Documents, Environment, Options Dialog Box
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use this page of the Options dialog box to control the display of documents in the integrated development
environment (IDE) and manage external changes to documents and files. You can access this dialog box by clicking
Options on the Tools menu and then selecting Documents in the Environment node. If Documents does not
appear in the list, select Show all settings in the Options dialog box.

NOTE
The options available in dialog boxes, and the names and locations of menu commands you see, might differ from what is
described in Help depending on your active settings or edition. To change your settings, choose Impor t and Expor t
Settings on the Tools menu. For more information, see Customizing Development Settings in Visual Studio.

Reuse current document window, if saved When selected, closes your current document if it has been saved,
and opens a new document in the same window. If your current document has not been saved, it remains open
and the new document is opened in a separate window. When this option is cleared, new documents always open
in separate windows.
If you perform multi-document cut and paste operations infrequently and want to minimize the number of open
documents and windows in your working space, try this option.
Detect when file is changed outside the environment When this option is selected, a message immediately
notifies you of changes to an open file that have been made by an editor outside the IDE. The message lets you
reload the file from storage.
Auto-load changes, if saved When you have Detect when file is changed outside the environment
selected and an open file in the IDE changes outside the IDE, a warning message is generated by default. If this
option is enabled, no warning appears and the document is reloaded in the IDE to pick up the external changes.
Allow editing of read-only files; warn when attempt to save When this option is enabled you can open and
edit a read-only file. When you are finished, you must use the Save As command to save the file by a new name if
you want to save a record of your changes.
Open file using director y of currently active document When selected, this option specifies that the Open
File dialog box displays the directory of the active document. When this option is cleared, the Open File dialog
box displays the directory last used to open a file.
Check for consistent line endings on load Select this option to have the editor scan the line endings in a file
and display a message box if inconsistencies are detected in how line endings are formatted.
Display warning when global undo will modify edited files Select this option to display a message box
when the Global Undo command will roll back refactoring changes made in files that also were changed after the
refactoring operation. Returning a file to its pre-refactoring state might discard subsequent changes made in the
file.
Show Miscellaneous files in Solution Explorer Select this option to display the Miscellaneous Files node in
Solution Explorer . Miscellaneous files are files that are not associated with a project or solution but can appear
in Solution Explorer for your convenience.

NOTE
Select this option to enable the View in Browser command on the File menu for Web documents not included in the
active Web application.

< n > items saved in the Miscellaneous files project Specifies the number of files to persist in the
MiscellaneousFiles folder of Solution Explorer . These files are listed even if they are no longer open in an
editor. You can specify any whole number from 0 to 256. The default number is 0.
For example, if you set this option to 5 and have 10 miscellaneous files open, when you close all 10 files, the first 5
will still be shown in the Miscellaneous Files folder.
Save documents as Unicode when data cannot be saved in codepage Select this option to cause files
containing information incompatible with the selected codepage to be saved as Unicode by default.

See Also
Environment Options Dialog Box Miscellaneous Files Finding and Replacing Text
Extensions and Updates, Environment, Options
Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use this page to set options for how Visual Studio performs updates and how extensions are updated and
discovered.
Automatically check for updates
When checked, Visual Studio will check periodically for updates to itself, installed SDKs and tools, and extensions,
and display notifications in the menu bar when updates are available. For more information, see Notifications.
Automatically update extensions
When checked, updates to extensions are made without prompting. For more information, see Finding and Using
Visual Studio Extensions.
Load user extensions when running as administrator
For more information, see Finding and Using Visual Studio Extensions.
Additional Extension Galleries
An Enterprise feature that enables support for galleries of proprietary extensions. For more information, see
Private Galleries.

See Also
Environment Options Dialog Box
Find and Replace, Environment, Options Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use this page of the Options dialog box to control message boxes and other aspects of a find and replace
operation. You can access this dialog box from the Tools menu by clicking Options , expanding Environment , and
then clicking Find and Replace . If this page does not appear in the list, select Show all setting in the Options
dialog box.

NOTE
The options available in dialog boxes, and the names and locations of menu commands you see, might differ from what is
described in Help depending on your active settings or edition. To change your settings, choose Impor t and Expor t
Settings on the Tools menu. For more information, see Customizing Development Settings in Visual Studio.

UIElement List
Display informational messages Select this option to display all Find and Replace informational messages that
have the Always show this message option. For example, if you chose not to display the message "Find reached
the starting point of the search.", selecting this option would cause this informational message to appear again
when you use Find and Replace.
If you do not want to see any informational messages for Find and Replace, clear this option.
When you have cleared the Always show this message option on some, but not all, Find and Replace
informational messages, the Display informational messages check box appears to be filled but not selected. To
restore all optional Find and Replace messages, clear this option and then select it again.

NOTE
This option does not affect any Find and Replace informational messages that do not display the Always show this
message option.

Display warning messages Select this option to display all cautionary Find and Replace messages that have the
Always show this message option. For example, if you chose not to display the Replace All warning message
that appears when you attempt to make replacements in files not currently opened for editing, selecting this option
would cause this warning message to appear again when you attempt to Replace All.
If you do not want to see any cautionary messages for Find and Replace, clear this option.
When you have cleared the Always show this message option on some, but not all, Find and Replace warning
messages, the Display warning messages check box appears to be filled but not selected. To restore all optional
Find and Replace messages, clear this option and then select it again.
NOTE
This option does not affect any Find and Replace warning messages that do not display the Always show this message
option.

Automatically populate Find What with text from the editor Select this option to paste the text on either
side of the current editor's insertion point into the Find what field when you select any view of the Find and
Replace window from the Edit menu. Clear this option to use the last search pattern from the previous search as
the Find what string.

See Also
Finding and Replacing Text
Fonts and Colors, Environment, Options Dialog Box
10/18/2019 • 16 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Fonts and Colors page of the Options dialog box lets you establish a custom font and color scheme for
various user interface elements in the integrated development environment (IDE). You can access this dialog box
by clicking Tools / Options , and then selecting Environment / Fonts and Colors . If this page does not appear
in the list, select Show all settings in the Options dialog box.

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

Color scheme changes do not take effect during the session in which you make them. You can evaluate color
changes by opening another instance of Visual Studio and producing the conditions under which you expect your
changes to apply.
Show settings for Lists all of the user interface elements for which you can change font and color schemes.
After selecting an item from this list you can customize color settings for the item selected in Display items .
Text Editor
Changes to font style, size, and color display settings for Text Editor affect the appearance of text in your
default text editor. Documents opened in a text editor outside the IDE will not be affected by these settings.
Printer
Changes to font style, size, and color display settings for Printer affect the appearance of text in printed
documents.

NOTE
As needed, you can select a different default font for printing than that used for display in the text editor. This can
be useful when printing code that contains both single-byte and double-byte characters.

Statement Completion
Changes the font style and size for the text that appears in statement completion pop-up in the editor.
Editor Tooltip
Changes the font style and size for the text that appears in ToolTips displayed in the editor.
Environment Font
Changes the font style and size for all IDE user interface elements that do not already have a separate
option in Show settings for. For example, this option applies to the Star t Page but would not affect the
Output window.
[All Text Tool Windows]
Changes to font style, size, and color display settings for this item affect the appearance of text in tool
windows that have output panes in the IDE. For example, Output window, Command window, Immediate
window, etc.

NOTE
Changes to the text of [All Text Tool Windows] items do not take effect during the session in which you make
them. You can evaluate such changes by opening another instance of Visual Studio.

Use Defaults Resets the font and color values of the list item selected in Show settings for . The Use
button appears when other display schemes are available for selection. For example, you can choose from
two schemes for the Printer.
Font (bold type indicates fixed-width fonts) Lists all the fonts installed on your system. When the
drop-down menu first appears, the current font for the element selected in the Show settings for field is
highlighted. Fixed fonts — which are easier to align in the editor — appear in bold.
Size Lists available point sizes for the highlighted font. Changing the size of the font affects all Display
items for the Show settings for selection.
Display items Lists the items for which you can modify the foreground and background color.

NOTE
Plain Text is the default display item. As such, properties assigned to PlainText will be overridden by properties assigned
to other display items. For example, if you assign the color blue to PlainText and the color green to Identifier , all
identifiers will appear in green. In this example, Identifier properties override PlainText properties.

Some of display items include:

DISP L AY IT EM DESC RIP T IO N

Plain Text Text in the editor.

Selected Text Text that is included in the current selection when the editor
has focus.

Inactive Selected Text Text that is included in the current selection when the editor
has lost focus.

Indicator Margin The margin at the left of the Code Editor where breakpoints
and bookmark icons are displayed.

Line Numbers Optional numbers that appear next to each line of code

Visible White Space Spaces, tabs and word wrap indicators

Bookmark Lines that have bookmarks. Bookmark is only visible if the


indicator margin is disabled.
DISP L AY IT EM DESC RIP T IO N

Brace Matching (Highlight) Highlighting that is typically bold formatting for matching
braces.

Brace Matching (Rectangle) Highlighting that is typically a grey rectangle in the


background.

Breakpoint (Disabled) Not used.

Breakpoint (Enabled) Specifies the highlight color for statements or lines containing
simple breakpoints. This option is applicable only if
statement-level breakpoints are active or the Highlight
entire source line for breakpoints or current
statement option is selected on General, Debugging,
Options Dialog Box.

Breakpoint (Error) Specifies the highlight color for statements or lines containing
breakpoints that are in an error state. Applicable only if
statement-level breakpoints are active or the Highlight
entire source line for breakpoints or current
statement option is selected on General, Debugging,
Options Dialog Box.

Breakpoint (Warning) Specifies the highlight color for statements or lines containing
breakpoints that are in a warning state. Applicable only if
statement-level breakpoints are active or the Highlight
entire source line for breakpoints or current
statement option is selected on General, Debugging,
Options Dialog Box.

Breakpoint - Advanced (Disabled) Specifies the highlight color for statements or lines containing
disabled conditional or hit-counted breakpoints. Applicable
only if statement-level breakpoints are active or the
Highlight entire source line for breakpoints or
current statement option is selected on General,
Debugging, Options Dialog Box.

Breakpoint - Advanced (Enabled) Specifies the highlight color for statements or lines containing
conditional or hit-counted breakpoints. Applicable only if
statement-level breakpoints are active or the Highlight
entire source line for breakpoints or current
statement option is selected on General, Debugging,
Options Dialog Box.

Breakpoint - Advanced (Error) Specifies the highlight color for statements or lines containing
conditional or hit-counted breakpoints that are in an error
state. Applicable only if statement-level breakpoints are active
or the Highlight entire source line for breakpoints or
current statement option is selected on General,
Debugging, Options Dialog Box.

Breakpoint - Advanced (Warning) Specifies the highlight color for statements or lines containing
conditional or hit-counted breakpoints that are in a warning
state. Applicable only if statement-level breakpoints are active
or the Highlight entire source line for breakpoints or
current statement option is selected on General,
Debugging, Options Dialog Box.
DISP L AY IT EM DESC RIP T IO N

Breakpoint - Mapped (Disabled) Specifies the highlight color for statements or lines containing
disabled mapped breakpoints. Applicable for ASP or ASP.NET
debugging if statement-level breakpoints are active or the
Highlight entire source line for breakpoints or
current statement option is selected on General,
Debugging, Options Dialog Box.

Breakpoint - Mapped (Enabled) Specifies the highlight color for statements or lines containing
mapped breakpoints. Applicable for ASP or ASP.NET
debugging if statement-level breakpoints are active or the
Highlight entire source line for breakpoints or
current statement option is selected on General,
Debugging, Options Dialog Box.

Breakpoint - Mapped (Error) Specifies the highlight color for statements or lines containing
mapped breakpoints in an error state. Applicable for ASP or
ASP.NET debugging if statement-level breakpoints are active
or the Highlight entire source line for breakpoints or
current statement option is selected on General,
Debugging, Options Dialog Box.

Breakpoint - Mapped (Warning) Specifies the highlight color for statements or lines containing
mapped breakpoints in a warning state. Applicable for ASP or
ASP.NET debugging if statement-level breakpoints are active
or the Highlight entire source line for breakpoints or
current statement option is selected on General,
Debugging, Options Dialog Box.

C/C++ User Keywords A constant within a particular code file defined by means of
the #define directive.

Call Return Specifies the highlight color for source statements or lines
that indicate call return points when context is switched to a
non-top stack frame when debugging.

Code Snippet Dependent Field A field that will be updated when the current editable field is
modified.

Code Snippet Field Editable field when a code snippet is active.

Collapsible Text A block of text or code that can be toggled in and out of view
within the Code Editor.

Comment Code comments.

Compiler Error Blue squiggles in the editor indicating a compiler error.

Coverage Not Touched Area Code that has not been covered by a unit test.

Coverage Par tially Touched Area Code that has been partially covered by a unit test.

Coverage Touched Area Code that has been completely covered by a unit test.
DISP L AY IT EM DESC RIP T IO N

CSS Comment A comment in Cascading Style Sheets. For example:

/* comment */

CSS Keyword Keywords in the Cascading Style Sheet.

CSS Proper ty Name The name of a property, such as Background.

CSS Proper ty Value The value assigned to a property such as blue.

CSS Selector A string that identifies what elements the corresponding rule
applies to. A selector can either be a simple selector, such a
'H1', or a contextual selector, such as 'H1 B', which consists of
several simple selectors.

CSS String Value A string in Cascading Style Sheets.

Current list location Current line navigated to in a list tool window, such as the
Output window or Find Results windows.

Current Statement Specifies the highlight color for the source statement or line
that indicates the current step position when debugging.

Debugger Data Changed The color of text used to display changed data inside the
Registers and Memor y windows.

Definition Window Background The background color of the Code Definition window.

Definition Window Current Match The current definition in the Code Definition window.

Disassembly File Name The color of text used to display file name breaks inside the
Disassembly window.

Disassembly Source The color of text used to display source lines inside the
Disassembly window.

Disassembly Symbol The color of text used to display symbol names inside the
Disassembly window.

Disassembly Text The color of text used to display op-code and data inside the
Disassembly window.

Excluded Code Code that is not to be compiled, per a conditional


preprocessor directive such as #if .

Identifier Identifiers in code such as the class names, methods names,


and variable names.

Keyword Keywords for the given language that are reserved. For
example: class and namespace.

Memor y Address The color of text used to display the address column inside
the Memor y window.
DISP L AY IT EM DESC RIP T IO N

Memor y Changed The color of text used to display changed data inside the
Memor y window.

Memor y Data The color of text used to display data inside the Memor y
window.

Memor y Unreadable The color of text used to display unreadable memory areas
within the Memor y window.

Number A number in code that represents an actual numeric value.

Operator Operators such as +, -, and !=.

Other Error Other error types not covered by other error squiggles.
Currently, this includes rude edits in Edit and Continue.

Preprocessor Keyword Keywords used by the preprocessor such as #include.

Read-Only Region Code that cannot be edited. For example code displayed in
the Code Definition View window or code that cannot be
modified during Edit and Continue.

Refactoring Background Background color of the Preview Changes dialog box.

Refactoring Current Field Background color of the current element to be refactored in


the Preview Changes dialog box.

Refactoring Dependent Field Color of references of the element to be refactored in the


Preview Changes dialog box.

Register Data The color of text used to display data inside the Registers
window.

Register NAT The color of text used to display unrecognized data and
objects inside the Registers window.

Smar t Tag Used to denote the outline when smart tags are invoked.

SQL DML Marker Applies to the Transact-SQL editor. DML statements in this
editor are marked with a bounding blue box by default.

Stale Code Superseded code awaiting an update. In some cases, Edit and
Continue cannot apply code changes immediately, but will
apply them later as you continue debugging. This occurs if
you edit a function that must call the function currently
executing, or if you add more than 64 bytes of new variables
to a function waiting on the call stack. When this happens,
the debugger displays a "Stale Code Warning" dialog box, and
the superseded code continues to execute until the function
in question finishes and is called again. Edit and Continue
applies the code changes at that time.

String String literals.


DISP L AY IT EM DESC RIP T IO N

String (C# @ Verbatim) String literals in C# that are interpreted verbatim. For
example:

@"x"

Syntax Error Parse errors.

Task List Shor tcut If a Task List shortcut is added to a line, and the indicator
margin is disabled, the line will be highlighted.

Tracepoint (Disabled) Not used.

Tracepoint (Enabled) Specifies the highlight color for statements or lines containing
simple tracepoints. This option is applicable only if statement-
level tracepoints are active or the Highlight entire source
line for breakpoints or current statement option is
selected on General, Debugging, Options Dialog Box.

Tracepoint (error) Specifies the highlight color for statements or lines containing
tracepoints that are in an error state. This option is applicable
only if statement-level tracepoints are active or the
Highlight entire source line for breakpoints or
current statement option is selected on General,
Debugging, Options Dialog Box.

Tracepoint (Warning) Specifies the highlight color for statements or lines containing
tracepoints that are in a warning state. This option is
applicable only if statement-level tracepoints are active or the
Highlight entire source line for breakpoints or
current statement option is selected on General,
Debugging, Options Dialog Box.

Tracepoint - Advanced (Disabled) Specifies the highlight color for statements or lines containing
disabled conditional or hit-counted tracepoints. This option is
applicable only if statement-level tracepoints are active or the
Highlight entire source line for breakpoints or
current statement option is selected on General,
Debugging, Options Dialog Box.

Tracepoint - Advanced (Enabled) Specifies the highlight color for statements or lines containing
conditional or hit-counted tracepoints. This option is
applicable only if statement-level tracepoints are active or the
Highlight entire source line for breakpoints or
current statement option is selected on General,
Debugging, Options Dialog Box.

Tracepoint - Advanced (Error) Specifies the highlight color for statements or lines containing
conditional or hit-counted tracepoints that are in an error
state. This option is applicable only if statement-level
tracepoints are active or the Highlight entire source line
for breakpoints or current statement option is selected
on General, Debugging, Options Dialog Box.
DISP L AY IT EM DESC RIP T IO N

Tracepoint - Advanced (Warning) Specifies the highlight color for statements or lines containing
conditional or hit-counted tracepoints that are in a warning
state. This option is applicable only if statement-level
tracepoints are active or the Highlight entire source line
for breakpoints or current statement option is selected
on General, Debugging, Options Dialog Box.

Tracepoint - Mapped (Disabled) Specifies the highlight color for statements or lines containing
disabled mapped tracepoints. Applicable for ASP or ASP.NET
debugging if statement-level breakpoints are active or the
Highlight entire source line for breakpoints or
current statement option is selected on General,
Debugging, Options Dialog Box.

Tracepoint - Mapped (Enabled) Specifies the highlight color for statements or lines containing
mapped tracepoints. Applicable for ASP or ASP.NET
debugging if statement-level breakpoints are active or the
Highlight entire source line for breakpoints or
current statement option is selected on General,
Debugging, Options Dialog Box.

Tracepoint - Mapped (Error) Specifies the highlight color for statements or lines containing
mapped tracepoints in an error state. Applicable for ASP or
ASP.NET debugging if statement-level breakpoints are active
or the Highlight entire source line for breakpoints or
current statement option is selected on General,
Debugging, Options Dialog Box.

Tracepoint - Mapped (Warning) Specifies the highlight color for statements or lines containing
mapped tracepoints in a warning state. Applicable for ASP or
ASP.NET debugging if statement-level breakpoints are active
or the Highlight entire source line for breakpoints or
current statement option is selected on General,
Debugging, Options Dialog Box.

Track Changes after save Lines of code that have been modified since the file was
opened but are saved to disk.

Track Changes before save Lines of code that have been modified since the file was
opened but are not saved to disk.

User Types Types defined by users.

User Types (Delegates) Type color for delegates.

User Types (Enums) Type color used for enums.

User Types (Interfaces) Type color for interfaces.

User Types (Value types) Type color for value types such as structs in C#.

Visual Basic Read Only Marker A marker specific to Visual Basic used for designating EnC,
such as exception regions, a method definition, and non-leaf
call frames.
DISP L AY IT EM DESC RIP T IO N

Warning Compiler warnings.

Warning Lines Path Used for Static Analysis warning lines.

XML Attribute Attribute names.

XML Attribute Quotes The quote characters for XML attributes.

XML Attribute Value Contents of XML attributes.

XML Cdata Section Contents of <![CDATA[…]]>.

XML Comment The contents of <!-- -->.

XML Delimiter XML Syntax delimiters, including <, <?, <!, <!--, -->, ?>, <![,
]]>, and [, ].

XML Doc Attribute The value of an xml documentation attribute, such as <param
name="I"> where the "I" is colorized.

XML Doc Comment The comments enclosed in the xml documentation


comments.

XML Doc Tag The tags in XML doc comments, such as

/// <summary>.

XML Keyword DTD keywords such as CDATA, IDREF, and NDATA.

XML Name Element names and Processing Instructions target name.

XML Processing Instruction Contents of Processing Instructions, not including target


name.

XML Text Plain text element content.

XSLT Keyword XSLT element names.

Item foreground Lists the available colors you can choose for the foreground of the item selected in Display
items . Because some items are related, and should therefore maintain a consistent display scheme, changing the
foreground color of text also changes the defaults for elements such as Compiler Error, Keyword, or Operator.
Automatic Items can inherit the foreground color from other display items such as Plain Text . Using this option,
when you change the color of an inherited display item, the color of the related display items also change
automatically. For example, if you selected the Automatic value for Compiler Error and later changed the color
of Plain Text to Red, Compiler Error would also automatically inherit the color Red.
Default The color that appears for the item the first time you start Visual Studio. Clicking the Use Defaults
button resets to this color.
Custom Displays the Color dialog box to allow you to set a custom color for the item selected in the Display
items list.
NOTE
Your ability to define custom colors may be limited by the color settings for your computer display. For example, if your
computer is set to display 256 colors and you select a custom color from the Color dialog box, the IDE defaults to the
closest available Basic color and displays the color black in the Color preview box.

Item background Provides a color palette from which you can choose a background color for the item selected
in Display items . Because some items are related, and should therefore maintain a consistent display scheme,
changing the background color of text also changes the defaults for elements such as Compiler Error, Keyword, or
Operator.
Automatic Items can inherit the background color from other display items such as Plain Text . Using this option,
when you change the color of an inherited display item, the color of the related display items also change
automatically. For example, if you selected the Automatic value for Compiler Error and later changed the color
of Plain Text to Red, Compiler Error would also automatically inherit the color Red.
Default The color that appears for the item the first time you start Visual Studio. Clicking the Use Defaults
button resets to this color.
Custom Displays the Color dialog box to allow you to set a custom color for the item selected in the Display
items list.
Bold Select this option to display the text of selected Display items in bold text. Bold text is easier to identify in
the editor.
Sample Displays a sample of the font style, size, and color scheme for the Show settings for and Display
items selected. You can use this box to preview the results as you experiment with different formatting options.

See Also
Environment Options Dialog Box Options Dialog Box How to: Change Fonts and Colors
Import and Export Settings, Environment, Options
Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use this page to specify where your user settings file is saved and whether to use a team settings file. For more
information about settings, see Customizing Development Settings in Visual Studio.

See Also
Environment Options Dialog Box
International Settings, Environment, Options Dialog
Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The International Settings page allows you to change the default language when you have more than one language
version of the integrated development environment (IDE) installed on your machine. You can access this dialog box
by selecting Options from the Tools menu and then choosing International Settings from the Environment
folder. If this page does not appear in the list, select Show all settings in the Options dialog box.

NOTE
The options available in dialog boxes, and the names and locations of menu commands you see, might differ from what is
described in Help depending on your active settings or edition. To change your settings, choose Impor t and Expor t
Settings on the Tools menu. For more information, see Customizing Development Settings in Visual Studio.

Language Lists the available languages for the installed product language versions. This option is unavailable
unless you have more than one language version installed on your machine. If multiple languages of products or a
mixed language installation of products share the environment, the language selection is changed to Same as
Microsoft Windows .
Cau t i on

In a system with multiple languages installed, the Visual C++ build tools (cl.exe, link.exe, nmake.exe, bscmake.exe
and related files) are not affected by this setting. These tools use the version for last language installed and the
tools for the previously installed language are overwritten because the Visual C++ build tools do not use the
satellite DLL model.

See Also
Environment Options Dialog Box
Keyboard, Environment, Options Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use this page to set keyboard mappings. For more information about mappings, see Identifying and Customizing
Keyboard Shortcuts.

See Also
Environment Options Dialog Box
Notifications, Environment, Options Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use this option to stop ignoring any notifications that you previously chose to ignore through the Notifications
dialog. For more information, see Notifications.

See Also
Environment Options Dialog Box
Quick Launch, Environment, Options Dialog Box
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can use Quick Launch to quickly search and execute actions for IDE assets such as options, templates, menus.
You can't use Quick Launch to search for code and symbols. The Quick Launch search box is located at the top-
right corner of the menu bar and is accessible by choosing the Ctrl+Q keys. Simply enter your search string in the
box. To search for strings that contain @, use '@@'.
Quick Launch is enabled by default when you install Visual Studio. On the menu bar, you can show or hide
Quick Launch by choosing Tools , Options . Expand the Environments node, and then choose Quick Launch .
Select or clear the Enable Quick Launch check box. You can also enable or disable search categories on this
page.

Category List
Quick Launch search results appear in four categories: Most Recently Used , Menus , Options , and Open
Documents , along with the number of items in the category. To traverse through search results by category,
choose the Ctrl+Q keys to show all the results from the next category. After the last category appears, Ctrl+Q
shows you a few results from each category. You can use Ctrl+Shift+Q to navigate through the categories in
reverse order. To view all the search results under a category, choose the category name.
You can use the following shortcuts to limit your search to specific categories.

C AT EGO RY SH O RTC UT SH O RTC UT DESC RIP T IO N

Most recently used @mru Displays up to five of the items that


you Most Recently Used .
For example, @mru font

Menus @menu Limits the search to menu items.

For example, @menu font

Options @opt Limits the search to settings in the


Options dialog box.
For example, @opt font

Documents @doc Limits the search to file names and


paths of open documents for the
For example, @doc font search criteria, but doesn't search the
text inside the files themselves.

NOTE
You can change the shortcut keys on the General, Keyboard page in the Options dialog box.
Show Previous Results
By default, the search term that you enter is not persisted between search sessions. The search string is cleared if
you search for a term, move the cursor outside the Quick Launch area, and then go back. To retain the search
results, go to the Options dialog box, choose Quick Launch , and then select the Show search results from
previous search when Quick Launch is activated. check box. The next time you do a search, leave the Quick
Launch area, and come back, Quick Launch will retain the search term last used and also show you the search
results.
For the most recent tips and tricks for using Quick Launch , see The Visual Studio Blog.

See Also
General User Interface Elements (Visual Studio) Environment Options Dialog Box
Startup, Environment, Options Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use this page to customize the Visual Studio start page or set a different default action when Visual Studio starts
up. For more information, see Customizing the Start Page.

See Also
Environment Options Dialog Box
Synchronized Settings, Environment, Options Dialog
Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use this page to specify whether to synchronize (roam) your settings across multiple machines. For more
information, see Synchronized Settings.

See Also
Environment Options Dialog Box
Tabs and Windows, Environment, Options Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use this page to set options for how tabbed windows behave in the editor pane, and how tool windows behave. For
more information, see How to: Arrange and Dock Windows

See Also
Environment Options Dialog Box
Task List, Environment, Options Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This Options page allows you to add, delete, and change the comment tokens that generate Task List reminders.
To display these settings, select Options from the Tools menu, expand the Environment folder, and choose Task
List .

Task List options


Confirm deletion of tasks When selected, a message box is displayed whenever a User Task is deleted from the
Task List , allowing you to confirm the deletion. This option is selected by default.

NOTE
To delete a Task Comment, use the link to find the comment, and then remove it from your code.

Show file names only When selected, the File column of the Task List displays only the names of files to be
edited, not their full paths.

Tokens
When you insert a comment into your code whose text begins with a token from the Token List , the Task List
displays your comment as new entry whenever the file is opened for editing. You can click this Task List entry to
jump directly to the comment line in your code. For more information, see Using the Task List.
Token List Displays a list of tokens, and allows you to add or remove custom tokens. Comment tokens are case
sensitive in Visual C# and Visual C++, but not in Visual Basic.

NOTE
If you do not type the desired token exactly as it appears in the Token List , a comment task will not be displayed in the
Task List .

Priority Sets the priority of tasks that use the selected token. Task comments that begin with this token are
automatically assigned the designated priority in the Task List .
Name Enter the token string. This enables the Add button. On Add , this string is included in the Token List , and
comments that begin with this name will be displayed in the Task List .
Add Enabled when you enter a new Name . Click to add a new token string using the values entered in the Name
and Priority fields.
Delete Click to delete the selected token from the Token List . You cannot delete the default comment token.
Change Click to make changes to an existing token using the values entered in the Name and Priority fields.
NOTE
You cannot rename or delete the default comment token, but you can change its priority level.

See Also
Using the Task List Setting Bookmarks in Code Environment Options Dialog Box
Web Browser, Environment, Options Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Sets options for both the internal Web browser and Internet Explorer. To access this dialog box, click Options on
the Tools menu, expand the Environment folder, and select Web Browser .

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

IMPORTANT
Opening certain files or components from the Web can execute code on your computer.

Home page Sets the page displayed when you open the IDE Web Browser.
Search page Lets you designate a Search page for the internal Web browser. This location can differ from the
search page used by instances of Internet Explorer initiated outside of the integrated development environment
(IDE).
View Source in Sets the editor used to open a Web page when you choose View Source on the page from the
internal Web browser.
Source editor Select to view source in the Writing Code.
HTML editor Select to view source in the HTML Designer. Use this selection to edit the Web page in one of
two views: Design view or the standard text-based Source view.
External editor Select to view source in another editor. Specify the path of any editor you choose, for
example, Notepad.exe.
Internet Explorer Options Click to change options for Internet Explorer in the Internet Proper ties dialog
box. Changes made in this dialog box affect both the internal Web browser and instances of Internet
Explorer initiated outside of the Visual Studio IDE (for example, from the Start menu).

NOTE
Use the Browse With dialog box to replace the Visual Studio internal Web browser, which is a version of Internet Explorer, by
using a different, external Web browser.

See Also
Environment Options Dialog Box General, Environment, Options Dialog Box HTML Designer
Options Page, Environment Node Properties
1/1/2020 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This document describes the pages (or properties collections) that are associated with the Environment category,
DTE.Properties("Environment", <Property Page>) , of the Options dialog box. The title of each subsection is the call
that is used to access the Properties collection, and the table in each subsection lists the properties in the collection.

General
DTE.Properties("Environment", "General")

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

ShowStatusBar Get/Set (Boolean) Determines whether the status bar is


visible.

WindowMenuContainsNItems Get/Set (Short) Determines how document windows are


contained at the bottom of the
Windows menu.

MRUListContainsNItems Get/Set (Short) Determines how many files display in


the "Most Recently Used" submenu.

Animations Get/Set (Boolean) Determines whether the integrated


development environment (IDE) uses
animation in the status bar.

AnimationSpeed Get/Set (Short)

AutoAdjustExperience Get/Set (Boolean) Automatically adjusts the visual


experience depending on the client
performance.

RichClientExperienceOptions Get/Set (Enum) Enables rich client visual experience with


values in vsRichClientExperienceOptions.

CloseButtonActiveTabOnly Get/Set (Boolean) Determines whether the Close button


is shown only on the active tab.

AutohidePinActiveTabOnly Get/Set (Boolean) Determines whether the Auto Hide


button affects only the active tab.

Add-in/Macros Security
DTE.Properties("Environment", "AddinMacrosSecurity")
P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

MacrosEnabled Get/Set (Boolean) Allows macros to run.

AddinsEnabled Get/Set (Boolean) Allows add-ins to load.

LoadAddinsFromTheWeb Get/Set (Boolean) Allows add-ins to load from a URL on


the Web.

Documents
DTE.Properties("Environment", "Documents")

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

ReuseSavedActiveDocWindow Get/Set (Boolean) Determines whether opening a new file


reuses the current document window if
the current document is saved. false
means always open a new document
window for each document opened.

DetectFileChangesOutsideIDE Get/Set (Boolean) Determines whether the environment


automatically reloads files opened in the
IDE when the operating system notifies
the IDE that the files have been
modified on disk.

AutoloadExternalChanges Get/Set (Boolean) Determines whether detected external


modifications to open documents
automatically reload the modified file if
the open document is not modified. If
the open document is modified and this
property is true , then the IDE
prompts as if this property were
false .

InitializeOpenFileFromCurrentDocumen Get/Set (Boolean) Determines whether the OpenFile


t command seeds the directory and file
name from the last active document, or
from the last place you opened a file.

MiscFilesProjectSavesLastNItems Get/Set (Short) Determines how many files the


Miscellaneous Files project records. As a
result, you can see what you most
recently had open as a miscellaneous
file on disk when you next use the IDE.

ShowMiscFilesProject Get/Set (Boolean) Determines whether the Miscellaneous


Files project is shown.

CheckForConsisentLineEndings Get/Set (Boolean) Checks for consistent line endings on


file load.

SaveDocsAsUnicodeWhenDataLoss Get/Set (Boolean) Saves documents as Unicode when data


cannot be saved in codepage.
P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

DontShowGlobalUndoChangeLossDialo Get/Set (Boolean) Displays a warning when global undo


g will modify other edited files.

AllowEditingReadOnlyFiles Get/Set (Boolean) Allows editing of read-only files, but


give a warning when there is an
attempt to save them.

DocumentDockPreference Get/Set (Enum) vsDocumentDockPreferenceOptions.


Position in the tab well in which to
insert opened document.

Extension Manager
DTE.Properties("Environment", "ExtensionManager")

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

EnableAdminExtensions Get/Set (Boolean) Loads per-user extensions when Visual


Studio is run under Administrator
credentials. Visual Studio must be
restarted after this value is changed.

EnableOnline Get/Set (Boolean) Enables access to extensions on the


Visual Studio Gallery.

AutomaticallyCheckForUpdates Get/Set (Boolean) Automatically checks for updates to


installed extensions.

Find and Replace


DTE.Properties("Environment", "FindAndReplace")

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

ShowWarningMessages Get/Set (Boolean) Displays warning messages.

InitializeFromEditor Get/Set (Boolean) Automatically populates the Find


What box with text from the editor.

ShowMessageBoxes Get/Set (Boolean) Displays informational messages.

HideWindowsAfterMatchFromQuickFin Get/Set (Boolean) Hides the Find and Replace window


dReplace after a match is located by using Quick
Find or Quick Replace .

Import and Export Settings


DTE.Properties("Environment", "Import and Export Settings")

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N


P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

TrackTeamSettings Get/Set (Boolean) Uses the settings in the file specified by


TeamSettingsFile.

TeamSettingsFile Get/Set (String) Name of file that has team settings.

AutoSaveFile Get/Set (String) Name of file where user settings are


automatically saved.

International Settings
DTE.Properties("Environment", "International")

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

Language Get/Set (String) LCID value for the current language for
Visual Studio.

Keyboard
DTE.Properties("Environment", "Keyboard")

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

Scheme Get/Set (String) Returns a string that contains a built-in


scheme, a string containing the full path
of the .vsk file that is loaded, or "
(Default)" if no .vsk file is loaded.

Projects and Solution


DTE.Properties("Environment", "ProjectsAndSolution")

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

OnRunOrPreview Get/Set (String) Determines whether the IDE saves


everything before previewing or
running a built project.

ProjectsLocation Get/Set (String) Determines the default directory where


the Add Project dialog box saves new
projects.

ShowOutputWindowBeforeBuild Get/Set (Boolean) Determines whether starting a build


displays the Output window.

ShowTaskListAfterBuild Get/Set (Boolean) Determines whether an unsuccessful


build operation displays the Task List
when the build is done.

TrackFileSelectionInExplorer Get/Set (Boolean) Determines whether the current item is


tracked in Solution Explorer .
P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

AlwaysShowSolutionNode Get/Set (Boolean) Determines whether the solution node


is displayed.

OnlySaveStartupProjectsAndDependenc Get/Set (Boolean) Determines whether save operations


ies are limited to startup projects and their
dependent files.

ShowAdvancedBuildConfigurations Get/Set (Boolean) Determines whether advanced build


configurations are displayed.

ConcurrentBuilds Get/Set (String) Determines the maximum number of


parallel project builds that can occur.

SaveNewProjects Get/Set (Boolean) Determines whether new projects are


automatically saved after being created.

PromptForRenameSymbol Get/Set (Boolean) Specifies whether to prompt for


symbolic renaming when files are
renamed.

OnRunWhenErrors Get/Set (Enum) Specifies the behavior on Run when a


build completed with errors.

OnRunWhenOutOfDate Get/Set (Enum) Specifies the behavior on Run when a


project is out of date.

ProjectTemplatesLocation Get/Set (String) Directory that contains user project


templates.

ProjectItemTemplatesLocation Get/Set (String) Directory that contains user item


templates.

DefaultBehaviorForStartupProjects Get/Set (String)

MSBuildOutputVerbosity Get/Set (String) Specifies the level of verbosity for Build


output.

Startup
DTE.Properties("Environment", "Startup")

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

OnStartUp Get/Set (Enum) Action to take at startup, from


vsStartUp, with values 0 through 5:

- 0: Open Home Page


- 1: Load last loaded solution
- 2: Show Open Project dialog box
- 3: Show New Project dialog box
- 4: Show empty environment
- 5: Show Start Page
P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

StartPageRSSUrl Get/Set (String) URL for the RSS feed that is used at
startup.

StartPageRefreshDownloadedContent Get/Set (Boolean) Refreshes the Start Page after every


passage of the interval specified in
StartPageRefreshInterval.

StartPageRefreshInterval Get/Set (Short) Interval in minutes to refresh the Start


Page.

TaskList
DTE.Properties("Environment", "TaskList")

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

ConfirmTaskDeletion Get/Set (Boolean) Specifies whether a confirmation box


displays when deleting tasks from the
Task List .

WarnOnAddingHiddenItem Get/Set (Boolean) Specifies whether you are warned when


adding a user task that will not be
shown.

DontShowFilePaths Get/Set (Boolean) Specifies whether to show full file paths


in the Task List.

CommentTokens SafeArray Returns a SafeArray of comment token


values. Each has the fields, Name
(string) and Priority (vsTaskPriority,
High, Medium, or Low).

Web Browser
DTE.Properties("Environment", "WebBrowser")

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

HomePage Get/Set (String) Represents the home page URL.

SearchPage Get/Set (String) Represents the search page URL.

ViewSourceIn Get/Set (Enum) vsBrowserViewSource (Source, Design,


External).

ViewSourceExternalProgram Get/Set (String) The path of the external source viewer.

See Also
Controlling Options Settings
Determining the Names of Property Items on Options Pages
Options Page, Fonts and Colors Node Properties
Options Page, Text Editor Node Properties
Environment Options Dialog Box
Text Editor Options Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The editor options in the Options dialog box provide ways to customize the appearance and behavior of the
editor.

In This Section
How to: Change Fonts and Colors in the Editor Explains how to change editor fonts and colors.
How to: Manage Word Wrap in the Editor Explains word wrap options.
How to: Display Line Numbers in the Editor Explains how to turn on line numbers.
How to: Display URLs as Links in the Editor Explains how to format URLs so they appear as links.
Setting Language-Specific Editor Options Explains how to set editor options that apply only to one development
language.
Options, Text Editor, General Explains general editor options.
Options, Text Editor, File Extension Explains file extension options.
Options, Text Editor, All Languages Explains options available to all languages.
Options, Text Editor, All Languages, Tabs Explains tab options available to all languages.
Options, Text Editor, Basic (Visual Basic) Explains Visual Basic options.
Options, Text Editor, C/C++, Formatting Explains C/C++ formatting options.
Options, Text Editor, C/C++, Advanced Explains C/C++ advanced options.
Options, Text Editor, C#, Formatting Explains C# formatting options.
Options, Text Editor, C#, Advanced Explains C# advanced options.
Options, Text Editor, C#, IntelliSense Explains C# IntelliSense options.
Options, Text Editor, JavaScript, Formatting Explains JavaScript formatting options.
Options, Text Editor, JavaScript, IntelliSense Explains JavaScript IntelliSense options.
Options, Text Editor, XAML, Formatting Explains XAML formatting options.

Related Sections
Writing Code Describes different ways to use the Code Editor.
How to: Change Fonts and Colors in the Editor
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can change the default font face, adjust the font size, and change the foreground and background colors for
various text Display items in the Code Editor. When changing font settings keep in mind the following
information:
The settings for Font and Size are global for all text elements in all Visual Studio editors.
The names of fixed width fonts are listed in bold.
Item foreground , Item background , and Bold options can be set for each type of text element. For
example, if you change colors and select Bold for Comment and Bookmarks , other types of text elements
will be unaffected.

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active
settings or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more
information, see Customizing Development Settings in Visual Studio.

To change the default font face, size, and colors


1. Select Options from the Tools menu, and in the Environment folder, select Fonts and Colors .
The Fonts and Colors, Environment, Options Dialog Box opens.
2. In Show settings for , select Text Editor .
3. Modify the Font and Size options to change the font face and size for all text elements in all editors.
4. Select the appropriate item in Display items , and then modify the Item foreground and Item
background options.

TIP
Click Use Defaults to reset the default settings.

5. Click OK .

See Also
Customizing the Editor Text Editor Options Dialog Box Writing Code How to: Change Fonts and Colors
How to: Manage Word Wrap in the Editor
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can set and clear the Word wrap option. When this option is set, the portion of a long line that extends
beyond the current width of the Code Editor window is displayed on the next line. When this option is cleared, for
example, to facilitate the use of line numbering, you can scroll to the right to see the ends of long lines.
For more information, see How to: Set General Editor Options.

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

Procedure
To set word wrap preferences
1. On the Tools menu, select Options .
2. In the Text Editor folder, choose the General options in the All Languages subfolder to set this option
globally.
— or —
Choose the General options in the subfolder for the language in which you are programming.
3. Under Settings , select or clear the Word wrap option.
When the Word wrap option is selected, the Show visual glyphs for word wrap option is enabled.
4. Select the Show visual glyphs for Word Wrap option if you prefer to display a return-arrow indicator
where a long line wraps onto a second line. Clear this option if you prefer not to display indicator arrows.

NOTE
These reminder arrows are not added to your code: they are for display purposes only.

See Also
Customizing the Editor Text Editor Options Dialog Box Writing Code
How to: Display Line Numbers in the Editor
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can display or hide line numbering in your code.

NOTE
Depending on your active settings, the dialog boxes and menu commands that appear might differ from the ones that are
described here. To change your settings, open Tools / Impor t and Expor t Settings . For more information, see
Customizing Development Settings in Visual Studio.

Display Line Numbers in Code


Line numbers aren't added to your code; they're just for reference. If you want line numbers to print, in the Print
dialog box, select the Include line numbers check box.
To display line numbers in code
1. On the menu bar, choose Tools , Options . Expand the Text Editor node, and then select either the node for
the language you are using, or All Languages to turn on line numbers in all languages. Or you can type
line number in the Quick Launch box.

2.

NOTE
Depending on your language or settings, you may have to select the Show All Settings check box in the Options dialog
box to reveal the All Languages sub-node.
See Also
Customizing the Editor Text Editor Options Dialog Box Writing Code
How to: Display URLs as Links in the Editor
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can choose to have the Code Editor treat Uniform Resource Locators (URLs) in your code as active links. When
you use this feature, URLs:
Appear underlined.
Display a ToolTip when you hover over them.
Attempt to open the Web site indicated when you CTRL + left-click on the link. By default, the Web site is
displayed in the internal Web browser.

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

Procedure
To display URLs as links
1. On the Tools menu, click Options .
2. Click Text Editor .
3. To change the option for only one language, expand the folder for that language and choose General .
—or—
To change the option for all languages, expand the All Languages folder and choose General .
4. Under Display , select Enable single-click URL navigation .

See Also
Customizing the Editor Text Editor Options Dialog Box Writing Code
Setting Language-Specific Editor Options
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Visual Studio offers a variety of Text Editor options that apply to specific programming languages.

In This Section
Options, Text Editor, Basic (Visual Basic) Describes settings for end constructs, code reformatting, outlining, and
error correction suggestions, among others, for Visual Basic code.
Options, Text Editor, C/C++, Formatting Describes outlining, indenting, Quick Info, and other settings for C and
C++ code.
Options, Text Editor, C/C++, Advanced Describes settings for IntelliSense and database files when using C and C++.
Options, Text Editor, C#, Formatting Describes settings for indenting, new line formatting, and wrapping text,
among others, for C# and J#.
Options, Text Editor, C#, Advanced Describes outlining, error identification, and XML documentation comment
settings for C# and J#.
Options, Text Editor, C#, IntelliSense Describes settings that specify how the IntelliSense completion list behaves
when you work in C# and J# code.
Validation, CSS, Text Editor, Options Dialog Box Describes statement completion and error correction settings for
cascading style sheets (CSS).
Validation, HTML, Text Editor, Options Dialog Box Describes settings for checking HTML syntax based on the
schema you select.
Options, Text Editor, XAML, Formatting Describes settings for element and attribute arrangement in XAML
documents.

Related Sections
Customizing the Editor Provides links to topics that explain the many aspects of the editor that you can set
preferences for.
Customizing Development Settings in Visual Studio Provides links to topics that explain how to customize your
settings, key bindings, and other features of the integrated development environment (IDE).
Options, Text Editor, General
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This dialog box lets you change global settings for the Visual Studio Code and Text Editor. To display this dialog box,
click Options on the Tools menu, expand the Text Editor folder, and then click General .

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

Settings
Drag and drop text editing When selected, enables you to move text by selecting it and dragging it with the mouse
to another location within the current document or any other open document.
Automatic delimiter highlighting When selected, delimiter characters that separate parameters or item-value pairs,
as well as matching braces, are highlighted.
Track changes When the code editor is selected, a vertical yellow line appears in the selection margin to mark code
that has changed since the file was most recently saved. When you save the changes, the vertical lines become
green.
Auto-detect UTF-8 encoding without signature By default, the editor detects encoding by searching for byte order
marks or charset tags. If neither is found in the current document, the code editor attempts to auto-detect UTF-8
encoding by scanning byte sequences. To disable the auto-detection of encoding, clear this option.

Display
Selection margin When selected, displays a vertical margin along the left edge of the editor's text area. You can
click this margin to select an entire line of text, or click and drag to select consecutive lines of text.

SEL EC T IO N M A RGIN O N SEL EC T IO N M A RGIN O F F

Indicator margin When selected, displays a vertical margin outside the left edge of the editor's text area. When you
click in this margin, an icon and ToolTip that are related to the text appear. For example, breakpoint or task list
shortcuts appear in the indicator margin. Indicator Margin information does not print.
Vertical scroll bar When selected, displays a vertical scrollbar which allows you to scroll up and down to view
elements that fall outside the viewing area of the Editor. If vertical scrollbars are not available, you can use the Page
Up, Page Down and cursor keys to scroll.
Horizontal scroll bar When selected, displays a horizontal scrollbar which allows you to scroll from side-to-side to
view elements that fall outside the viewing area of the Editor. If horizontal scrollbars are unavailable, you can use
the cursor keys to scroll.
Highlight current line When selected, displays a gray box around the line of code in which the cursor is located.

See Also
Options, Text Editor, All Languages Options, Text Editor, All Languages, Tabs Options, Text Editor, File Extension
Identifying and Customizing Keyboard Shortcuts Customizing the Editor Using IntelliSense
Options, Text Editor, File Extension
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This Options dialog allows you to specify how all files with certain file extensions will be handled by the Visual
Studio integrated development environment (IDE). For each Extension that you enter, you can select an Editing
Experience. This allows you to choose the IDE editor or designer in which documents of a certain type will open. To
display these options, choose Options from the Tools menu, expand the Text Editor node, and select File
Extension .
When you select an option "with Encoding," a dialog will be displayed whenever you open a document of that type
that allows you to select an encoding scheme for that document. This can be helpful if you are preparing versions
of your project documents for use on different platforms or in different target languages.

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

UIElement List
Extension Type the file extension whose Editing Experience in the IDE you wish to define.
Editor Select the IDE editor or designer in which documents with this file extension will open. When you select an
option "with Encoding," a dialog will be displayed whenever you open such a document that allows you to select
an encoding scheme.
Add Adds an entry that includes the specified Extension and Editing Experience to the Extension List.
Remove Deletes the selected entry from the Extension List.
Extension List Lists all extensions for which an Editing Experience has been specified.
Map extensionless files to Select this option if you wish to specify how files without an extension will be
handled by the IDE.
Extensionless file options Provides the same list as Editor . Select the IDE editor or designer in which
documents without file extensions will open.

See Also
How to: Manage Editor Modes
Options, Text Editor, All Languages
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This dialog box allows you to change the default behavior of the Code Editor. These settings also apply to other
editors based upon the Code Editor, such as the HTML Designer's Source view. To open this dialog box, select
Options from the Tools menu. Within the Text Editor folder, expand the All Languages subfolder and then
choose General .
Cau t i on

This page sets default options for all development languages. Remember that resetting an option in this dialog will
reset the General options in all languages to whatever choices are selected here. To change Text Editor options for
just one language, expand the subfolder for that language and select its option pages.
A grayed checkmark is displayed when an option has been selected on the General options pages for some
programming languages, but not for others.

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

Statement Completion
Auto list members When selected, pop-up lists of available members, properties, values, or methods are displayed
by IntelliSense as you type in the editor. Choose any item from the pop-up list to insert the item into your code.
Selecting this option enables the Hide advanced members option.
Hide advanced members When selected, shortens pop-up statement completion lists by displaying only those
items most commonly used. Other items are filtered from the list.
Parameter information When selected, the complete syntax for the current declaration or procedure is displayed
under the insertion point in the editor, with all of its available parameters. The next parameter you can assign is
displayed in bold.

Settings
Enable virtual space When this option is selected and Word wrap is cleared, you can click anywhere beyond the
end of a line in the Code Editor and type. This feature can be used to position comments at a consistent point next
to your code.
Word wrap When selected, any portion of a line that extends horizontally beyond the viewable editor area is
automatically displayed on the next line. Selecting this option enables the Show visual glyphs for word wrap
option.
NOTE
The Vir tual Space feature is turned off while Word Wrap is on.

Show visual glyphs for word wrap When selected, a return-arrow indicator is displayed where a long line wraps
onto a second line.

Clear this option if you prefer not to display these indicators.

NOTE
These reminder arrows are not added to your code, and do not print. They are for reference only.

Apply Cut or Copy commands to blank lines when there is no selection This option sets the behavior of the editor
when you place the insertion point on a blank line, select nothing, and then Copy or Cut.
When this option is selected, the blank line is copied or cut. If you then Paste, a new, blank line is inserted.
When this option is cleared, the Cut command removes blank lines. However, the data on the Clipboard is
preserved. Therefore, if you then use the Paste command, the content most recently copied onto the
Clipboard is pasted. If nothing has been copied previously, nothing is pasted.
This setting has no effect on Copy or Cut when a line is not blank. If nothing is selected, the entire line is
copied or cut. If you then Paste, the text of the entire line and its endline character are pasted.

TIP
To display indicators for spaces, tabs, and line ends, and thus distinguish indented lines from lines that are entirely blank,
select Advanced from the Edit menu and choose View White Space .

Display
Line numbers When selected, a line number appears next to each line of code.

NOTE
These line numbers are not added to your code, and do not print. They are for reference only.

Enable single-click URL navigation When selected, the mouse cursor changes to a pointing hand as it passes over a
URL in the editor. You can click the URL to display the indicated page in your Web browser.
Navigation bar When selected, displays the Navigation bar at the top of the code editor. Its dropdown Objects
and Members lists allow you to choose a particular object in your code, select from its members, and navigates to
the declaration of the selected member in the Code Editor.

See Also
Options, Text Editor, All Languages, Tabs General, Environment, Options Dialog Box Using IntelliSense
Options, Text Editor, All Languages, Tabs
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This dialog box allows you to change the default behavior of the Code Editor. These settings also apply to other
editors based upon the Code Editor, such as the HTML Designer's Source view. To display these options, select
Options from the Tools menu. Within the Text Editor folder expand the All Languages subfolder, and then
choose Tabs .
Cau t i on

This page sets default options for all development languages. Remember that resetting an option in this dialog will
reset the Tabs options in all languages to whatever choices are selected here. To change Text Editor options for just
one language, expand the subfolder for that language and select its option pages.
If different settings are selected on the Tabs options pages for particular programming languages, then the
message "The indentation settings for individual text formats conflict with each other," is displayed for differing
Indenting options; and the message "The tab settings for individual text formats conflict with each other," is
displayed for differing Tab options. For example, this reminder is displayed if the Smar t indenting option is
selected for Visual Basic, but Block indenting is selected for Visual C++.

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

Indenting
None When selected, new lines are not indented. The insertion point is placed in the first column of a new line.
Block When selected, new lines are automatically indented. The insertion point is placed at the same starting point
as the preceding line.
Smart When selected, new lines are positioned to fit the code context, per other code formatting settings and
IntelliSense conventions for your development language. This option is not available for all development
languages.
For example, lines enclosed between an opening brace ( { ) and a closing brace ( } ) might automatically be
indented an extra tab stop from the position of the aligned braces.

Tabs
Tab size Sets the distance in spaces between tab stops. The default is four spaces.
Indent size Sets the size in spaces of an automatic indentation. The default is four spaces. Tab characters, space
characters, or both will be inserted to fill the specified size.
Insert spaces When selected, indent operations insert only space characters, not TAB characters. If the Indent size
is set to 5, for example, then five space characters are inserted whenever you press the TAB key or the Increase
Indent button on the Formatting toolbar.
Keep tabs When selected, indent operations insert as many TAB characters as possible. Each TAB character fills the
number of spaces specified in Tab size . If the Indent size is not an even multiple of the Tab size , space
characters are added to fill in the difference.

See Also
Options, Text Editor, All Languages General, Environment, Options Dialog Box
Options, Text Editor, Basic (Visual Basic)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The VB Specific property page, in the Basic folder of the Text Editor folder of the Options (Tools menu) dialog
box contains the following properties:
Automatic inser tion of end constructs When you type—for example, the first line of a procedure declaration,
Sub Main— and press ENTER, the text editor adds a matching End Sub line. Similarly, if you add a For loop, the text
editor adds a matching Next statement. When this option is selected, the code editor automatically adds the end
construct.
Pretty Listing (reformatting) of code The text editor reformats your code as appropriate. When this option is
selected, the code editor will:
Align your code to the correct tab position
Recase keywords, variables, and objects to the correct case
Add a missing Then to an If...Then statement
Add parenthesis to function calls
Add missing end quotes to strings
Reformat exponential notation
Reformat dates
Enable outlining mode When you open a file in the code editor, you can view the document in outlining
mode. See Outlining for more information. When this option is selected, the outlining feature is activated
when you open a file.
Automatic inser tion of Interface and MustOverride members When you commit an Implements
statement or an Inherits statement for a class, the text editor inserts prototypes for the members that
have to be implemented or overridden, respectively.
Show procedure line separators The text editor indicates visual scope of procedures. A line is drawn in
the .vb source files of your project at locations listed in the following table:

LO C AT IO N IN . VB SO URC E F IL E EXA M P L E O F L IN E LO C AT IO N

After the close of a block declaration construct - At the end of a class, structure, module, interface, or enum
- After a property, function, or sub
- Not between the get and set clauses in a property

After a set of single line constructs - After the import statements, before a type definition in a
class file
- After variables declared in a class, before any procedures
LO C AT IO N IN . VB SO URC E F IL E EXA M P L E O F L IN E LO C AT IO N

After single line declarations (non-block level declarations) - Following import statements, inherits statements, variable
declarations, event declarations, delegate declarations, and
DLL declare statements

Enable error correction suggestions The text editor can suggest solutions to common errors and allow you to
select the appropriate correction, which is then applied to your code.
Enable highlighting of references and keywords The text editor can highlight all instances of a symbol or all
of the keywords in a clause such as If..Then , While...End While , or Try...Catch...Finally . You can navigate
between highlighted references or keywords by pressing CTRL+SHIFT+DOWN ARROW or CTRL+SHIFT+UP
ARROW.

See Also
General, Environment, Options Dialog Box Options, Text Editor, All Languages, Tabs
Options, Text Editor, C/C++, Formatting
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Lets you change the default behavior of the Code Editor when you are programming in C or C++.
To access this page, in the Options dialog box, in the left pane, expand Text Editor , expand C/C++ , and then click
Formatting .

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the
following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For
more information, see Customizing Development Settings in Visual Studio.

C/C++ Options
Enable automatic Quick Info ToolTips Enables or disables the Quick Info IntelliSense feature.

Inactive Code
Show Inactive Code Blocks Code that is inactive due to #ifdef declarations are colorized differently to help
you identify it.
Disable Inactive Code Opacity Inactive code can be identified by using color instead of transparency.
Inactive Code Opacity Percent The degree of opacity for inactive code blocks can be customized.

Indentation
Indent Braces You can configure how braces are aligned when you press ENTER after you begin a code block, for
example, a function or a for loop. The braces can either be aligned with the first character of the code block or
indented.
Automatic Indentation On Tab You can configure what happens on the current code line when you press TAB.
Either the line is indented or a tab is inserted.

Miscellaneous
Enumerate the comments in the Task List window The editor can scan open source files for preset words in
the comments. It creates an entry in the Task List window for any keywords that it finds.
Highlight Matching Tokens When the cursor is next to a brace, the editor can highlight the matching brace so
that you can more easily see the contained code.

Outlining
Enter outlining mode when files open When you bring a file into the text editor, you can enable the outlining
feature. For more information, see Outlining. When this option is selected, the outlining feature is enabled when
you open a file.
Automatic outlining of #pragma region blocks When this option is selected, automatic outlining for pragma
directives is enabled. This lets you expand or collapse pragma region blocks in outlining mode.
Automatic outlining of statement blocks When this option is selected, automatic outlining is enabled for the
following statement constructs:
if-else
switch Statement (C++)
while Statement (C++)

See Also
General, Environment, Options Dialog Box Using IntelliSense
Options, Text Editor, C/C++, Advanced
10/18/2019 • 7 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

By changing these options, you can change the behavior related to IntelliSense and the browsing database when
you're programming in C or C++.
To access this page, in the Options dialog box, in the left pane, expand Text Editor , expand C/C++ , and then
choose Advanced .

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the
following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. See
Customizing Development Settings in Visual Studio.

Browsing/Navigation
You should never choose these options except in the rare case where a solution is so large that the database
activity consumes an unacceptable amount of system resources.
Disable Database All use of the code browsing database (SDF), all other Browsing/Navigation options, and all
IntelliSense features except for #include Auto Complete are disabled.
Disable Database Updates The database will be opened read-only, and no updates will be performed as files
are edited. Most features will still work. However, as edits are made, the data will become stale, and you'll get
incorrect results.
Disable Database Auto Updates The code browsing database won't be automatically updated when source
files are modified. However, if you open Solution Explorer , open the shortcut menu for the project, and then
choose Rescan Solution , all out-of-date files will be checked, and the database will be updated.
Disable Implicit Files The code browsing database doesn't collect data for files that aren't specified in a project.
A project contains source files and header files that are explicitly specified. Implicit files are included by explicit files
(for example, afxwin.h, windows.h, and atlbase.h). Normally, the system finds these files and also indexes them for
various browsing features (including Navigate To). If you choose this option, those files aren't indexed, and some
features aren't available for them. If you choose this option, “Disable Implicit Cleanup” and “Disable External
Dependencies” are also implicitly chosen.
Disable Implicit Cleanup The code browsing database doesn't clean up implicit files that are no longer
referenced. This option prevents implicit files from being removed from the database when they're no longer used.
For example, if you add an #include directive that references mapi.h to one of your source files, mapi.h will be
found and indexed. If you then remove the #include and the file isn't referenced elsewhere, information about it
will eventually be removed unless you choose this option. (See the Rescan Solution Inter val option.) This option
is ignored when you explicitly rescan the solution.
Disable External Dependencies Folders The External Dependencies folder for each project isn't created or
updated. In Solution Explorer , each project contains an External Dependencies folder, which contains all implicit
files for that project. If you choose this option, that folder doesn't appear.
Recreate Database Recreate the code browsing database from nothing the next time that the solution loads. If
you choose this option, the SDF database file is deleted the next time you load the solution, thus causing the
database to be recreated and all files indexed.
Rescan Solution Inter val A ‘Rescan Solution Now’ job is scheduled for the interval that you specify. You must
specify between 0 and 5000 minutes. The default value is 60 minutes. While the solution is rescanned, file
timestamps are checked to determine whether a file was changed outside of the IDE. (Changes that are made in
the IDE are automatically tracked, and files are updated.) Implicitly included files are checked to determine whether
they're all still referenced.

Diagnostic Logging
These options are provided in case Microsoft asks you to collect advanced information to diagnose an issue. The
logging information isn't useful for users, and we recommend that you leave it disabled.
Enable Logging Enables diagnostic logging to the output window.
Logging Level Set the log verbosity, from 0 to 5.
Logging Filter Filters displayed event types by using a bitmask.
Set by using a sum of any of the following options:
0 - None
1 - General
2 - Idle
4 - WorkItem
8 - IntelliSense
16 - ACPerf
32 - ClassView

Fallback Location
The fallback location is where the SDF and IntelliSense support files (for example, iPCH) are put when the primary
location (same directory as solution) isn't used. This situation could occur the user doesn't have the permissions to
write to the solution directory or the solution directory is on a slow device. The default fallback location is in the
user’s temp directory.
Always Use Fallback Location Indicates that the code browsing database and IntelliSense files should always be
stored in a folder that you specify as your “Fallback Location”, not next to the .sln file. The IDE will never try to put
the SDF or iPCH files next to the solution directory and will always use the fallback location.
Do Not Warn If Fallback Location Used You aren't informed or prompted if a ‘Fallback Location’ is used.
Normally, the IDE will tell you if it had to use the fallback location. This option turns off that warning.
Fallback Location This value is used as a secondary location to store the code browsing database or IntelliSense
files. By default, your temporary directory is your fallback location. The IDE will create a subdirectory under the
specified path (or the temp directory) that includes the name of the solution along with a hash of the full path to
the solution, which avoids issues with solution names being identical.
IntelliSense
Auto Quick Info Enables QuickInfo tooltips when you move the pointer over text.
Disable IntelliSense Disables all IntelliSense features. The IDE does not create VCPkgSrv.exe processes to service
IntelliSense requests, and no IntelliSense features will work (QuickInfo, Member List, Auto Complete, Param Help).
Semantic colorization and reference highlighting are also disabled. This option doesn't disable browsing features
that rely solely on the database (including Navigation Bar, ClassView, and Property window).
Disable Auto Updating IntelliSense updating is delayed until an actual request for IntelliSense is made. This
delay can result in a longer execution time of the first IntelliSense operation on a file, but it may be helpful to set
this option on very slow or resource-constrained machines. If you choose this option, you also implicitly choose
the “Disable Error Reporting” and “Disable Squiggles” options.
Disable Error Repor ting Disables reporting of IntelliSense errors through squiggles and the Error List window.
Also disables the background parsing that's associated with error reporting. If you choose this option, you also
implicitly choose the “Disable Squiggles” option.
Disable Squiggles Disables IntelliSense error squiggles. The red “squiggles” don't show in the editor window, but
the error will still appear in the Error List window.
Disable #include Auto Complete Disables auto-completion of #include statements.
Use For ward Slash in #include Auto Complete Triggers auto-completion of #include statements when "/" is
used. The default delimiter is backslash ‘\’. The compiler can accept either, so use this option to specify what your
code base uses.
Max Cached Translation Units The maximum number of translation units that will be kept active at any one
time for IntelliSense requests. You must specify a value between 2 and 15. This number directly relates to the
maximum number of VCPkgSrv.exe processes that will run (for a given instance of Visual Studio). The default value
is 2, but if you have available memory, you can increase this value and possibly achieve slightly better
performance on IntelliSense.
For more information about translation units, see Phases of Translation.
Disable Aggressive Member List The member list doesn't appear while you type the name of a type or
variable. The list appears only after you type one of the commit characters, as defined in the Member List
Commit Characters option.
Disable Member List Keywords Language keywords such as void , class , switch don't appear in member
list suggestions.
Disable Member List Code Snippets Code snippets don't appear in member list suggestions.
Disable Semantic Colorization Turns off all code colorization except for language keywords, strings, and
comments.
Smar t Member List Commit Adds a line when you choose the Enter key at the end of a fully typed word.
Member List Filter Mode Sets the type of matching algorithm. Fuzzy finds the most possible matches because
it uses an algorithm that's similar to a spell-checker to find matches that are similar but not identical. Smar t
filtering matches substrings even if they're not at the start of a word. Prefix only matches on identical substrings
that start at the beginning of the word.
Member List Commit Characters Specifies the characters that cause the currently highlighted Member List
suggestion to be committed. You can add or remove characters from this list.

References
Disable Resolving For performance reasons, ‘Find All References’ displays raw textual search results by default
instead of using IntelliSense to verify each candidate. You can clear this check box for more accurate results on all
find operations. To filter on a per-search basis, open the shortcut menu for the result list, and then choose "Resolve
Results."
Hide Unconfirmed Hide unconfirmed items in the ‘Find All References’ results. If you unset the “Disable
Resolving” option, you can use this option to hide unconfirmed items in the results.
Disable Reference Highlighting

See Also
Setting Language-Specific Editor Options
Options, Text Editor, C/C++, Experimental
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

By changing these options, you can change the behavior related to IntelliSense and the browsing database when
you're programming in C or C++.
To access this page, in the Options dialog box, in the left pane, expand Text Editor , expand C/C++ , and then
choose Experimental .
These features are available in a Visual Studio 2015 Update 1 RC installation.

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following
instructions. The Visual Studio edition that you have and the settings that you use determine these elements. See
Customizing Development Settings in Visual Studio.

Browsing/Navigation
Enable New Database Engine This should automatically speed up database population and make all database
operations faster (with no loss in accuracy) for operations such as Go To Definition and Find All References .
(Just close and reopen your solution to apply the changes; you do not have to restart Visual Studio.)

IntelliSense
Member List Dot-To-Arrow Replaces '.' with '->' when applicable for Member List.

Refactoring
Enable Extract Function Extract selected code to its own function and replace code with a call to the new
function. To access this feature, right-click on the selected code and select Quick Actions , or simply press the
default shortcut Ctrl+Dot [Ctrl+.].
Enable Change Signature Add, reorder, and delete parameters of a function and propagate the changes to all call
sites. To access this feature, right-click on any usage of the function and select Quick Actions , or simply press the
default shortcut Ctrl+Dot [Ctrl+.].

Text Editor
Enable Expand Scopes If enabled, you can surround selected text with curly braces by typing '{' into the text
editor.
Enable Expand Precedence If enabled, you can surround selected text with parentheses by typing '(' into the text
editor.
For additional text editor features on the Visual Studio Gallery, see the list here. An example is C++ Quick Fixes,
which supports the following:
Add missing #include - Suggests relevant #include's for unknown symbols in your code
Add using namespace/Fully qualify symbol - Like the previous item, but for namespaces
Add missing semicolon
MSDN Help - Search MSDN for your error messages
You can either hover over a squiggle to get a light bulb, or use the default keyboard shortcut Ctrl+Dot
(Ctrl+.). Note that for the keyboard shortcut, your caret doesn't need to be positioned on the specific error or
token; you can simply be on the same line as the error to invoke suggestions for anything on that line.

See Also
Setting Language-Specific Editor Options Refactoring in C++ (VC Blog)
Options, Text Editor, C#, Formatting
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the Formatting property page dialog box to set options for formatting code in the Code Editor. To access this
dialog box, click Options on the Tools menu, expand Text Editor , expand C# , and then click Formatting .

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

General Settings
The general settings affect how the Code Editor applies formatting options to code.

UIElement List
L A B EL DESC RIP T IO N

Automatically format completed statement on ; When selected, formats statements at completion according
to the formatting options selected for the Code Editor. Clear
this box if you do not want the Code Editor to alter
statements.

Automatically format completed block on } When selected, formats code blocks according to the
formatting options selected for the Code Editor as soon as
you complete the code block. Clear this box if you do not
want the Code Editor to alter blocks.

Adjust indentation on paste When selected, formats text pasted into the Code Editor to fit
the formatting options selected for the Code Editor. Clear this
box if you do not want pasted text to be altered.

Preview Window
The Indentation , New Lines , Spacing , and Wrapping options panes each display a preview window. The
preview window shows the effect of each option. To use the preview window, select a formatting option. The
preview window shows an example of the selected option. When you change the setting, for example, when you
select or clear a check box, the preview window updates to show the effect of the new setting.

Remarks
Indentation options on the Tabs pages for each language only determine where the Code Editor places the cursor
when you press ENTER at the end of a line. Indentation options under Formatting apply when code is formatted
automatically, for example, when you paste code into the file while Adjust indentation on paste is selected, and
when the block being formatted is typed manually.

See Also
General, Environment, Options Dialog Box
Options, Text Editor, C#, Advanced
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use this dialog box to modify the settings for editor formatting, code refactoring, and XML documentation
comments for Visual C#. To access this dialog box, click Options on the Tools menu, expand the Text Editor
folder, expand C# , and then click Advanced .

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

Outlining
Enter outlining mode when files open When selected, automatically outlines the code file, which creates collapsible
blocks of code. The first time a file is opened, #regions blocks and inactive code blocks collapse.

Editor Help
Underline errors in the editor Identifies build errors in code. When this option is selected, wavy underlines appear
in colors that have specific meanings:
Parse errors are red.
Build errors are blue.
Build warnings are green.
Invalid Edit and Continue edits are purple.
Move the pointer over the underlined code segment to see a ToolTip with information about the error.
Show live semantic errors Identifies certain compile errors without explicit compilation, for example,
declaring and using an unknown type or referencing an unknown property.
Highlight references to symbol under cursor When the cursor is positioned inside a symbol, or when you
click a symbol, all the instances of that symbol in the code file are highlighted.

Refactoring
Verify results of refactoring Displays the Verification Results dialog box when you try to refactor code that
contains build errors, or when refactoring would cause a code reference to bind to something different from its
original binding.
Warn on members with compiler generated references Displays a warning dialog when you try to refactor a
member that has the same name as a compiler generated reference.
XML Documentation Comments
Generate XML documentation comments for /// When selected, inserts the <summary> start and end tags
automatically for XML documentation comments after you type the /// comment introduction. For more
information about XML documentation, see XML Documentation Comments.

Implement Interface
Surround generated code with #region Inserts a #region <interface name> Member around the methods when
Implement Interface or Implement Interface Explicitly is used.

Organize Usings
Place 'System' directives first when sorting usings When selected, System using directives appear before other
using directives. For more information, see Sort Usings.

See Also
XML Documentation Comments Setting Language-Specific Editor Options Visual C# IntelliSense
Options, Text Editor, C#, IntelliSense
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the IntelliSense property page to modify settings that affect the behavior of IntelliSense for Visual C#. You
can access the IntelliSense property page by clicking Options on the Tools menu, then clicking C# in the Text
Editor folder, and then clicking IntelliSense.

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

The IntelliSense property page contains the following properties:

Completion Lists
Show completion list after a character is typed When this option is selected, IntelliSense automatically
displays the completion list when you begin typing. When this option is not selected, IntelliSense completion is still
available from the IntelliSense menu or by pressing CTRL+SPACE.
Place keywords in completion lists When this option is selected, IntelliSense adds C# keywords, for example,
class, to the completion list.
Place code snippets in completion lists When this option is selected, IntelliSense adds aliases for C# code
snippets to the completion list. In the case where the code snippet alias is the same as a keyword, for example,
class, the keyword is replaced by the shortcut. For more information, see Visual C# Code Snippets.

Selection in Completion Lists


Committed by typing the following characters: Specifies all characters that execute IntelliSense automatic
completion for the selected item in completion list, after they are typed.
Committed by pressing the space bar Specifies to include the action of pressing the space bar to execute
IntelliSense automatic completion for the selected item in completion list.
Add new line on enter at end of fully typed word Specifies that if you type all the characters for an entry in
the completion list and then press ENTER, a new line is created automatically and the cursor moves to the new line.
For example, if you type else and then press ENTER, the following appears in the editor:
else

| (cursor location)
However, if you type only el and then press ENTER, the following appears in the editor:
else| (cursor location)

IntelliSense Member Selection


Pre-selects most recently used member When this option is selected, IntelliSense pre-selects the members
that you have recently selected in the pop-up List Members box for automatic object name completion, during
your current session in the integrated development environment (IDE). The history of most recently used
members is cleared between each session in the IDE. For more information, see IntelliSense for Most Recently
Used Members.

See Also
General, Environment, Options Dialog Box XML Documentation Comments Using IntelliSense
Options, Text Editor, JavaScript, Formatting
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the Formatting page of the Options dialog box to set options for formatting code in the Code Editor. To
access this page, on the menu bar, choose Tools , Options , and then expand Text Editor , JavaScript , and
Formatting .

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following
instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more
information, see Personalizing the IDE.

Automatic Formatting
These options determine when formatting occurs in Source view.

UIElement List
O P T IO N DESC RIP T IO N

Format completed line on Enter When this option is selected, the Code Editor automatically
formats the line when you choose the Enter key.

Format completed statement on ; When this option is selected, the Code Editor automatically
formats the line when you choose the semicolon key.

Format completed block on } When this option is selected, the Code Editor automatically
formats the line when you choose the closing brace key.

Format on paste When this option is selected, the Code Editor reformats code
when you paste it into the editor. The editor uses the currently
defined formatting rules. If this option is not selected, the
editor uses the original formatting of the pasted-in code.

New Lines
These options determine whether the Code Editor puts an open brace for functions and control blocks on a new
line.

UIElement List
O P T IO N DESC RIP T IO N

Place open brace on new line for functions When this option is selected, the Code Editor moves the open
brace associated with a function to a new line.

Place open brace on new line for control blocks When this option is selected, the Code Editor moves the open
brace associated with a control block (for example, if and
while control blocks) to a new line.

Spacing
These options determine how spaces are inserted in Source view.

UIElement List
O P T IO N DESC RIP T IO N

Inser t space after comma delimiter When this option is selected, the Code Editor adds a space
after comma delimiters.

Inser t space after semicolon in 'for' statement When this option is selected, the Code Editor adds a space
after each semicolon in the first line of a for loop.

Inser t space before and after binar y operators When this option is selected, the Code Editor adds a space
before and after binary operators (for example, +, -, &&, ||).

Inser t space after keywords in control flow When this option is selected, the Code Editor adds a space
statements after JavaScript keywords in control flow statements.

Inser t space after function keyword for anonymous When this option is selected, the Code Editor adds a space
functions. after the function keyword for anonymous functions.

Inser t space after opening and before closing non- When this option is selected, the Code Editor adds a space
empty parenthesis after the opening parenthesis and before the closing
parenthesis if non-empty characters are present within the
parentheses.

See Also
General, Environment, Options Dialog Box
Options, Text Editor, JavaScript, IntelliSense
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the IntelliSense page of the Options dialog box to modify settings that affect the behavior of IntelliSense for
JavaScript. You can access the IntelliSense page by choosing Tools , Options on the menu bar, and then
expanding Text Editor , JavaScript , IntelliSense.

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the
following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For
more information, see Personalizing the IDE.

The IntelliSense page contains the following sections:

Validation
You can use these options to set preferences for how the JavaScript editor validates syntax in your document.

UIElement List
Show syntax errors When this check box is not selected, the JavaScript code editor does not show syntax errors.
This is useful if you are working with code that you didn't write and you don't intend to fix syntax errors.
When this check box is selected, you have the option to select the Show errors as warning check box.
Show errors as warnings When this check box is selected, JavaScript errors are shown as warnings instead of
errors in the error list.
Download remote references (e.g. http://) for files in the miscellaneous files project When this check
box is selected, and if you have a JavaScript file opened outside the context of a project, Visual Studio will
download remote JavaScript files referenced in the file for the purpose of providing IntelliSense information. If this
option is selected, files will download when you include them as a reference in your JavaScript file.

NOTE
For Web projects, remote files referenced in your project are downloaded by default.

Statement Completion
You can use these options to change the behavior of IntelliSense statement completion.

UIElement List
Only use tab or enter to commit When this check box is selected, the JavaScript code editor appends
statements with items selected in the completion list only after you choose the Tab or Enter key. When this check
box is not selected, other characters, such as a period, comma, colon, open parenthesis, and open brace ({), can
also append statements with the selected items.

References
You can use these options to specify the types of IntelliSense .js files that are in scope for different JavaScript
project types. The IntelliSense references are typically used to provide IntelliSense support for global objects. You
can also use this page to set the loading order for scripts that must be loaded at run time, and to add IntelliSense
extension files.

UIElement List
Reference groups This option specifies the reference group type. Three reference groups are supported:
You can use pre-defined reference groups to specify that particular IntelliSense .js files are in scope for different
JavaScript projects. Four reference groups are available:
Implicit (Windows version), for Windows 8.x Store apps using JavaScript. Files included in this group are in
scope for every .js file opened in the Code Editor for Windows 8.x Store apps using JavaScript.
Implicit (Web), for HTML5 projects. Files included in this group are in scope for every .js file opened in the
Code Editor for these project types.
Dedicated worker reference groups, for HTML5 Web Workers. Files specified in this group are in scope for
.js files that have an explicit reference to a dedicated worker reference group.
Generic, for other JavaScript project types.
Included files This option specifies the order in which files are loaded into the context of the language
service. You can configure the order by using the Remove , Move Up , and Move Down buttons. For
IntelliSense to work correctly, a file that is dependent on another must be loaded after the other file.
Cau t i on

If an object is defined unconditionally in two or more implicit references, the last reference in this list will be used
to define the object.
Add a reference to the group This option provides a way to add additional IntelliSense .js files by browsing to
the appropriate files.

See Also
JavaScript IntelliSense
Options, Text Editor, XAML, Formatting
10/16/2020 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the Formatting property page to specify how elements and attributes are formatted in your XAML
documents. To open the Options dialog box, click the Tools menu and then click Options . To access the
Formatting property page, expand the Text Editor , XAML , Formatting node.

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

Auto-Formatting Events
Auto-formatting may occur when any of the following events is detected.
Completion of an end tag or simple tag.
Completion of a start tag.
Pasting from the clipboard.
Formatting keyboard commands.
You can specify which events cause auto-formatting.

NAME DESC RIP T IO N

On completion of end tag or simple tag Auto-formatting occurs when you finish typing an end tag or
a simple tag. A simple tag has no attributes, for example
<Button /> .

On completion of star t tag Auto-formatting occurs when you finish typing a start tag.

On paste from clipboard Auto-formatting occurs when you paste XAML from the
clipboard into XAML view.

Quotation Mark Style


This setting indicates whether attribute values are enclosed in single or double quotation marks. The auto-
formatter and IntelliSense auto-completion both use this setting.
Once you set this option, only attributes subsequently added either using the designer or manually in the XAML
view are affected.
NAME DESC RIP T IO N

Double quotes (") Attribute values are enclosed in double quotes.

<Button Name="button1">Hello</Button>

Single quotes (') Attribute values are enclosed in single quotes.

<Button Name='button1'>Hello</Button>

Tag Wrapping
You can specify a line length for tag wrapping. When tag wrapping is enabled, any XAML subsequently added by
using the designer will be wrapped appropriately.

NAME DESC RIP T IO N

Wrap tags that exceed specified length Specifies whether lines are wrapped at the line length specified
by Length .

Length The number of characters a line may contain. If necessary,


some XAML lines might exceed the specified line length.

Attribute Spacing
Use this setting to control how attributes are arranged in your XAML document

NAME DESC RIP T IO N

Preser ve newlines and spaces between attributes New lines and spaces between attributes are not affected by
auto-formatting.

<Button Height="23" Name="button1"

Width="75">Hello</Button>

Inser t a single space between attributes Attributes occupy one line, with one space separating
adjacent attributes. Tag wrapping settings are applied.

<Button Height="23" Name="button1"


Width="75">Hello</Button>

Position each attribute on a separate line Each attribute occupies its own line. This is useful when many
attributes are present.

<Button

Height="23"

Name="button1"

Width="75">Hello</Button>
NAME DESC RIP T IO N

Position first attribute on same line as star t tag When checked, the first attribute appears on the same line as
the element's start tag.

<Button Height="23"

Name="button1"

Width="75">Hello</Button>

Element Spacing
Use this setting to control how elements are arranged in your XAML document

Preser ve new lines in content Empty lines in element content are not removed.

<Grid>

<Button Name="button1">Hello</Button>

</Grid>\

Collapse multiple empty lines in content to a single Empty lines in element content are collapsed to a single line.
line
<Grid>

<Button Name="button1">Hello</Button>

</Grid>

Remove empty lines in content All empty lines in element content are removed.

<Grid>

<Button Name="button1">Hello</Button>

</Grid>

Auto Insert
Use this setting to control when tags and quotes are automatically generated.

NAME DESC RIP T IO N


NAME DESC RIP T IO N

Closing tags Specifies whether an element's closing tag is automatically


generated when you close the opening tag with the greater
than character (>).

Attribute quotes Specifies whether enclosing quotes are generated when an


attribute value is selected from the statement completion
drop-down list.

Closing braces for MarkupExtensions Specifies whether a markup extension's closing brace (}) is
automatically generated when you type the opening brace
character ({).

Commas to separate MarkupExtension parameters Specifies whether commas are generated when you type more
than one parameter in a markup extension.

Default View
Use this setting to control whether Design view appears when XAML documents are loaded.

NAME DESC RIP T IO N

Always open documents in full XAML view Specifies whether XAML documents appear only in XAML
view, without Design view. Useful for loading large documents.

Toolbox
Use this setting to specify whether user controls and custom controls are shown in the Toolbox.

NAME DESC RIP T IO N

Automatically populate toolbox items Specifies whether user controls and custom controls in the
current solution are shown in the Toolbox automatically.

See Also
XAML in WPF How to: Change XAML View Settings XAML and Code Walkthroughs
Options Page, Fonts and Colors Node Properties
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This document describes font and color properties for a tool window that is registered to appear under Fonts and
Colors in the Environment category of the Options dialog box. This supports the dynamic nature of groups of
colorable items, which can change if VSPackages are installed or uninstalled.
The following section shows an example of a registered window type and the properties that are available for each
window.

Text Editor or Printer or Dialogs and Tool Windows


DTE.Properties("FontsAndColors", "TextEditor")

-or-
DTE.Properties("FontsAndColors", "Printer")

-or-
DTE.Properties("FontsAndColors", "Dialogs and Tool Windows")

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

FontFamily Get/Set (String) The font name to use, such as "Courier


New."

FontCharacterSet Get/Set (vsFontCharSet) A vsFontCharSet value, specifying the


type of character set to use, such as
Hebrew or Russian.

FontSize Get/Set (Short) The size of font to use, in points. For


example, 10 or 12.

See Also
Controlling Options Settings Determining the Names of Property Items on Options Pages Options Page,
Environment Node Properties Options Page, Text Editor Node Properties
Options Page, Text Editor Node Properties
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This document describes some pages (or properties collections) that are associated with the Text Editor category,
DTE.Properties("TextEditor", <Property Page>) , of the Options dialog box. The title of each subsection is the call
that is used to access the Properties collection, and the table in each subsection lists the properties in the
collection.
The Visual Basic macros in Controlling Options Settings demonstrate how to display current options and their
values for each page of the Options dialog box.

General
DTE.Properties("TextEditor", "General")

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

GoToAnchorAfterEscape Get/Set (Boolean) If True , pressing escape while there is


a selection causes the insertion point to
move to where the action that created
the selection was initiated. False
moves the insertion point to the other
end of the selection.

DragNDropTextEditing Get/Set (Boolean) Determines whether you can drag a


selected region of text from one
location to another in the document for
copy or cut/paste operations.

HorizontalScrollBar Get/Set (Boolean) Determines whether there is a


horizontal scrollbar on editor windows.

VerticalScrollBar Get/Set (Boolean) Determines whether there is a vertical


scroll bar on editor windows.

SelectionMargin Get/Set (Boolean) Determines whether there is space at


the left of the text pane for special
selection operations, drawing
breakpoint icons, and so forth.

MarginIndicatorBar Get/Set (Boolean) Determines whether there is a vertical


line dividing the left margin of the text
pane from the main body of the text
pane.
P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

UndoCaretActions Get/Set (Boolean) If True . undo operations include


insertion point motion, selection
commands, and so forth, in addition to
editing actions that modify the buffer.

AutoDelimiterHighlighting Get/Set (Boolean) Determines whether typing a closing


delimiter causes the editor to highlight
the opening delimiter. The editor always
bolds the open delimiter regardless of
the value of this property.

EditorEmulation Get/Set (Enum)

DetectUTF8WithoutSignature Get/Set (Boolean) Detects whether a file uses UTF-8


encoding when it does not have an
encoding signature.

TrackChanges Get/Set (Boolean)

Plain Text
DTE.Properties("TextEditor", "PlainText")

The PlainText editor options affect the editor settings when text files are edited. Each programming language and
Visual Studio package has its own specific Text Editor settings. For example, to view or change the Visual C#
editor settings, use DTE.Properties("TextEditor", "CSharp") or DTE.Properties("TextEditor", "CSharp-Specific") .
For the SQL Script editor settings, use DTE.Properties("TextEditor", "SQL ") .

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

AutoListMembers Get/Set (Boolean) Determines whether an available list of


members automatically appears when a
user types a period following a variable
reference.

AutoListParams Get/Set (Boolean) Determines whether a description of an


argument list automatically displays
when the users types a "(" following a
function name.

HideAdvancedMembers Get/Set (Boolean) Determines whether statement


completion lists all members or only the
commonly used ones.

VirtualSpace Get/Set (Boolean) Determines whether white space


characters are displayed as graphics.
Setting this to true causes the
WordWrap property item (in this list) to
be set to false .
P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

WordWrap Get/Set (Boolean) Determines whether the view wraps


long lines at word boundaries. Setting
this to true causes the
VirtualSpace property item (in this
list) to be set to false .

WordWrapGlyphs Get/Set (Boolean) Displays a glyph at the end of a line;


this indicates that the line wraps to the
next line.

EnableLeftClickForURLs Get/Set (Boolean) Determines whether the editor


underlines URLs and enables a single
left-click for jumping to the URL in the
system registered Web browser.

IndentStyle Get/Set (vsIndentStyle) Determines the indenting style: Default,


Smart, or None.

TabSize Get/Set (Long) Represents the number of spaces that


equal a tab. Setting an integer outside
the range 1 to 60 (inclusive) fails.

InsertTabs Get/Set (Boolean) If True , TAB characters are used when


indenting.

IndentSize Get/Set (Long) Represents the number of spaces that


equals one indent level. Setting an
integer value outside the range 1 to 60
(inclusive) fails.

ShowLineNumbers Get/Set (Boolean) Determines whether the view of a core


editor document displays line numbers
along the left margin.

ShowNavigationBar Get/Set (Boolean) Determines whether the drop-down


lists and buttons appear at the top of
editor windows.

CutCopyBlankLines Get/Set (Boolean) Cuts or copies blank lines when they


are selected.

See Also
Controlling Options Settings Determining the Names of Property Items on Options Pages Options Page,
Environment Node Properties Options Page, Fonts and Colors Node Properties
Options Page, Debugging Node Properties
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The following tables describe the pages (or properties collections) that are associated with the Debugging
category, DTE.Properties("Debugging", <Property Page>) of the Options dialog box.

General
DTE.Properties("Debugging", "General")

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

PromptOnBreakpointDelete Get/Set (Boolean) Determines whether the debugger


prompts for permission before deleting
all breakpoints in a project.

BreakAllProcesses Get/Set (Boolean) Determines whether the debugger


breaks all processes whenever a single
process breaks.

BreakAtBoundaries Get/Set (Boolean) Determines whether the debugger


breaks execution when an exception
crosses a border between AppDomains
or between managed and native code.

EnableAddressLevelDebugging Get/Set (Boolean) Determines whether address-level


debugging features are enabled.

ShowDisassemblyIfNoSource Get/Set (Boolean) Determines whether the debugger


displays disassembly code when source
code is not available.

EnableBreakpointFilters Get/Set (Boolean) Determines whether breakpoint filtering


is enabled.

EnableExceptionAssistant Get/Set (Boolean) Determines whether the Exception


Assistant is used for managed
exceptions.

UnwindCallstack Get/Set (Boolean) Determines whether the debugger


unwinds the call stack for an unhandled
exception.

EnableJustMyCode Get/Set (Boolean) Determines whether Just My Code is


enabled for C# and for Visual Basic
code.
P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

ShowAllMembers Get/Set (Boolean) For non-user objects, determines


whether the debugger displays all
object members in the variables
windows. This option has no effect
unless Just My Code is enabled.

WarnIfNoUserCode Get/Set (Boolean) Determines whether the debugger


emits a warning when the user tries to
attach to a process that has no user
code. This option has no effect unless
Just My Code is enabled.

EnablePropertyEvaluation Get/Set (Boolean) Determines whether the debugger


automatically evaluates properties and
implicit function calls in managed code.

CallStringConversion Get/Set (Boolean) Determines whether the debugger


implicitly calls a string conversion
function on objects in the variables
windows. This option applies to C# and
JScript code only.

EnableSourceServer Get/Set (Boolean) Determines whether the debugger can


access code from a source server.

PrintSourceServerDiagnostics Get/Set (Boolean) Determines whether the Output


window shows diagnostic messages
related to the source server. This option
has no effect unless source server
access is enabled.

HighlightEntireLine Get/Set (Boolean) Determines whether the debugger


highlights an entire line for breakpoints
and the current statement.

RequireSourceToMatch Get/Set (Boolean) Determines whether the debugger


requires source files to exactly match
the original version when you open files
for debugging.

RedirectOutputToImmediate Get/Set (Boolean) Determines whether Output window


output is redirected to the Immediate
Window.

ShowRawVariableStructure Get/Set (Boolean) Determines whether objects in the


variables windows are shown in raw
form.

SuppressJitOptimization Get/Set (Boolean) For managed code, determines whether


just-in-time optimization is suppressed
by the debugger.

WarnIfNoSymbols Get/Set (Boolean) Determines whether the debugger


displays a warning if no debugging
symbols are available when a process is
launched.
P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

WarnIfScriptDisabled Get/Set (Boolean) Determines whether the debugger


displays a warning if script debugging is
not enabled when a process is launched.

ShowMarkersForAllThreads Get/Set (Boolean) Determines whether the debugger


displays thread markers.

StepOverPropertiesAndOperators Get/Set (Boolean) Specifies whether to step over


properties and operators in managed
code only.

Edit and Continue


DTE.Properties("Debugging", "EditAndContinue")

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

EnableEditAndContinue Get/Set (Boolean) Determines whether Edit and Continue


is enabled. This option applies to all
languages that support Edit and
Continue.

InvokedByCommands Get/Set (Boolean) Determines whether Edit and Continue


automatically applies code changes
when the user selects a debugging
command such as Step or Continue .
This option applies to native code only.

InvokedByCommandsAskFirst Get/Set (Boolean) Determines whether Edit and Continue


prompts the user for permission to
apply code changes when the user
selects a debugging command such as
Step or Continue . This option applies
to native code only.

WarnAboutStaleCode Get/Set (Boolean) Determines whether the debugger


issues a warning message when Edit
and Continue would result in the
execution of out-of-date, or stale, code.
This option applies to native code only.

RelinkChangesOnStop Get/Set (Short) Determines whether Visual Studio


relinks code changes applied by Edit
and Continue when execution of the
application stops. This option applies to
native code only.

AllowPrecompiling Get/Set (Short) Determines whether Edit and Continue


is allowed to load precompiled headers
in the background. This option applies
to native code only.

Just-In-Time
DTE.Properties("Debugging", "JustInTime")
P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

JitManaged Get/Set (Boolean) Determines whether Just-In-Time


Debugging is enabled for managed
code.

JitNative Get/Set (Boolean) Determines whether Just-In-Time


Debugging is enabled for native code.

JitScript Get/Set (Boolean) Determines whether Just-In-Time


Debugging is enabled for script code.

Native
DTE.Properties("Debugging", "Native")

P RO P ERT Y IT EM N A M E VA L UE DESC RIP T IO N

LoadDllExports Get/Set (Boolean) Determines whether the debugger


loads DLL export tables.

EnableRPC Get/Set (Boolean) Determines whether the debugger can


step into COM remote procedure calls.

See Also
Controlling Options Settings Determining the Names of Property Items on Options Pages Options Page, Fonts and
Colors Node Properties Options Page, Text Editor Node Properties General, Debugging, Options Dialog Box Edit and
Continue, Debugging, Options Dialog Box Just-In-Time, Debugging, Options Dialog Box
Output Window
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Output window can display status messages for various features in the integrated development environment
(IDE). To open the Output window, on the menu bar, choose View/Output (or click CTRL + ALT + O).

WARNING
The Output window does not appear on the View menu in Visual Studio Express editions. To bring it up, use the hotkey CTRL
+ ALT + O.

Toolbar
Show output from Displays one or more output panes to view. Several panes of information might be available,
depending on which tools in the IDE have used the Output window to deliver messages to the user.
Find Message in Code Moves the insertion point in the code editor to the line that contains the selected build
error.
Go to Previous Message Changes the focus in the Output window to the previous build error and moves the
insertion point in the code editor to the line that contains that build error.
Go to Next Message Changes the focus in the Output window to the next build error and moves the insertion
point in the code editor to the line that contains that build error.
Clear all Clears all text from the Output pane.
Toggle Word Wrap Turns the Word Wrap feature on and off in the Output pane. When Word Wrap is on, text in
longer entries that extends beyond the viewing area is displayed on the following line.

Output Pane
The Output pane selected in the Show output from list displays output from the source indicated.

Routing Messages to the Output Window


To display the Output window whenever you build a project, in the General, Projects and Solutions, Options
dialog box, select Show Output window when build star ts . Then, with a code file open for editing, choose the
Go to Next Message and Go To Previous Message buttons on the Output window toolbar to select entries in
the Output pane. As you do this, the insertion point in the code editor jumps to the line of code where the selected
problem occurs.
Certain IDE features and commands invoked in the Command Window deliver their output to the Output window.
Output from external tools such as .bat and .com files, which is typically displayed in the Command Prompt
window, is routed to an Output pane when you select the Use Output Window option in the Managing External
Tools. Many other kinds of messages can be displayed in Output panes as well. For example, when Transact-SQL
syntax in a stored procedure is checked against a target database, the results are displayed in the Output window.
You can also program your own applications to write diagnostic messages at run time to an Output pane. To do
this, use members of the Debug class or Trace class in the System.Diagnostics namespace of the .NET Framework
Class Library. Members of the Debug class display output when you build Debug configurations of your solution
or project; members of the Trace class display output when you build either Debug or Release configurations. For
more information, see Diagnostic Messages in the Output Window.
In Visual C++, you can create custom build steps and build events whose warnings and errors are displayed and
counted in the Output pane. By pressing F1 on a line of output, you can display an appropriate help topic. For
more information, see Formatting the Output of a Custom Build Step or Build Event.

Scrolling Behavior
If you use autoscrolling in the Output window and then navigate by using the mouse or arrow keys, autoscrolling
stops. To resume autoscrolling, press CTRL+END.

See Also
Diagnostic Messages in the Output Window How to: Control the Output Window Compiling and Building
Understanding Build Configurations Class Library Overview
Project Properties Reference
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Learn more about how to configure and customize project properties.

Project Properties Pages


T IT L E DESC RIP T IO N

Application Page, Project Designer (Visual Basic) Use this page to specify application settings and properties
for a Visual Basic project.

Application Page, Project Designer (C#) Use this page to specify application settings and properties
for a Visual C# project.

Build Events Page, Project Designer (C#) Use this pane to specify build configuration instructions.

Build Page, Project Designer (C#) Use this pane to specify build configuration properties for a
Visual C# project.

Compile Page, Project Designer (Visual Basic) Use this page to specify compilation properties for Visual
Basic projects.

Debug Page, Project Designer Use this page to specify debugging properties for a project.

Code Analysis, Project Designer Use this page to configure the code analysis tool.

Publish Page, Project Designer Use this page to configure properties for ClickOnce.

References Page, Project Designer (Visual Basic) Use this page to manage references used by a project.

Security Page, Project Designer Use this page to configure code access security settings for
applications that are deployed by using ClickOnce
deployment.

Signing Page, Project Designer Use this page to sign application and deployment manifests,
and sign the assembly.

See Also
Introduction to the Project Designer Solutions and Projects
Application Page, Project Designer (Visual Basic)
1/10/2020 • 9 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the Application page of the Project Designer to specify a project's application settings and properties.
To access the Application page, choose a project node (not the Solution node) in Solution Explorer . Then
choose Project , Proper ties on the menu bar. When the Project Designer appears, click the Application tab.

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the
following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For
more information, see Personalizing the IDE.

General Application Settings


The following options enable you to configure general settings for an application.
Assembly name Specifies the name of the output file that will contain the assembly manifest. If you change this
property, the Output Name property will also change. You can also make this change at a command prompt by
using /out (Visual Basic). For information about how to access this property programmatically, see
AssemblyName.
Root namespace Specifies the base namespace for all files in the project. For example, if you set the Root
Namespace to Project1 and you have a Class1 outside of any namespace in your code, its namespace would
be Project1.Class1 . If you have a Class2 in a namespace Order in code, its namespace would be
Project1.Order.Class2 .

If you clear the Root Namespace , you can specify the namespace structure of your project in code.

NOTE
If you use the Global keyword in a Namespace Statement, you can define a namespace out of the root namespace of your
project. If you clear the Root Namespace , Global becomes the top-level namespace, which removes the need for the
Global keyword in a Namespace statement. For more information, see "Global Keyword in Namespace Statements" in
Namespaces in Visual Basic.

For information about how to create namespaces in your code, see Namespace Statement.
For more information about the root namespace property, see /rootnamespace.
For information about how to access this property programmatically, see RootNamespace.
Target framework (all configurations) Specifies the version of the .NET Framework that the application
targets. This option can have different values depending on which versions of the .NET Framework are installed
on your computer.
The default value matches the target framework that you specified in the New Project dialog box.

NOTE
The prerequisite packages that are listed in the Prerequisites Dialog Box are set automatically when you open the dialog box
for the first time. If you subsequently change the project's target framework, you must specify the prerequisites manually to
match the new target framework.

For more information, see How to: Target a Version of the .NET Framework and Visual Studio Multi-Targeting
Overview.
Application type Specifies the type of application to build. For Windows 8.x Store apps, you can specify
Windows Store App , Class Librar y , or WinMD File . For most other application types, you can specify
Windows Application , Console Application , Class Librar y , Windows Ser vice , or Web Control Librar y .
For a web application project, you must specify Class Librar y .
If you specify the WinMD File option, types can be projected into any Windows Runtime programming
language. By packaging the project's output as a WinMD file, you can code an application in multiple languages
and have code interoperate as if you wrote it all in the same language. You can use the WinMD File option for
solutions that target the Windows Runtime libraries, including Windows 8.x Store apps. For more information, see
Creating Windows Runtime Components in C# and Visual Basic.

NOTE
The Windows Runtime can project types so that they appear as native objects in whichever language uses them. For
example, JavaScript applications that interact with Windows Runtime use it as a set of JavaScript objects, and C#
applications use the library as a collection of .NET objects. By packaging the project’s output as a WinMD file, you can take
advantage of the same technology that Windows Runtime uses.

For more information about the Application type property, see /target (Visual Basic). For information about how
to access that property programmatically, see OutputType.
Icon Sets the .ico file that you want to use as your program icon. Select <Browse...> to browse for an existing
graphic. See /win32icon (or /win32icon (C# Compiler Options)) for more information. To access this property
programmatically, see ApplicationIcon.
Star tup form / Star tup object / Star tup URI Specifies the application's startup form or entry point.
If Enable application framework is selected (the default), this list is titled Star tup form and shows only forms
because the application framework supports only startup forms, not objects.
If the project is a WPF Browser Application, this list is titled Star tup URI , and the default is Page1.xaml . The
Star tup URI list enables you to specify the user interface resource (a XAML element) that the application displays
when the application starts. For more information, see StartupUri.
If Enable application framework is cleared, this list becomes Star tup object and shows both forms and
classes or modules with a Sub Main .
Star tup object defines the entry point to be called when the application loads. Generally this is set to either the
main form in your application or to the Sub Main procedure that should run when the application starts. Because
class libraries do not have an entry point, their only option for this property is (None) . For more information, see
/main. To access this property programmatically, see StartupObject.
Assembly Information Click this button to display the Assembly Information Dialog Box.
Enable application framework Specifies whether a project will use the application framework. The setting of
this option affects the options available in Star tup form /Star tup object .
If this check box is selected, your application uses the standard Sub Main . Selecting this check box enables the
features in the Windows application framework proper ties section, and also requires you to select a startup
form.
If this check box is cleared, your application uses the custom Sub Main that you specified in Star tup form . In this
case you can specify either a startup object (a custom Sub Main in a method or a class) or a form. Also, the
options in the Windows application framework proper ties section become unavailable.
View Windows Settings Click this button to generate and open the app.manifest file. Visual Studio uses this file
to generate manifest data for the application. Then set the UAC requested execution level by modifying the
<requestedExecutionLevel> tag in app.manifest as follows:

<requestedExecutionLevel level="asInvoker" />

ClickOnce works with a level of asInvoker or in virtualized mode (no manifest generation). To specify virtualized
mode, remove the entire tag from app.manifest.
For more information about manifest generation, see ClickOnce Deployment on Windows Vista.

Windows Application Framework Properties


The following settings are available in the Windows application framework proper ties section. These
options are available only if the Enable application framework check box is selected. The section following this
one describes Windows application framework proper ties settings for Windows Presentation Foundation
(WPF) Applications.
Enable XP visual styles Enables or disables the Windows XP visual styles, also known as Windows XP Themes.
Windows XP visual styles enable, for example, controls with rounded corners and dynamic colors. The default is
enabled. For more information about Windows XP visual styles, see Windows XP Features and Windows Forms
Controls).
Make single instance application Select this check box to prevent users from running multiple instances of
the application. The default setting for this check box is cleared. This setting allows multiple instances of the
application to be run.
Save My.Settings on Shutdown Select this check box to specify that the application's My.Settings settings are
saved when users shut down their computers. The default setting is enabled. If this option is disabled, you can
save application settings manually by calling My.Settings.Save .
Authentication mode Select Windows (the default) to specify the use of Windows authentication to identify
the currently logged-on user. You can retrieve this information at run time by using the My.User object. Select
Application-defined if you will provide your own code to authenticate users instead of using the default
Windows authentication methods.
Shutdown mode Select When star tup form closes (the default) to specify that the application exit when the
form set as the startup form closes, even if other forms are open. Select When last form closes to specify that
the application exit when the last form is closed or when My.Application.Exit or the End statement is called
explicitly.
Select On explicit shutdown to specify that the application exit when you explicitly call Shutdown .
Select On last window close to specify that the application exit when the last window closes or when you
explicitly call Shutdown . This is the default setting.
Select On main window close to specify that the application exit when the main window closes or when you
explicitly call Shutdown .
Splash screen Select the form that you want to use as a splash screen. You must have previously created a
splash screen by using a form or a template. The default is (None) .
View Application Events Click this button to display an events code file in which you can write events for the
application framework events Startup , Shutdown , UnhandledException , StartupNextInstance and
NetworkAvailabilityChanged . You can also override certain application framework methods. For example, you can
change the display behavior of the splash screen by overriding OnInitialize .
Windows Application Framework Properties for Windows Presentation Foundation (WPF ) Applications
The following settings are available in the Windows application framework proper ties section when the
project is a Windows Presentation Foundation application. These options are available only if the Enable
application framework check box is selected. The options listed in this table are available only for WPF
applications or WPF browser applications. They are not available for WPF User Control or Custom Control
libraries.
Shutdown mode This property is applicable only to Windows Presentation Foundation applications.
Select On explicit shutdown to specify that the application exit when you explicitly call Shutdown.
Select On last window close to specify that the application exit when the last window closes or when you
explicitly call Shutdown. This is the default setting.
Select On main window close to specify that the application exit when the main window closes or when you
explicitly call Shutdown.
For more information about using this setting, see Shutdown
Edit XAML Click this button to open and modify the application definition file (Application.xaml) in the XAML
editor. When you click this button, Application.xaml opens at the application definition node. You might have to
edit this file to perform certain tasks, such as defining resources. If the application definition file does not exist, the
Project Designer creates one.
View Application Events Click this button to display the Application partial class file (Application.xaml.vb) in a
code editor. If the file does not exist, the Project Designer creates one with the appropriate class name and
namespace.
The Application object raises events when certain application state changes occur (for example, on application
startup or shutdown). For a full list of the events that this class exposes, see Application. These events are handled
in the user code section of the Application partial class.

See Also
Managing Application Properties Writing Code in Office Solutions
Assembly Information Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Assembly Information dialog box is used to specify the values of the .NET Framework global assembly
attributes, which are stored in the AssemblyInfo file created automatically with your project. In Solution Explorer ,
the file is located in the My Project node in Visual Basic (click Show All files to view it); it is located under
Proper ties in Visual C#. For more information about assembly attributes, see Attributes.
To access this dialog box, select a project node in Solution Explorer , and then, on the Project menu, click
Proper ties . When the Project Designer appears, click the Application tab. On the Application page, click the
Assembly Information button.

UIElement List
Title Specifies a title for the assembly manifest. Corresponds to AssemblyTitleAttribute.
Description Specifies an optional description for the assembly manifest. Corresponds to
AssemblyDescriptionAttribute.
Company Specifies a company name for the assembly manifest. Corresponds to AssemblyCompanyAttribute.
Product Specifies a product name for the assembly manifest. Corresponds to AssemblyProductAttribute.
Copyright Specifies a copyright notice for the assembly manifest. Corresponds to AssemblyCopyrightAttribute.
Trademark Specifies a trademark for the assembly manifest. Corresponds to AssemblyTrademarkAttribute.
Assembly Version Specifies the version of the assembly. Corresponds to AssemblyVersionAttribute.
File Version Specifies a version number that instructs the compiler to use a specific version for the Win32 file
version resource. Corresponds to AssemblyFileVersionAttribute.
GUID A unique GUID that identifies the assembly. When you create a project, Visual Studio generates a GUID for
the assembly. Corresponds to Guid.
Neutral Language Specifies which culture the assembly supports. Corresponds to
NeutralResourcesLanguageAttribute. The default is (None) .
Make assembly COM-Visible Specifies whether types in the assembly will be available to COM. Corresponds to
ComVisibleAttribute.

See Also
Application Page, Project Designer (Visual Basic) Attributes
Application Page, Project Designer (C#)
1/10/2020 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the Application page of the Project Designer to specify the project's application settings and properties.
To access the Application page, choose a project node (not the Solution node) in Solution Explorer . Then
choose Project , Proper ties on the menu bar. When the Project Designer appears, click the Application tab.

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the
following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For
more information, see Personalizing the IDE.

General Application Settings


The following options enable you to configure general settings for the application.
Assembly name Specifies the name of the output file that will hold the assembly manifest. Changing this
property will also change the Output Name property. You can also make this change from the command line by
using /out (C# Compiler Options). To access this property programmatically, see AssemblyName.
Default namespace Specifies the base namespace for files added to the project.
See namespace for more information about creating namespaces in your code.
To access this property programmatically, see RootNamespace.
Target Framework Specifies the version of the .NET Framework that the application targets. This option can
have different values depending on which versions of the .NET Framework are installed on your computer.
By default, the value is the same as the target framework that you selected in the New Project dialog box.

NOTE
The prerequisite packages listed in the Prerequisites Dialog Box are set automatically the first time that you open the dialog
box. If you subsequently change the project's target framework, you will have to select the prerequisites manually to match
the new target framework.

For more information, see How to: Target a Version of the .NET Framework and Visual Studio Multi-Targeting
Overview.
Application type Specifies the type of application to build. For Windows 8.x Store apps, you can specify
Windows Store App , Class Librar y , or WinMD File . For most other application types, you can specify
Windows Application , Console Application , Class Librar y , Windows Ser vice , or Web Control Librar y .
For a web application project, you must specify Class Librar y .
If you specify the WinMD File option, types can be projected into any Windows Runtime programming
language. By packaging the project's output as a WinMD file, you can code an application in multiple languages
and have code interoperate as if you wrote it all in the same language. You can specify this option for solutions
that target the Windows Runtime libraries, including Windows 8.x Store apps. For more information, see Creating
Windows Runtime Components in C# and Visual Basic.

NOTE
The Windows Runtime can project types so that they appear as native objects in whichever language uses them. For
example, JavaScript applications that interact with Windows Runtime use it as a set of JavaScript objects, and C#
applications use the library as a collection of .NET objects. By packaging the project’s output as a WinMD file, you can take
advantage of the same technology that Windows Runtime uses.

For more information about the Application type property, see /target (C# Compiler Options). For information
about how to access this property programmatically, see OutputType.
Assembly Information Clicking this button displays the Assembly Information Dialog Box.
Star tup object Defines the entry point to be called when the application loads. Generally this is set either to the
main form in your application or to the Main procedure that should run when the application starts. Because
class libraries do not have an entry point, their only option for this property is (Not Set) .
By default, in a WPF Browser Application project, this option is (Not set) . The other option is Projectname.App. In
this kind of project, you have to set the startup URI to load a UI resource when the application starts. To do this,
open the Application.xaml file in your project and set the StartupUri property to a .xaml file in your project, such
as Window1.xaml. For a list of acceptable root elements, see StartupUri. You also have to define a
public static void Main() method in a class in the project. This class will appear in the Star tup object list as
ProjectName.ClassName. You can then select the class as the startup object.
See /main (C# Compiler Options) for more information. To access this property programmatically, see
StartupObject.

Resources
The following options enable you to configure general settings for the application.
Icon and manifest By default, this radio button is selected and the Icon and Manifest options are enabled. This
enables you to select your own icon, or to select different manifest generation options. Leave this radio button
selected unless you are providing a resource file for the project.
Icon Sets the .ico file that you want to use as your program icon. Click the ellipsis button to browse for an existing
graphic, or type the name of the file that you want. See /win32icon (C# Compiler Options) for more information.
To access this property programmatically, see ApplicationIcon.
Manifest Selects a manifest generation option when the application runs on Windows Vista under User Account
Control (UAC). This option can have the following values:
Embed manifest with default settings . Supports the typical manner in which Visual Studio operates on
Windows Vista, which is to embed security information in the application's executable file, specifying that
requestedExecutionLevel be AsInvoker . This is the default option.

Create application without a manifest . This method is known as virtualization. Use this option for
compatibility with earlier applications.
Proper ties\app.manifest . This option is required for applications deployed by ClickOnce or Registration-
Free COM. If you publish an application by using ClickOnce deployment, Manifest is automatically set to
this option.
Resource File Select this radio button when you are providing a resource file for the project. Selecting this
option disables the Icon and Manifest options.
Enter a path name or use the Browse button (...) to add a Win32 resource file to the project.

See Also
Managing Application Properties Writing Code in Office Solutions
Build Events Page, Project Designer (C#)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the Build Events page of the Project Designer to specify build configuration instructions. You can also
specify the conditions under which any post-build events are run. For more information, see How to: Specify Build
Events (C#)and How to: Specify Build Events (Visual Basic).

UIElement List
Configuration This control is not editable in this page. For a description of this control, see Build Page, Project
Designer (C#).
Platform This control is not editable on this page. For a description of this control, see Build Page, Project
Designer (C#).
Pre-build event command line Specifies any commands to execute before the build starts. To type long
commands, click Edit Pre-build to display the Pre-build Event/Post-build Event Command Line Dialog Box.

NOTE
Pre-build events do not run if the project is up to date and no build is triggered.

Post-build event command line Specifies any commands to execute after the build ends. To type long
commands, click Edit Post-build to display the Pre-build Event/Post-build Event Command Line Dialog
Box .

NOTE
Add a call statement before all post-build commands that run .bat files. For example, call C:\MyFile.bat or
call C:\MyFile.bat call C:\MyFile2.bat .

Run the post-build event Specifies the following conditions for the post-build event to run, as shown in the
following table.

O P T IO N RESULT

Always Post-build event will run regardless of whether the build


succeeds.

On successful build Post-build event will run if the build succeeds. Thus, the event
will run even for a project that is up-to-date, as long as the
build succeeds.
O P T IO N RESULT

When the build updates the project output Post-build event will only run when the compiler's output file
(.exe or .dll) is different than the previous compiler output file.
Thus, a post-build event is not run if a project is up-to-date.

See Also
How to: Specify Build Events (Visual Basic) How to: Specify Build Events (C#) Project Properties Reference
Compiling and Building
Pre-build Event/Post-build Event Command Line
Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

You can type pre- or post-build events for the Build Events Page, Project Designer (C#) directly in the edit box, or
you can select pre- and post-build macros from a list of available macros.

NOTE
Pre-build events do not run if the project is up to date and no build is triggered.

UI Element List
Command line edit box Contains the events to run either for pre-build or post-build.

NOTE
Add a statement before all post-build commands that run .bat files. For example,
call call C:\MyFile.bat or
call C:\MyFile.bat call C:\MyFile2.bat .

Macros Expands the edit box to display a list of macros to insert in the command line edit box.
Macro table Lists the available macros and its value. See Macros below for a description of each. You can select
only one macro at a time to insert into the command line edit box.
Inser t Inserts into the command line edit box the macro selected in the macro table.
Macros
You can use any of these macros to specify locations for files, or to get the actual name of the input file in the case
of multiple selections. These macros are not case-sensitive.

M A C RO DESC RIP T IO N

$(ConfigurationName) The name of the current project configuration, for example,


"Debug".

$(OutDir) Path to the output file directory, relative to the project


directory. This resolves to the value for the Output Directory
property. It includes the trailing backslash '\'.

$(DevEnvDir) The installation directory of Visual Studio (defined with drive


and path); includes the trailing backslash '\'.
M A C RO DESC RIP T IO N

$(PlatformName) The name of the currently targeted platform. For example,


"AnyCPU".

$(ProjectDir) The directory of the project (defined with drive and path);
includes the trailing backslash '\'.

$(ProjectPath) The absolute path name of the project (defined with drive,
path, base name, and file extension).

$(ProjectName) The base name of the project.

$(ProjectFileName) The file name of the project (defined with base name and file
extension).

$(ProjectExt) The file extension of the project. It includes the '.' before the
file extension.

$(SolutionDir) The directory of the solution (defined with drive and path);
includes the trailing backslash '\'.

$(SolutionPath) The absolute path name of the solution (defined with drive,
path, base name, and file extension).

$(SolutionName) The base name of the solution.

$(SolutionFileName) The file name of the solution (defined with base name and file
extension).

$(SolutionExt) The file extension of the solution. It includes the '.' before the
file extension.

$(TargetDir) The directory of the primary output file for the build (defined
with drive and path). It includes the trailing backslash '\'.

$(TargetPath) The absolute path name of the primary output file for the
build (defined with drive, path, base name, and file extension).

$(TargetName) The base name of the primary output file for the build.

$(TargetFileName) The file name of the primary output file for the build (defined
as base name and file extension).

$(TargetExt) The file extension of the primary output file for the build. It
includes the '.' before the file extension.

See Also
Specifying Custom Build Events in Visual Studio Build Events Page, Project Designer (C#) How to: Specify Build
Events (Visual Basic) How to: Specify Build Events (C#)
Build Page, Project Designer (C#)
10/18/2019 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the Build page of the Project Designer to specify the project's build configuration properties. This page
applies to Visual C# projects only.
To access the Build page, choose a project node (not the Solution node) in Solution Explorer . Then choose
Project , Proper ties on the menu bar. When the Project Designer appears, click the Build tab.

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the
following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For
more information, see Personalizing the IDE.

Configuration and Platform


The following options enable you to select the configuration and platform to display or modify.

NOTE
With simplified build configurations, the project system determines whether to build a debug or release version. Therefore,
these options are not displayed. For more information, see Debug and Release Project Configurations.

Configuration Specifies which configuration settings to display or modify. The settings can be Active (Debug)
(this is the default), Debug , Release , or All Configurations .
Platform Specifies which platform settings to display or modify. The default setting is Active (Any CPU) . You
can change the active platform using the Configuration Manager . For more information, see How to: Create
and Edit Configurations.

General
The following options enable you to configure several C# compiler settings.
Conditional compilation symbols Specifies symbols on which to perform conditional compilation. Separate
symbols with a semi-colon (“;”). For more information, see /define (C# Compiler Options).
Define DEBUG constant Defines DEBUG as a symbol in all source code files in your app. Selecting this is
equivalent to using the /define:DEBUG command line option.
Define TRACE constant Defines TRACE as a symbol in all source code files in your app. Selecting this is
equivalent to using the /define:TRACE command line option.
Target CPU Specifies the processor to be targeted by the output file. Choose x86 for any 32-bit Intel-compatible
processor, choose x64 for any 64-bit Intel-compatible processor, choose ARM for ARM processors, or choose
Any CPU to specify that any processor is acceptable. Any CPU is the default value for projects, because it allows
the application to run on the broadest range of hardware.
For more information, see /platform (C# Compiler Options).
Prefer 32-bit If the Prefer32-bit check box is selected, the application runs as a 32-bit application on both 32-
bit and 64-bit versions of Windows. If the check box is cleared, the application runs as a 32-bit application on 32-
bit versions of Windows and as a 64-bit application on 64-bit versions of Windows.
If you run an application as a 64-bit application, the pointer size doubles, and compatibility problems can occur
with other libraries that are exclusively 32-bit. It is useful to run a 64-bit application only if it needs more than 4
GB of memory or 64-bit instructions provide a significant performance improvement.
This check box is available only if all of the following conditions are true:
On the Build Page , the Platform target list is set to Any CPU .
On the Application Page , the Output type list specifies that the project is an application.
On the Application Page , the Target framework list specifies the .NET Framework 4.5.
Allow unsafe code Allows code that uses the unsafe keyword to compile. For more information, see
/unsafe (C# Compiler Options).
Optimize code Enable or disable optimizations performed by the compiler to make your output file
smaller, faster, and more efficient. For more information, see /optimize (C# Compiler Options).

Errors and Warnings


The following settings are used to configure the error and warning options for the build process.
Warning level Specifies the level to display for compiler warnings. For more information, see /warn (C#
Compiler Options).
Suppress warnings Blocks the compiler's ability to generate one or more warnings. Separate multiple warning
numbers with a comma or semicolon. For more information, see /nowarn (C# Compiler Options).

Treat Warnings as Errors


The following settings are used to specify which warnings are treated as errors. Select one of the following
options to indicate under what conditions to return an error when the build encounters a warning. For more
information, see /warnaserror (C# Compiler Options).
None Treats no warnings as errors.
Specific warnings Treats the specified warnings as errors. Separate multiple warning numbers with a comma
or semicolon.
All Treats all warnings as errors.

Output
The following settings are used to configure the output options for the build process.
Output path Specifies the location of the output files for this project's configuration. Enter the path of the build
output in this box, or choose the Browse button to specify a path. Note that the path is relative; if you enter an
absolute path, it will be saved as relative. The default path is bin\Debug or bin\Release\. For more information,
see Debug and Release Project Configurations.
With simplified build configurations, the project system determines whether to build a debug or release version.
The Build command from the Debug menu (F5) will put the build in the debug location regardless of the
Output path you specify. However, the Build command from the Build menu puts it in the location you specify.
For more information, see Debug and Release Project Configurations.
XML documentation file Specifies the name of a file into which documentation comments will be processed.
For more information, see /doc (C# Compiler Options).
Register for COM interop Indicates that your managed application will expose a COM object (a COM callable
wrapper) that allows a COM object to interact with your managed application. The Output type property in the
Application page of the Project Designer for this application must be set to Class Librar y in order for the
Register for COM interop property to be available. For an example class that you might include in your Visual
C# application and expose as a COM object, see Example COM Class.
Generate serialization assembly Specifies whether the compiler will use the XML Serializer Generator Tool
(Sgen.exe) to create XML serialization assemblies. Serialization assemblies can improve the startup performance
of XmlSerializer if you have used that class to serialize types in your code. By default, this option is set to Auto ,
which specifies that serialization assemblies be generated only if you have used XmlSerializer to encode types in
your code to XML. Off specifies that serialization assemblies never be generated, regardless of whether your
code uses XmlSerializer. On specifies that serialization assemblies always be generated. Serialization assemblies
are named TypeName .XmlSerializers.dll. For more information, see XML Serializer Generator Tool (Sgen.exe).
Advanced Click to display the Advanced Build Settings Dialog Box (C#) dialog box.

See Also
Project Properties Reference C# Compiler Options
Advanced Build Settings Dialog Box (C#)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the AdvancedBuild Settings dialog box of the Project Designer to specify the project's advanced build
configuration properties. This dialog box applies to Visual C# projects only.

General
The following options enable you to set general advanced settings.
Language Version Specifies the version of the language to use. The feature set is different in each version, so this
option can be used to force the compiler to allow only a subset of the implemented features, or to enable only
those features compatible with an existing standard. This setting has the following options:
ISO-1
Targets the ISO-1 standard features.
default
Targets the current version.
For more information, see /langversion (C# Compiler Options).
Internal Compiler Error Repor ting Specifies whether to report compiler errors to Microsoft. If set to
prompt (the default), you will receive a prompt if an internal compiler error occurs, giving you the option of
sending an error report electronically to Microsoft. If set to send , an error report will be sent automatically.
If set to queue , error reports will be queued. If set to none , the error will be reported only in the compiler's
text output. For more information, see /errorreport (C# Compiler Options).
Check for arithmetic overflow/underflow Specifies whether an integer arithmetic statement that is not
in the scope of the checked or unchecked keywords and that results in a value outside the range of the data
type will cause a run-time exception.For more information, see /checked (C# Compiler Options).
Do not reference mscorlib.dll Specifies whether mscorlib.dll will be imported into your program,
defining the entire System namespace. Check this box if you want to define or create your own System
namespace and objects. For more information, see /nostdlib (C# Compiler Options).

Output
The following options enable you to specify advanced output options.
Debug Info Specifies the type of debugging information generated by the compiler. For information on how to
configure the debug performance of an application, see Making an Image Easier to Debug. This setting has the
following options:
none
Specifies that no debugging information will be generated
full
Enables attaching a debugger to the running program.
pdbonly
Allows source code debugging when the program is started in the debugger but will only display assembler
when the running program is attached to the debugger.
For more information, see /debug (C# Compiler Options).
File Alignment Specifies the size of sections in the output file. Valid values are 512 , 1024 , 2048 , 4096 ,
and 8192 . These values are measured in bytes. Each section will be aligned on a boundary that is a multiple
of this value, affecting the size of the output file. For more information, see /filealign (C# Compiler Options).
DLL Base Address Specifies the preferred base address at which to load a DLL. The default base address
for a DLL is set by the .NET Framework common language runtime. For more information, see /baseaddress
(C# Compiler Options).

See Also
C# Compiler Options Build Page, Project Designer (C#)
Code Analysis, Project Designer
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Contains the code analysis tool that you can opt to run on your code. The tool reports information about your
assemblies, such as violations of the programming and design rules set forth in the Microsoft .NET Framework
Design Guidelines.

UIElement List
Enable Code Analysis Enables or disables code analysis for your project.
Design Rules Enables or disables the design rules. You can also expand this entry to enable or disable individual
rules.
Globalization Rules Enables or disables the globalization rules. You can also expand this entry to enable or disable
individual rules.
Interoperability Rules Enables or disables the interoperability rules. You can also expand this entry to enable or
disable individual rules.
Maintainability Rules Enables or disables the maintainability rules. You can also expand this entry to enable or
disable individual rules.
Mobility Rules Enables or disables the mobility rules. You can also expand this entry to enable or disable individual
rules.
Naming Rules Enables or disables the naming rules. You can also expand this entry to enable or disable individual
rules.
Performance Rules Enables or disables the performance rules. You can also expand this entry to enable or disable
individual rules.
Portability Rules Enables or disables the portability rules. You can also expand this entry to enable or disable
individual rules.
Reliability Rules Enables or disables the reliability rules. You can also expand this entry to enable or disable
individual rules.
Security Rules Enables or disables the security rules. You can also expand this entry to enable or disable individual
rules.
Usage Rules Enables or disables the usage rules. You can also expand this entry to enable or disable individual
rules.

See Also
Code Analysis for Managed Code Warnings Code Analysis for Managed Code Overview Walkthrough: Analyzing
Managed Code for Code Defects
Compile Page, Project Designer (Visual Basic)
10/18/2019 • 9 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the Compile page of the Project Designer to specify compilation instructions. You can also specify advanced
compiler options and pre-build or post-build events on this page.
To access the Compile page, choose a project node (not the Solution node) in Solution Explorer . Then choose
Project , Proper ties on the menu bar. When the Project Designer appears, click the Compile tab.

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the
following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For
more information, see Personalizing the IDE.

Configuration and Platform


The following settings enable you to select the configuration and platform to display or modify.

NOTE
With simplified build configurations, the project system determines whether to build a debug or release version. Therefore,
the Configuration and Platform lists are not displayed. For more information, see Debug and Release Project
Configurations.

Configuration Specifies which configuration settings to display or modify. The settings are Debug (default),
Release , or All Configurations . For more information, see Debug and Release Project Configurations and How
to: Create and Edit Configurations.
Platform Specifies which platform settings to display or modify. You can specify Any CPU (default), x64 , or x86 .
For more information, see Debug and Release Project Configurations.

Compiler Configuration Options


The following settings enable you to set the compiler configuration options.
Build output path Specifies the location of the output files for this project's configuration. Type the path of the
build output in this box, or click the Browse button to select a path. Note that the path is relative; if you enter an
absolute path, it will be saved as relative. The default path is bin\Debug\ or bin\Release\. For more information,
see Debug and Release Project Configurations.
With simplified build configurations, the project system determines whether to build a debug or release version.
The Build command from the Debug menu (F5) will put the build in the debug location regardless of the
Output path you specify. However, the Build command from the Build menu puts it in the location you specify.
For more information, see Debug and Release Project Configurations.
Option explicit Specifies whether to allow implicit declaration of variables. Select On to require explicit
declaration of variables. This causes the compiler to report errors if variables are not declared before they are
used. Select Off to allow implicit declaration of variables.
This setting corresponds to the /optionexplicit compiler option.
If a source code file contains an Option Explicit Statement, the On or Off value in the statement overrides the
Option Explicit setting on the Compile page .
When you create a new project, the Option Explicit setting on the Compile page is set to the value of the
Option Explicit setting in the Options dialog box. To view or change the setting in this dialog box, on the Tools
menu, click Options . In the Options dialog box, expand Projects and Solutions , and then click VB Defaults .
The initial default setting of Option Explicit in VB Defaults is On .
Setting Option Explicit to Off is generally not a good practice. You could misspell a variable name in one or
more locations, which would cause unexpected results when the program is run.
Option strict Specifies whether to enforce strict type semantics. When Option Strict is On , the following
conditions cause a compile-time error:
Implicit narrowing conversions
Late binding
Implicit typing that results in an Object type
Implicit narrowing conversion errors occur when there is an implicit data type conversion that is a
narrowing conversion. For more information, see Option Strict Statement, Implicit and Explicit Conversions,
and Widening and Narrowing Conversions.
An object is late bound when it is assigned to a property or method of a variable that is declared to be of
type Object . For more information, see Option Strict Statement and Early and Late Binding.
Implicit object type errors occur when an appropriate type cannot be inferred for a declared variable, so a
type of Object is inferred. This primarily occurs when you use a Dim statement to declare a variable
without using an As clause, and Option Infer is off. For more information, see Option Strict Statement,
Option Infer Statement, and the Visual Basic Language Specification.
The Option Strict setting corresponds to the /optionstrict compiler option.
If a source code file contains an Option Strict Statement, the On or Off value in the statement overrides
the Option Strict setting on the Compile page .
When you create a project, the Option Strict setting on the Compile page is set to the value of the
Option Strict setting in the Options dialog box. To view or change the setting in this dialog box, on the
Tools menu, click Options . In the Options dialog box, expand Projects and Solutions , and then click
VB Defaults . The initial default setting of Option Strict in VB Defaults is Off .
Option Strict Individual Warnings. The Warning configurations section of the Compile page has
settings that correspond to the three conditions that cause a compile-time error when Option Strict is
on. Following are these settings:
Implicit conversion
Late binding; call could fail at run time
Implicit type; object assumed
When you set Option Strict to On , all three of these warning configuration settings are set to Error .
When you set Option Strict to Off , all three settings are set to None .
You can individually change each warning configuration setting to None , Warning , or Error . If all three
warning configuration settings are set to Error , On appears in the Option strict box. If all three are set
to None , Off appears in this box. For any other combination of these settings, (custom) appears.
Option compare Specifies the type of string comparison to use. Select Binar y to instruct the compiler to
use binary, case-sensitive string comparisons. Select Text to use locale-specific, case-insensitive text string
comparisons.
This setting corresponds to the /optioncompare compiler option.
If a source code file contains an Option Compare Statement, the Binary or Text value in the statement
overrides the Option Compare setting on the Compile page .
When you create a project, the Option Compare setting on the Compile page is set to the value of the
Option Compare setting in the Options dialog box. To view or change the setting in this dialog box, on
the Tools menu, click Options . In the Options dialog box, expand Projects and Solutions , and then
click VB Defaults . The initial default setting of Option Compare in VB Defaults is Binar y .
Option infer Specifies whether to allow local type inference in variable declarations. Select On to allow
the use of local type inference. Select Off to block local type inference.
This setting corresponds to the /optioninfer compiler option.
If a source code file contains an Option Infer Statement, the On or Off value in the statement overrides
the Option Infer setting on the Compile page .
When you create a project, the Option Infer setting on the Compile page is set to the value of the
Option Infer setting in the Options dialog box. To view or change the setting in this dialog box, on the
Tools menu, click Options . In the Options dialog box, expand Projects and Solutions , and then click
VB Defaults . The initial default setting of Option Infer in VB Defaults is On .
Target CPU Specifies the processor to be targeted by the output file. Specify x86 for any 32-bit Intel-
compatible processor, x64 for any 64-bit Intel-compatible processor, ARM for any ARM processor, or Any
CPU to specify that any processor is acceptable. Any CPU is the default value for new projects because it
allows the application to run on the largest number of hardware types.
For more information, see /platform (Visual Basic).
Prefer 32-bit If the Prefer32-bit check box is selected, the application runs as a 32-bit application on
both 32-bit and 64-bit versions of Windows. Otherwise, the application runs as a 32-bit application on 32-
bit versions of Windows and as a 64-bit application on 64-bit versions of Windows.
Running as a 64-bit application doubles the pointer size, and it can cause compatibility problems with
libraries that are exclusively 32-bit. It makes sense to run an application as 64-bit only if it runs
significantly faster or needs more than 4 GB of memory.
This check box is available only if all of the following conditions are true:
On the Compile Page , the Target CPU list is set to Any CPU .
On the Application Page , the Application type list specifies that the project is an application.
On the Application Page , the Target framework list specifies the .NET Framework 4.5.
Warning configurations This table lists build conditions and the corresponding notification level of
None , Warning , or Error for each.
By default, all compiler warnings are added to the Task List during compilation. Select Disable all
warnings to instruct the compiler not to issue warnings or errors. Select Treat all warnings as errors if
you want the compiler to treat warnings as errors that must be fixed.
Disable all warnings Specifies whether to allow the compiler to issue notifications as specified in the
Condition and Notification table described earlier in this document. By default, this check box is
cleared. Select this check box to instruct the compiler not to issue warnings or errors.
This setting corresponds to the /nowarn compiler option.
Treat all warnings as errors Specifies how to treat warnings. By default, this check box is cleared, so
that all warning notifications remain set to Warning . Select this check box to change all warning
notifications to Error .
This option is available only if Disable all warnings is cleared.
Generate XML documentation file Specifies whether to generate documentation information. By
default, this check box is selected, instructing the compiler to generate documentation information and
include it in an XML file. Clear this check box to instruct the compiler not to create documentation.
This setting corresponds to the /doc compiler option.
Register for COM interop Specifies whether your managed application will expose a COM object (a
COM-callable wrapper) that enables a COM object to interact with the application.
By default, this check box is cleared, which specifies that the application will not allow COM interop. Select
this check box to allow COM interop.
This option is not available for Windows Application or Console Application projects.
Build Events Click this button to access the Build Events dialog box. Use this dialog box to specify pre-
build and post-build configuration instructions for the project. This dialog box applies to Visual Basic
projects only. For more information, see Build Events Dialog Box (Visual Basic).
Advanced Compile Options Click this button to access the AdvancedCompiler Settings dialog box.
Use the AdvancedCompiler Settings dialog box to specify a project's advanced build configuration
properties. This dialog box applies to Visual Basic projects only. For more information, see Advanced
Compiler Settings Dialog Box (Visual Basic).

See Also
Debug and Release Project Configurations Managing Compilation Properties How to: Specify Build Events (Visual
Basic) Visual Basic Command-Line Compiler How to: Create and Edit Configurations
Advanced Compiler Settings Dialog Box (Visual Basic)
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the AdvancedCompiler Settings dialog box of the Project Designer to specify the project's advanced
build-configuration properties. This dialog box applies to Visual Basic projects only.
To access this dialog box
1. In Solution Explorer , choose a project node (not the Solution node).
2. On the Project menu, click Proper ties . When the Project Designer appears, click the Compile tab.
3. On the Compile Page, Project Designer (Visual Basic), select the Configuration and Platform . In simplified
build configurations, the Configuration and Platform lists are not displayed. For more information, see
Debug and Release Project Configurations.
4. Click Advanced Compile Options .

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the
following instructions. The Visual Studio edition that you have and the settings that you use determine these
elements. For more information, see Personalizing the IDE.

Optimizations
The following options specify optimizations that can in some cases make a program file smaller, make a program
run faster, or speed up the build process.
Remove integer overflow checks By default, this check box is cleared to enable integer overflow checking.
Select this check box to remove integer overflow checking. If you select this check box, integer calculations might
be faster. However, if you remove overflow checking and data type capacities overflow, incorrect results might be
stored without an error being raised.
If overflow conditions are checked and an integer operation overflows, an OverflowException exception is thrown.
If overflow conditions are not checked, integer operation overflows do not throw an exception.
Enable optimizations By default, this check box is cleared to disable compiler optimizations. Select this check box
to enable compiler optimizations. Compiler optimizations make your output file smaller, faster, and more efficient.
However, because optimizations cause code rearrangement in the output file, compiler optimizations can make
debugging difficult.
DLL base address This text box displays the default DLL base address in hexadecimal format. In Class Library and
Control Library projects, you can use this text box to specify the base address to be used when the DLL is created.
Generate debug info Select None , Full , or pdb-only from the list. None specifies that no debugging
information be generated. Full specifies that full debugging information be generated, and pdb-only specifies that
only PDB debugging information be generated. By default, this option is set to Full .
Compilation Constants
Conditional compilation constants have an effect similar to that of using a #Const preprocessor directive in a
source file, except that constants defined are public and apply to all files in the project. You can use conditional
compilation constants together with the #If...Then...#Else directive to compile source files conditionally. See
Conditional Compilation.
Define DEBUG constant By default, this check box is selected, specifying that a DEBUG constant be set.
Define TRACE constant By default, this check box is selected, specifying that a TRACE constant be set.
Custom constants Enter any custom constants for your application in this text box. Entries should be delimited by
commas, using this form: Name1="Value1",Name2="Value2",Name3="Value3" .

Other Settings
Generate serialization assemblies This setting specifies whether the compiler will create XML serialization
assemblies. Serialization assemblies can improve the startup performance of XmlSerializer if you have used that
class to serialize types in your code. By default, this option is set to Auto , which specifies that serialization
assemblies be generated only if you have used XmlSerializer to encode types in your code to XML. Off specifies
that serialization assemblies never be generated, regardless of whether your code uses XmlSerializer. On specifies
that serialization assemblies always be generated. Serialization assemblies are named TypeName .XmlSerializers.dll.

See Also
Compile Page, Project Designer (Visual Basic)
Build Events Dialog Box (Visual Basic)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the Build Events dialog box to specify build configuration instructions. You can also specify the conditions
under which any pre-build or post-build events are run. For more information, see How to: Specify Build Events
(Visual Basic).
Pre-build event command line Specifies any commands to execute before the build starts. To type long
commands, click Edit Pre-build to display the Pre-build Event/Post-build Event Command Line Dialog Box.

NOTE
Pre-build events do not run if the project is up-to-date and no build is triggered.

Post-build event command line Specifies any commands to execute after the build ends. To type long
commands, click Edit Post-build to display the Pre-build Event/Post-build Event Command Line d ialog box.

NOTE
Add a call statement before all post-build commands that run .bat files. For example, call C:\MyFile.bat or
call C:\MyFile.bat call C:\MyFile2.bat .

Run the post-build event Specifies the conditions for the post-build event to run, as shown in the following
table.

O P T IO N RESULT

Always Post-build event will run, regardless of whether the build


succeeds.

On successful build Post-build event will run if the build succeeds. The event will
run even for a project that is up-to-date, as long as the build
succeeds. This is the default setting.

When the build updates the project output Post-build event will run only when the compiler's output file
(.exe or .dll) differs from the previous compiler output file. A
post-build event is not run if a project is up-to-date.

See Also
Compile Page, Project Designer (Visual Basic) How to: Specify Build Events (Visual Basic) Pre-build Event/Post-build
Event Command Line Dialog Box
Debug Page, Project Designer
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

WARNING
This topic does not apply to Windows Store apps. See Start a debug session (VB, C#, C++ and XAML) in the Windows Dev
Center.

Use the Debug page of the Project Designer to set properties for debugging behavior in a Visual Basic or C#
project.
To access the Debug page, select a project node in Solution Explorer . On the Project menu, choose
ProjectNameProper ties . When the Project Designer appears, click the Debug tab.

Configuration and Platform


The following options allow you to select the configuration and platform to display or modify.
Configuration Specifies which configuration settings to display or modify. The settings can be Debug (default),
Release , or All Configurations . For more information, see Debug and Release Project Configurations.
Platform Specifies which platform settings to display or modify. The choices can include Any CPU (default), x64 ,
and x86 . For more information, see Debug and Release Project Configurations.

Start Action
Star t Action indicates the item to start when the application is debugged: the project, a custom program, a URL,
or nothing. By default, this option is set to Star t project . The Star t Action setting on the Debug page determines
the value of the StartAction property.
Star t project Choose this option to specify that the executable (for Windows Application and Console Application
projects) should be started when the application is debugged. This option is selected by default.
Star t external program Choose this option to specify that a specific program should be started when the
application is debugged.
Star t browser with URL Choose this option to specify that a particular URL should be accessed when the
application is debugged.

Start Options
Command line arguments In this text box, enter the command-line arguments to use for debugging.
Working director y In this text box, enter the directory from which the project will be launched. Or click the
Browse button (...) to choose a directory.
Use remote machine To debug the application from a remote computer, select this check box, and enter the path
to the remote computer in the text box.

Enable Debuggers
Enable unmanaged code debugging This option specifies whether debugging of native code is supported.
Select this check box if you are making calls to COM objects or if you start a custom program written in native code
that calls your project and you must debug the native code. Clear this check box to disable debugging of
unmanaged code. This check box is cleared by default.
Enable SQL Ser ver debugging Select or clear this check box to enable or disable debugging of SQL procedures
from your Visual Basic application. This check box is cleared by default.
Enable the Visual Studio hosting process Select this check box to enable the Visual Studio hosting process.
This check box is selected by default. For more information, see Hosting Process (vshost.exe).
To debug in a security zone, you must enable this option and Debug this application with the selected
permission set in the Advanced Security Settings Dialog Box.

See Also
Debugging in Visual Studio Project Settings for C# Debug Configurations Project Settings for a Visual Basic Debug
Configuration Managing Debugging Properties How to: Debug a ClickOnce Application with Restricted Permissions
How to: Create and Edit Configurations
My Extensions Page, Project Designer (Visual Basic)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the My Extensions page of the Project Designer to manage My namespace extensions in your project. My
namespace extensions enable you to customize the My namespace to add your own custom members. For
information about creating custom My namespace extensions, see Extending the My Namespace in Visual Basic.
To access the My Extensions page, double-click My Project for your project node in Solution Explorer . When
the Project Designer appears, click the My Extensions tab.

UIElement List
The following options enable you to add or remove My namespace extensions in your project. A My namespace
extension must first be installed as a Visual Studio Item template to be available to be added. For information about
publishing and installing My namespace extensions, see Packaging and Deploying Custom My Extensions.
My namespace extensions This list shows all the My namespace extensions installed in the project.
Add Extension Click this button to add an installed My namespace extension to your project. A list of all possible
My namespace extensions will appear. Select the My namespace extension that you want to add to your project
and click OK to add it.
Remove Extension Select one or more references in the My namespace extensions list, and then click this
button to remove the My namespace extension from the project.

See Also
Extending the My Namespace in Visual Basic Packaging and Deploying Custom My Extensions Extending the Visual
Basic Application Model Customizing Which Objects are Available in My
Publish Page, Project Designer
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Publish page of the Project Designer is used to configure properties for ClickOnce deployment.
To access the Publish page, select a project node in Solution Explorer , and then, on the Project menu, click
Proper ties . When the Project Designer appears, click the Publish tab.

NOTE
Some of the ClickOnce properties described here can also be set in the PublishWizard , available from the Build menu or
by clicking the PublishWizard button on this page.

UIElement List
Publishing Folder Location Specifies the location where the application is published. Can be a drive path (
C:\deploy\myapplication ), a file share ( \\server\myapplication ), an FTP server (
ftp://ftp.microsoft.com/myapplication ), or a Web site ( http://www.microsoft.com/myapplication ). Note that text
must be present in the Publishing Location box in order for the browse (...) button to work.
By default, the publishing location is http://localhost/<projectname>/ if you have IIS installed, or the publish\
directory if you do not have IIS installed. If your computer is running Windows Vista, the default is always the
publish\ directory, regardless of whether you have IIS installed.

Installation Folder URL Optional. Specifies a Web site to which users go to install the application. This is
necessary only when it differs from the Publishing Location , for example, when the application is published to a
staging server.
Install Mode and Settings Determines whether the application is run directly from the Publishing Location
(when The application is available online only is selected) or is installed and added to the Star t menu and the
Add or Remove Programs item in Control Panel (when The application is available offline as well is
selected).
For WPF Web Browser Applications, the The application is available offline as well option is disabled,
because such applications are available only online.
Application Files Opens the Application Files Dialog Box, which is used to specify how and where individual files
are installed.
Prerequisites Opens the Prerequisites Dialog Box, which is used to specify prerequisite components, such as the
.NET Framework, to be installed together with the application.
Updates Opens the Application Updates Dialog Box, which is used to specify update behavior for the application.
Not available when The application is available online only is selected.
Options Opens the Publish Options Dialog Box, which is used to specify additional advanced publishing options.
Publish Version Sets the publish version number for the application; when the version number is changed, the
application is published as an update. Each part of the publish version (Major , Minor , Build , Revision ) can have a
maximum value of 65355 (MaxValue), the maximum allowed by Version.
When you install more than one version of an application by using ClickOnce, the installation moves earlier
versions of the application into a folder named Archive, in the publish location that you specify. Archiving earlier
versions in this manner keeps the installation directory clear of folders from the earlier version.
Automatically increment revision with each publish Optional. When this option is selected (the default), the
Revision part of the publish version number is incremented by one every time that the application is published.
This causes the application to be published as an update.
Publish Wizard Opens the Publish Wizard. Completing the Publish Wizard has the same effect as running the
Publish command on the Build menu.
Publish Now Publishes the application using the current settings. Equivalent to the Finish button in the
PublishWizard .

See Also
Publishing ClickOnce Applications How to: Publish a ClickOnce Application using the Publish Wizard How to:
Specify Where Visual Studio Copies the Files How to: Specify the Location Where End Users Will Install From How
to: Specify a Link for Technical Support How to: Specify the ClickOnce Offline or Online Install Mode How to:
Enable AutoStart for CD Installations How to: Set the ClickOnce Publish Version How to: Automatically Increment
the ClickOnce Publish Version How to: Specify Which Files Are Published by ClickOnce How to: Install Prerequisites
with a ClickOnce Application How to: Manage Updates for a ClickOnce Application How to: Change the Publish
Language for a ClickOnce Application How to: Specify a Start Menu Name for a ClickOnce Application How to:
Specify a Publish Page for a ClickOnce Application ClickOnce Security and Deployment
Prerequisites Dialog Box
1/10/2020 • 7 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This dialog box specifies which prerequisite components are installed, how they are installed, and which order the
packages are installed.
To access this dialog box, select a project node in Solution Explorer , and then, on the Project menu, click
Proper ties . When the Project Designer appears, click the Publish tab. On the Publish page, click
Prerequisites . For Setup projects, on the Project menu, click Proper ties . When the Proper ty Pages dialog box
appears, click Prerequisites .

UIElement List
EL EM EN T DESC RIP T IO N

Create setup program to install prerequisite Includes the prerequisite components in your application's
components Setup program (Setup.exe) so that they will be installed before
your application, in order of dependency. By default, this
option is selected. If it is not selected, no Setup.exe is created.

Choose which prerequisites to install Specifies whether to install components such as .NET
Framework, Crystal Reports, and so on.

For example, by selecting the check box next to SQL Ser ver
2005 Express Edition SP2 , you specify that the Setup
program verify whether this component is installed on the
target computer and install it if it is not already installed.

For detailed information about each prerequisite package, see


the Prerequisites Information table later in this topic.

Check Microsoft Update for more redistributable Clicking this link takes you to the Bootstrapper Packages to
components Redistribute Components website to check for updates.

Download prerequisites from the component vendor's Specifies that the prerequisite components be installed from
web site the vendor's Web site. This is the default option.

Download prerequisites from the same location as my Specifies that the prerequisite components be installed from
application the same location as the application. This copies all the
prerequisite packages to the publish location. For this option
to work, the prerequisite packages must be on the
development computer.

Download prerequisites from the following location Specifies that the prerequisite components be installed from
the location that you select. You can use the Browse button
to select a location.
Prerequisites Information
The prerequisite components that appear in the Prerequisites dialog box might differ from those in the following
list. The prerequisite packages listed in the Prerequisites Dialog Box are set automatically the first time that you
open the dialog box. If you subsequently change the project's target framework, you will have to select the
prerequisites manually to match the new target framework.

EL EM EN T DESC RIP T IO N

.NET Framework 3.5 SP1 This package installs the following:

- .NET Framework versions 2.0, 3.0, and 3.5.


- Support for all .NET Framework versions on 32-bit (x86) and
64-bit (x64) operating systems.
- Language packs for each .NET Framework version that is
installed with the package.
- Service packs for .NET Framework 2.0 and 3.0.

.NET Framework 3.0 is included with Windows Vista, and .NET


Framework 3.5 is included with Visual Studio. .NET Framework
3.5 is required for all Visual Basic and Visual C# projects that
are compiled for 32-bit operating systems and for which the
target framework is set to .NET Framework 3.5 , and for
Visual Basic and Visual C# projects compiled for 64-bit
operating systems. (IA64 is not supported.) Note that Visual
Basic and Visual C# projects are compiled for any CPU
architecture by default. For more information, see Visual
Studio Multi-Targeting Overview, Redistributing the .NET
Framework, and Deploying Prerequisites for 64-bit
Applications.

By default, this item is selected.

.NET Framework 3.5 SP1 Client Profile The .NET Framework Client Profile is a subset of the full .NET
Framework 3.5 SP1 that targets client applications. It provides
a streamlined subset of Windows Presentation Foundation
(WPF), Windows Forms, Windows Communication Foundation
(WCF), and ClickOnce features. This enables rapid deployment
scenarios for WPF, Windows Forms, WCF, and console
applications that target the .NET Framework Client Profile. For
more information, see .NET Framework Client Profile.

Microsoft .NET Framework 4 (x86 and x64) This package installs the .NET Framework 4 for both the x86
and x64 platforms.

For more information, see Visual Studio Multi-Targeting


Overview, Redistributing the .NET Framework, and Deploying
Prerequisites for 64-bit Applications.

By default, this item is selected.

Microsoft .NET Framework 4 Client Profile (x86 and The .NET Framework 4 Client Profile is a subset of the full .NET
x64) Framework 4 that targets client applications. It provides a
streamlined subset of Windows Presentation Foundation
(WPF), Windows Forms, Windows Communication Foundation
(WCF), and ClickOnce features. This enables rapid deployment
scenarios for WPF, Windows Forms, and console applications
that target the .NET Framework 4 Client Profile. For more
information, see .NET Framework Client Profile.
EL EM EN T DESC RIP T IO N

Microsoft Office 2007 Primar y Interop Assemblies This package installs the Primary Interop Assemblies for 2007
Microsoft Office products. The primary interop assembly
enables managed code to interact with a Microsoft Office
application's COM-based object model. For more information,
see Office Primary Interop Assemblies.

Microsoft Visual Basic PowerPacks version 10.0 Power Packs are add-ins, controls, components, and tools to
aid you in developing Visual Basic applications. This version
contains the PrintForm component, which enables you to
print the contents of a Windows Form, and the Printer
Compatibility Library, which enables Visual Basic 6.0 Printer
code to run unmodified.

Microsoft Visual F# Runtime for .NET 2.0 This package installs the Visual F# run-time libraries for the
x86 and x64 operating systems, which provide support for
functional programming as well as traditional object-oriented
and imperative (procedural) programming. This package must
be installed if the application or its components is authored in
Visual F# and .NET Framework 2.0, .NET Framework 3.0, or
.NET Framework 3.5.

For more information, see F# Language Reference.

Microsoft Visual F# Runtime for .NET 4.0 This package installs the Visual F# run-time libraries for the
x86 and x64 operating systems, which provide support for
functional programming as well as traditional object-oriented
and imperative (procedural) programming. This package must
be installed if the application or its components is authored in
Visual F# and .NET Framework 4.

For more information, see F# Language Reference.

Microsoft Visual Studio 2010 Repor t Viewer This package installs report viewer controls that you can use
to add rich data reporting to Windows Forms and ASP.NET
applications.

Microsoft Visual Studio 2010 for Office Runtime (x86 The Office developer tools in Visual Studio offers easy-to-use,
and x64) integrated tools for creating customized business solutions
with Microsoft Office. You can create managed, smart client
solutions that use Office applications as a user interface. The
tools enable developers to create secure solutions that are
easy to deploy and maintain.

For more information, see How to: Publish an Office Solution


by Using ClickOnce.

SQL Ser ver 2005 Express Edition SP2 (x86) This package installs Microsoft SQL Server 2005 Express
Edition SP2, a database application that is based on Microsoft
SQL Server 2005. SQL Server Express is a replacement for
Microsoft SQL Server Desktop Engine (MSDE). SQL Server
Express is free and can be redistributed (subject to
agreement), and it functions as both a client database and a
basic server database. It is the same as SQL Server 2005,
except for the following differences:

- No enterprise features support.


- Limited to one CPU.
- 1 gigabyte (GB) memory limit for the buffer pool.
- 4 GB maximum size for databases.
EL EM EN T DESC RIP T IO N

SQL Ser ver 2008 Express This package installs Microsoft SQL Server 2008 Express, a
free edition of Microsoft SQL Server 2008, an ideal database
for small web, server or desktop applications. It can be used
for free for development and production. A free registration is
required for distributing SQL Server 2008 Express with the
application.

The behavior of the bootstrapper is the following:

- If the computer already has SQL Server 2008 Express or


later, the computer remains at SQL Server 2008 Express or
later.
- If the computer does not have any version of SQL Server
2008 Express or later, the package installs the latest version of
SQL Server 2008 Express SP1.

To learn more about SQL Server 2008 Express, visit


http://go.microsoft.com/fwlink/?LinkId=183586.

Visual C++ 2010 Runtime Libraries (IA64) This package installs the Visual C++ run-time libraries for the
Itanium architecture, which provide routines for programming
for the Microsoft Windows operating system. These routines
automate many common programming tasks that are not
provided by the C and C++ languages.

For more information, see C Run-Time Library Reference.

Visual C++ 2010 Runtime Libraries (x64) This package installs the Visual C++ run-time libraries for the
x64 operating systems, which provide routines for
programming for the Microsoft Windows operating system.
These routines automate many common programming tasks
that are not provided by the C and C++ languages.

For more information, see C Run-Time Library Reference.

Visual C++ 2010 Runtime Libraries (x86) This package installs the Visual C++ run-time libraries for the
x86 operating systems, which provide routines for
programming for the Microsoft Windows operating system.
These routines automate many common programming tasks
that are not provided by the C and C++ languages.

For more information, see C Run-Time Library Reference.

Windows Installer 3.1 This package installs the Microsoft Windows Installer
redistributable, version 3.1, which allows the installation of
Windows Installer Setup projects. It is preinstalled on
Windows Server 2003 with SP1 and later.

By default, this item is selected.

Windows Installer 4.5 This package installs the Microsoft Windows Installer
redistributable, version 4.5, which allows the installation of
Windows Installer Setup projects.

See Also
Publish Page, Project Designer Application Deployment Prerequisites Redistributing the .NET Framework
Deploying Prerequisites for 64-bit Applications Visual Studio Multi-Targeting Overview
References Page, Project Designer (Visual Basic)
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the References page of the Project Designer to manage references, Web references, and imported
namespaces in your project. Projects can contain references to COM components, XML Web services, .NET
Framework class libraries or assemblies, or other class libraries. For more information on using references, see
Managing references in a project.
To access the References page, choose a project node (not the Solution node) in Solution Explorer . Then
choose Project , Proper ties on the menu bar. When the Project Designer appears, click the References tab.

UIElement List
The following options allow you to select or remove references and imported namespaces in your project.
Unused References Click this button to access the Unused References dialog box.
The Unused References dialog box allows you to remove references that are included in your project but not
actually used by the code. It contains a grid that lists the Reference Name , the Path , and other information about
the unused namespace references in your project. In the grid, select the namespace references that you want to
remove from your project and click Remove .
Reference Paths Click this button to access the Reference Paths dialog box.

NOTE
When the project system finds an assembly reference, the system resolves the reference by looking in the following locations,
in the following order:
1. The project folder. The project folder files appear in Solution Explorer when Show All Files isn't in effect. 2. Folders that
are specified in the Reference Paths dialog box. 3. Folders that display files in the Add Reference dialog box. 4. The
project's obj folder. (When you add a COM reference to your project, one or more assemblies may be added to the
project's obj folder.)

References This list shows all references in the project, used or unused.
Add Click this button to add a reference or Web reference to the References list.
Choose Reference to add a reference to your project using the Add Reference dialog box.
Choose Web Reference to add a Web reference to your project using the Add Web Reference dialog box.
Remove Select one or more references in the References list, then click this button to delete it.
Update Web Reference Select a Web reference in the References list and click this button to update it.
Impor ted namespaces You can type your own namespace in this box and click Add User Impor t to add it to
the namespaces list.
You can create aliases for user-imported namespaces. To do this, enter the alias and the namespace in the format
alias=namespace. This is useful if you are using long namespaces, for example:
Http= MyOrg.ObjectLib.Internet.WebRequestMethods.Http .

Add User Impor t Click this button to add the namespace specified in the Impor ted namespaces box to the list
of imported namespaces. The button is active only if the specified namespace is not already in the list.
Namespaces list This list shows all available namespaces. The check boxes for namespaces included in your
project are selected.
Update User Impor t Select a user-specified namespace in the namespaces list, type the name that you want to
replace it with in the Impor ted namespaces box, and then click this button to change to the new namespace. The
button is active only if the selected namespace is one that you added to the list by using the Add User Impor t
button. You can add:
Classes or namespaces, such as System.Math.
Aliased imports, such as VB=Microsoft.VisualBasic .
XML namespaces, such as <xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> .

See Also
NIB How to: Add or Remove References By Using the Add Reference Dialog Box How to: Add or Remove Imported
Namespaces (Visual Basic) NIB: Add Web Reference Dialog Box Imports Statement (XML Namespace)
Security Page, Project Designer
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Security page of the Project Designer is used to configure code access security settings for applications that
are deployed by using ClickOnce deployment. For more information, see Code Access Security for ClickOnce
Applications.
To access the Security page, click a project node in Solution Explorer , and then, on the Project menu, click
Proper ties . When the Project Designer appears, click the Security tab.

Security Settings
Enable ClickOnce Security Settings Determines whether security settings are enabled at design time. When
this option is cleared, all other options on the Security page are unavailable.

NOTE
When you publish an application by using the Publish wizard, this option is automatically enabled.

When you select this option, you have the choice of selecting one of two radio buttons: This is a full trust
application or This is a par tial trust application .
By default, for WPF Web Browser Application projects, this option is selected.
By default, for all other project types, this option is cleared.
This is a full trust application If you select this option, the application requests Full Trust permissions when it is
installed or run on a client computer. Avoid using Full Trust if possible, because your application will be granted
unrestricted access to resources such as the file system and the registry.
By default, for WPF Web Browser Application projects, this option is set to Partial Trust.
By default, for all other project types, this option is set to Full Trust.
This is a par tial trust application If you select this option, the application requests Partial Trust permissions
when it is installed or run on a client computer. Partial Trust means that only the actions that are permitted under
the requested code access security permissions will run. For more information about how to configure security
permissions, see Code Access Security for ClickOnce Applications.
You can specify the Partial Trust security settings by configuring the options in the ClickOnce Security
Permissions area.

ClickOnce Security Permissions


Zone your application will be installed from Specifies a default set of code-access security permissions.
Choose Internet or Local Intranet for a restricted permission set, or choose (Custom) to configure a custom
permission set. If the application requests more permissions than granted in a zone, a ClickOnce trust prompt
appears for the end user to grant the additional permissions. For more information about how to configure
security permissions, see Code Access Security for ClickOnce Applications.
By default, for WPF Web Browser Application projects, this option is set to Internet .
Edit Permissions XML Opens the application manifest template (app.manifest) to configure the permissions for
the (Custom) permission set.
Advanced Opens the Advanced Security Settings Dialog Box, which is used to configure settings for debugging
the application with restricted permissions. These settings are checked during debugging, and permission
exceptions indicate that your application may need more permissions than defined in a zone.

See Also
WebBrowserPermission MediaPermission Code Access Security for ClickOnce Applications How to: Enable
ClickOnce Security Settings How to: Set a Security Zone for a ClickOnce Application How to: Set Custom
Permissions for a ClickOnce Application How to: Debug a ClickOnce Application with Restricted Permissions
ClickOnce Security and Deployment Project Properties Reference Advanced Security Settings Dialog Box
Advanced Security Settings Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This dialog box allows you to specify security settings related to debugging in zone.
To access this dialog box, select a project node in Solution Explorer , and then, on the Project menu, click
Proper ties . When the Project Designer appears, click the Security tab. On the Security page, select Enable
ClickOnce Security Settings , click This is a par tial trust application , and then click Advanced .

UIElement List
Debug this application with the selected permission set If you select this check box, the permission set
selected on the Security page is used during debugging. By default, this option is selected.
For debugging in a security zone to work, this option must be enabled; also, the Enable the Visual Studio
hosting process option (available on the Debug page of the Project Designer ) must be enabled.
For WPF Web Browser Application projects, the Debug this application with the selected permission set
option is checked and disabled.
Grant the application access to its site of origin If you select this check box, the application can access the
Web site or server share on which it is published. By default, this option is selected.
Debug this application as if it were downloaded from the following URL If you have to allow the
application to access the Web site or server share corresponding to the Installation URL you specified on the
Publish page, type that URL here. This option is available only when Grant the application access to its site
of origin is selected.

See Also
Security Page, Project Designer
Services Page, Project Designer
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Client application services provide simplified access to Microsoft Ajax login, roles, and profile services from
Windows Forms and Windows Presentation Foundation (WPF) applications. You can use the Ser vices page of the
Project Designer to enable and configure client application services for your project.
With client application services, you can use a centralized server to authenticate users, determine each user's
assigned role or roles, and store per-user application settings that you can share across the network. For more
information, see Client Application Services.
To access the Ser vices page, select a project node in Solution Explorer , and then click Proper ties on the
Project menu. When the Project Designer appears, click the Ser vices tab.

NOTE
Client application services require the full version of the .NET Framework, and are not supported in the .NET Framework
Client Profile. If the Enable client application ser vices check box is disabled, verify that the Target framework is set to
the .NET Framework 3.5 or later. To view the Target framework setting in C#, open the Project Designer and then click the
Application page. To view the Target framework setting in Visual Basic, open the Project Designer, click the Compile
page, and then click Advanced Compile Options .

Task List
How to: Configure Client Application Services

UIElement List
Configuration This control is not editable on this page. For a description of this control, see Compile Page, Project
Designer (Visual Basic) or Build Page, Project Designer (C#).
Platform This control is not editable on this page. For a description of this control, see Compile Page, Project
Designer (Visual Basic) or Build Page, Project Designer (C#).
Enable client application ser vices Select to enable client application services. You must specify service
locations on the Ser vices page to use client application services.
Use Windows authentication Indicates that the authentication provider will use Windows-based authentication,
that is, the identity supplied by the Windows operating system.
Use Forms authentication Indicates that the authentication provider will use forms authentication. This means
that your application must provide a user interface for login. For more information, see How to: Implement User
Login with Client Application Services.
Authentication ser vice location Used only with forms authentication. Specifies the location of the
authentication service.
Optional: Credentials provider Used only with forms authentication. Indicates the
IClientFormsAuthenticationCredentialsProvider implementation that the authentication service will use to display a
login dialog box when your application calls the static System.Web.Security.Membership.ValidateUser method
and passes empty strings or null for the parameters. If you leave this box blank, you must pass a valid user name
and password to the System.Web.Security.Membership.ValidateUser method. You must specify the credentials
provider as an assembly-qualified type name. For more information, see System.Type.AssemblyQualifiedName and
Assembly Names. In its simplest form, an assembly-qualified type name looks similar to the following example:
MyNamespace.MyLoginClass, MyAssembly

Roles ser vice location Specifies the location of the roles service.
Web settings ser vice location Specifies the location of the profile (Web settings) service.
Advanced Opens the Advanced Settings for Services Dialog Box, which you can use to override default behavior.
For example, you can use this dialog box to specify a database for offline storage instead of using the local file
system. For more information, see Advanced Settings for Services Dialog Box.

See Also
Client Application Services Advanced Settings for Services Dialog Box How to: Configure Client Application
Services Compile Page, Project Designer (Visual Basic) Build Page, Project Designer (C#) Introduction to the Project
Designer
Advanced Settings for Services Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Client application services provide simplified access to Microsoft Ajax login, roles, and profile services from
Windows Forms and Windows Presentation Foundation (WPF) applications. You can use the Ser vices page in the
Project Designer to configure client application services. For more information about the Ser vices page, see
Services Page, Project Designer.
Use the Advanced Settings for Ser vices dialog box of the Ser vices page in the Project Designer to
configure advanced settings for client application services. By using these settings, you can override some default
application service behaviors to enable less common scenarios. For more information, see Client Application
Services.
To access the Advanced Settings for Ser vices dialog box, select a project node in Solution Explorer , and then
click Proper ties on the Project menu. When the Project Designer appears, click the Ser vices tab, and then
click the Advanced button. This button will be disabled until you enable client application services.

Task List
How to: Configure Client Application Services
How to: Work Offline with Client Application Services

UIElement List
Save password hash locally to enable offline login Specifies whether an encrypted form of the user's
password will be cached locally to enable the user to log in when the application is in offline mode. For more
information, see How to: Work Offline with Client Application Services. This option is selected by default.
Require users to log on again whenever the ser ver cookie expires Specifies whether previously
authenticated users are automatically reauthenticated when your application accesses the roles or profile service
and the server authentication cookie has expired. Select this option to deny access to the application services and
require explicit reauthentication after the cookie expires. This is useful for applications deployed in public locations
to make sure that users who leave the application running after use will not remain authenticated indefinitely. This
option is cleared by default.
Role ser vice cache timeout Specifies the amount of time the client role provider will use cached role values
instead of accessing the roles service. Set this time interval to a small value when roles are updated frequently or
to a larger value when roles are updated infrequently. The default value is one day.
The role provider accesses the cached role values or the roles service when you call the IsInRole method. To
programmatically clear the cache and force this method to access the remote service, call the ResetCache method.
Use custom connection string Specifies whether the client service providers will use a custom data store for
the local cache. By default, the service providers will use the local file system for the cache. Selecting this option
will automatically populate the text box with a default connection string. You can keep the default connection string
to automatically generate and use a SQL Server Compact Edition database, or you can specify a connection string
to an existing SQL Server database. For more information, see How to: Configure Client Application Services. This
option is cleared by default.

See Also
Client Application Services Services Page, Project Designer How to: Configure Client Application Services How to:
Work Offline with Client Application Services
Signing Page, Project Designer
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the Signing page of the Project Designer to sign the application and deployment manifests and also to sign
the assembly (strong-name signing).
Notice that the signing of application and deployment manifests is a process distinct from the signing of an
assembly, although both tasks are performed on the Signing page.
Also, the storage of key-file information differs for manifest signing and assembly signing. For manifest signing,
key information is stored in your computer's cryptographic storage database and the current user's Windows
certificate store. For assembly signing, key information is stored only in your computer's cryptographic storage
database.
To access the Signing page, select a project node in Solution Explorer , and then, on the Project menu, click
Proper ties . When the Project Designer appears, click the Signing tab.

Application and Deployment Manifest Signing


Sign the ClickOnce manifests check box Select this check box to sign the application and deployment manifests
with a public/private key pair. For more information about how to do this, see How to: Sign Application and
Deployment Manifests.
Select from Store button Allows you to select an existing certificate from the current user's personal certificate
store. You can select one of these certificates to sign your application and deployment manifests.
Clicking Select from Store opens the Select a Cer tificate dialog box, which lists certificates in your personal
certificate store that are currently valid (not expired) and that have private keys. The purpose of the certificate you
select should include code signing.
If you click view cer tificate proper ties , the Cer tificate Details dialog box appears. This dialog box includes
detailed information about the certificate, and includes additional options. You can click Learn more about
cer tificates to view additional Help information.
Select from File button Allows you to select a certificate from an existing key file.
Clicking Select from File opens the Select File dialog box, which enables you to select a certificate key (.pfx) file.
The file must be password protected and cannot already be located in your personal certificate store.
In the Enter password to open file dialog box, enter a password to open the certificate key (.pfx) file. The
password information is stored in your personal key container list and your personal certificate store.
Create Test Cer tificate button Allows you to create a certificate for testing. The test certificate is used for signing
your ClickOnce application and deployment manifests.
Clicking Create Test Cer tificate opens the Create Test Cer tificate dialog box, in which you can type a
password for the strong-name key file for the test certificate. The file is named projectname_TemporaryKey.pfx. If
you click OK without typing a password, the .pfx file is not password encrypted.
Timestamp ser ver URL box Specifies the address of a server that timestamps your signature. When you provide
a certificate, this external site verifies the time that the application was signed.

Assembly Signing
Sign the assembly check box Select this check box to sign the assembly and create a strongly named key file. For
more information about signing the assembly by using the Project Designer , see How to: Sign an Assembly
(Visual Studio).
This option uses the Al.exe tool provided by the Windows Software Development Kit (SDK) to sign the assembly.
For more information about Al.exe, see How to: Sign an Assembly with a Strong Name.
Choose a strong name key file list Enables you to specify a new or existing strongly named key file that is used
to sign the assembly. Select <Browse...> to select an existing key file.
Select <New...> to create a new key file with which to sign the assembly. The Create Strong Name Key dialog
box appears, which you can use to specify a key file name and protect the key file with a password. The password
must be at least 6 characters long. If you specify a password, a Personal Information Exchange (.pfx) file is created;
if you do not specify a password, a strongly named key (.snk) file is created.
Change Password button Changes the password for the Personal Information Exchange (.pfx) key file that is used
to sign the assembly.
Clicking Change Password opens the Change Key Password dialog box. In this dialog box, Old password is
the current password for the key file. New password must be a least 6 characters long. The password information
is stored in current user's Windows certificate store.
Delay sign only check box Select this check box to enable delay signing.
Note that a delay signed project will not run and cannot be debugged. You can, however, use the Sn.exe (Strong
Name Tool) with the -Vr option to skip verification during development.

NOTE
When you sign an assembly, you might not always have access to a private key. For example, an organization might have a
closely guarded key pair that developers don’t have access to on a daily basis. The public key might be available, but access
to the private key is restricted to a few individuals. In such a case, you can use delayed or partial signing to provide the
public key, deferring the addition of the private key until the assembly is handed off.

See Also
Project Properties Reference Managing Assembly and Manifest Signing Strong-Name Signing for Managed
Applications How to: Sign Application and Deployment Manifests How to: Sign an Assembly (Visual Studio) How
to: Sign an Assembly with a Strong Name Strong-Named Assemblies
Visual Basic Defaults, Projects, Options Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Specifies the default settings for Visual Basic project options. When a new project is created, the specified option
statements will be added to the project header in the Code Editor. The options apply to all Visual Basic projects.
To access this dialog box, on the Tools menu, click Options , expand the Projects and Solutions folder, and then
click VB Defaults .
Option Explicit Sets the compiler default so that explicit declarations of variables are required. By default, Option
Explicit is set to On . For more information, see /optionexplicit.
Option Strict Sets the compiler default so that explicit narrowing conversions are required and late binding is not
allowed. By default, Option Strict is set to Off . For more information, see /optionstrict.
Option Compare Sets the compiler default for string comparisons: binary (case-sensitive) or text (case-
insensitive.) By default, Option Compare is set to Binar y . For more information, see /optioncompare.
Option Infer Sets the compiler default for local type inference. By default, Option Infer is set to On for newly
created projects and to Off for migrated projects created in earlier versions of Visual Basic. For more information,
see /optioninfer.

See Also
Solutions and Projects
VC++ Project Settings, Projects and Solutions,
Options Dialog Box
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

This dialog box lets you define Visual C++ project settings related to build logging and supporting file types.
To access this dialog box
1. On the Tools menu, click Options .
2. Select Projects and Solutions , and then select VC++ Project Settings .

Build Customization Search Path


Specifies the list of directories that contain .rules files, which help you define build rules for your projects.

Build Logging
Yes Turns on generation of the build log file. This option generates BuildLog.htm, which can be found in the
project's intermediate files directory. Every fresh build overwrites the previous BuildLog.htm file.
No Turns off generation of the build log file.

Build Timing
Yes Turns on build timing. If selected, the time it takes for the build to complete is posted to the Output window. For
more information, see Output Window.
No Turns off build timing.

Extensions to Hide
Specifies the file name extensions of files that will not be displayed in Solution Explorer when Show All Files is
enabled.

Extensions to Include
Specifies the file name extensions of files that can be ported into your project.

Maximum concurrent C++ compilations


Specifies the maximum number of CPU cores to use for parallel C++ compilation.

Show Environment in Log


Yes Lists environment variables in the build log file. This option specifies to echo all environment variables, during
builds of Visual C++ projects, into the build log file.
No Exclude environment variables from the build log file.

Solution Explorer Mode


Show only files in project Configures Solution Explorer to only display files in the project.
Show all files Configures Solution Explorer to show files in the project and files on disk in the project folder.

See Also
Building C/C++ Programs C/C++ Building Reference
Project and Solution File Types
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Visual Studio supports many file types. In a particular installation, the installed components determine which file
types are supported. This topic lists solution and project file types that are supported in some typical installations.
For information about other file types, search by using the file name extensions for each type.

Solution Files (.sln and .suo)


Visual Studio uses two file types (.sln and .suo) to store settings specific to solutions. These files, known collectively
as solution files, provide Solution Explorer with the information it needs to display a graphical interface for
managing your files. They allow you to concentrate on your projects and final goals rather than on the environment
itself each time you return to your development tasks.

EXT EN SIO N NAME DESC RIP T IO N

.sln Visual Studio Solution Organizes projects, project items and


solution items into the solution.

.suo Solution User Options Keeps track of user-level customizations


you have made Visual Studio, such as
breakpoints.

Project Files
Visual Studio uses a variety of file formats to store information specific to projects. For more information, see the
following Help topics:
Visual C++
File Types Created for Visual C++ Projects
Creating and Managing Visual C++ Projects
Unicode

See Also
Solutions and Projects
Projects and Solutions, Options Dialog Box
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Sets the default path of Visual Studio project folders, and determines the default behavior of the Output window,
Task List , and Solution Explorer as projects are developed and built. To access this dialog box, click Tools /
Options expand Projects and Solutions , and click General .

NOTE
The options available in dialog boxes, and the names and locations of menu commands you see, might differ from what is
described in Help depending on your active settings or edition. This Help page was written with the General Development
settings in mind. To view or change your settings, choose Impor t and Expor t Settings on the Tools menu. For more
information, see Customizing Development Settings in Visual Studio.

Settings
Projects location Sets the default location where new projects and solution folders and directories are created.
Several dialog boxes also use the location set in this option for folder starting points. For example, the Open Project
dialog box uses this location for the My Projects shortcut.
User project templates location Sets the default location that is used by the New Project dialog box to create
the list of My Templates . For more information, see How to: Locate and Organize Templates.
User item templates location Sets the default location that is used by the Add New Item dialog box to create
the list of My Templates . For more information, see How to: Locate and Organize Templates.
Always show Error List if build finishes with errors Opens the Error List window on build completion, only
if a project failed to build. Errors that occur during the build process are displayed. When this option is cleared, the
errors still occur but the window does not open when the build is complete. This option is enabled by default.
Track Active Item in Solution Explorer When selected, Solution Explorer automatically opens and the active
item is selected. The selected item changes as you work with different files in a project or solution, or different
components in a designer. When this option is cleared, the selection in Solution Explorer does not change
automatically. This option is enabled by default.
Show advanced build configurations When selected, the build configuration options appear on the Project
Proper ty Pages dialog box and the Solution Proper ty Pages dialog box. When cleared, the build configuration
options do not appear on the Project Proper ty Pages dialog box and the Solution Proper ty Pages dialog box
for Visual Basic and Visual C# projects that contain one configuration or the two configurations debug and release.
If a project has a user-defined configuration, the build configuration options are shown.
When unselected, the commands on the Build menu, such as Build Solution , Rebuild Solution , and Clean
Solution , are performed on the Release configuration and the commands on the Debug menu, such as Star t
Debugging and Star t Without Debugging , are performed on the Debug configuration.
Always show solution When selected, the solution and all commands that act on solutions are always shown in
the IDE. When cleared, all projects are created as stand-alone projects and you do not see the solution in Solution
Explorer or commands that act on solutions in the IDE if the solution contains only one project.
Save new projects when created When selected, you can specify a location for your project in the New Project
dialog box. When cleared, all new projects are created as temporary projects. When you are working with
temporary projects, you can create and experiment with a project without having to specify a disk location.
Warn user when the project location is not trusted If you attempt to create a new project or open an existing
project in a location that is not fully trusted (for example, on a UNC path or an HTTP path), a message is displayed.
Use this option to specify whether the message is displayed each time that you attempt to create or open a project
in a location that is not fully trusted.
Show Output window when build star ts Automatically displays the Output Window in the IDE at the outset of
solution builds. For more information, see How to: Control the Output Window. This option is enabled by default.
Prompt for symbolic renaming when renaming files When selected, displays a message box asking whether
or not Visual Studio should also rename all references in the project to the code element.

See Also
Options Dialog Box, Projects and Solutions, Build and Run
Options Dialog Box, Projects and Solutions, Build and
Run
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In this dialog box, you can specify the maximum number of Visual C++ or Visual C# projects that can build at the
same time, certain default build behaviors, and some build log settings. To open the Options dialog box, choose
Tools , Options on the menu bar. To access this set of options, expand Projects and Solutions , and then choose
Build and Run .

UIElement List
maximum number of parallel project builds Specifies the maximum number of Visual C++ and Visual C#
projects that can build at the same time. To optimize the build process, the maximum number of parallel project
builds is automatically set to the number of CPUs of your computer. The maximum is 32.
Only build star tup projects and dependencies on Run Only the startup project and its dependencies are
built if this check box is selected when you choose the F5 key; choose Debug , Star t on the menu bar; or choose
Build , Build on the menu bar. All projects, dependencies, and solution files are built if this check box is cleared
when you choose the F5 key; choose Debug , Star t on the menu bar; or choose Build , Build on the menu bar. By
default, this option is cleared.
On Run, when projects are out of date

NOTE
This list applies to Visual C++ projects only.

By default, a message appears if a project configuration is out of date when you choose the F5 key or choose
Debug , Star t on the menu bar. You can specify whether to build the project anyway and whether the message
appears. Use this option to specify whether the message appears and what the build behavior should be if the
message doesn't appear.
Always build The message box doesn't appear, and the project is built despite the out-of-date configuration. This
option is set when you select the Do not show this dialog again box in the message and then choose the Yes
button.
Never build The message box doesn't appear, and the project isn't built. This option is set when you select the Do
not show this dialog again box in the message and then choose the No button.
Prompt to build Displays the message box every time that a project configuration is out of date.
On Run, when build or deployment errors occur If build errors occur when you start a build from the Build
menu, a message appears. You can specify whether to continue by starting the application and whether the
message appears every time that build errors occur. Use this option to specify whether the message appears and
what the behavior should be if the message doesn't appear.
NOTE
This option applies to Visual C++ projects only.

Prompt to launch Displays a message box every time that build errors occur.
Do not launch The message box doesn't appear, and the application isn't started. This option is set when you
select the Do not show this dialog again check box in the message box and then choose the No button.
Launch old version The message box doesn't appear, and the newly built version of the application isn't started.
This option is set when you select the Do not show this dialog again check box in the message box and then
choose the Yes button.
For new solutions use the currently selected project as the star tup project If this check box is selected,
new solutions use the currently selected project as the startup project.
MSBuild project build output verbosity Determines how much information appears in the Output window
for the build.
MSBuild project build log file verbosity

NOTE
This option applies to Visual C++ projects only.

Determines how much information is written to the build log file, which is located at
\...\ProjectName\Debug\ProjectName.log.

See Also
Compiling and Building
Options Dialog Box, Projects and Solutions, Web
Projects
1/13/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Sets the Web server that Web projects will use for development within Visual Studio. To access this dialog box, click
Tools Options . Expand Projects and Solutions and then click Web Projects .
By default, when you run a Web project in Visual Studio (for example, using F5 or Ctrl+F5), Visual Studio uses the
Visual Studio Development Server. For more information, see Web Servers in Visual Studio for ASP.NET Web
Projects.

NOTE
The options available in dialog boxes, and the names and locations of menu commands you see, might differ from what is
described in Help depending on your active settings or edition. This Help page was written with the Web settings in mind.
To view or change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

Settings
Use the 64-bit version of IIS Express for web sites and projects Select this option to use IIS Express instead
of the Visual Studio Development Server. For more information, see Introducing IIS Express and IIS Express
Overview. This option is disabled by default.
Warn before running web applications when there are errors in the error list If this box is checked, you
will be warned if you try to run your web application when it does not compile without errors.
Property Pages, JavaScript
1/10/2020 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Proper ty Pages provides access to project settings. You can use the pages that appear in the Proper ty Pages
to change project properties.
To access the project properties, select a project node in Solution Explorer . On the Project menu, click
Proper ties .

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following
instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more
information, see Personalizing the IDE.

The following pages and options appear in the Proper ty Pages .

Configuration and Platform Page


Use the following options to select the configuration and platform to display or modify.
Configuration Specifies the configuration settings to display or modify. The settings are Debug (default),
Release , All Configurations , or a user-defined configuration. For more information, see Debug and Release
Project Configurations.
Platform Specifies the platform settings to display or modify. The settings are Any CPU (default for Windows 8.x
Store apps), x64 , ARM , x86 , or a user-defined platform. For more information, see Debug and Release Project
Configurations.

General Page
Use the following options to set general properties of the project.

NOTE
Some options are only available in Windows Store apps.

Output Path Specifies the location of the output files for the project's configuration. The path is relative; if you
enter an absolute path, the absolute path is saved in the project. The default path is bin\Debug.
When you use simplified build configurations, the project system determines whether to build a debug or release
version. When you click Debug , Star t Debugging (or press F5) the build is put in the debug location regardless
of the Output path you specify. However, the Build Solution command on the Build menu puts it in the location
you specify. To enable advanced build configurations, on the menu bar, choose Tools , Options . In the Options
dialog box, expand Projects and Solutions , select General , and then clear the Show advanced build
configurations check box. This gives you manual control over all configuration values and whether a debug or
release version is built. For more information, see NIB: General, Projects and Solutions, Options Dialog Box.
Default Language Specifies the default language for the project. The language option selected in Clock ,
Language, and Region in Control Panel specifies the user's preferred language. By specifying a default language
for the project, you make sure that the specified default language resources are used if the user’s preferred
language does not match the language resources provided in the application.

Debug Page
Use the following options to set properties for debugging behavior in the project.

NOTE
Some options are only available in Windows Store apps.

Debugger to Launch Specifies the default host for the debugger.


Select Local Machine to start the application on the Visual Studio host computer. For more information,
see Running apps on the local machine.
Select Simulator to start the application in the Simulator. For more information, see Running apps in the
simulator.
Select Remote Machine to start the application on a remote computer. For more information about remote
debugging, see Running apps on a remote machine.
Launch Application Specifies whether to start the application when you press F5 or click Debug , Star t
Debugging . Select Yes to start the application; otherwise, select No . If you select No , you can still debug
the application if you use a different method to start it.
Debugger Type Specifies the types of code to debug. Select Script Only to debug JavaScript code. Select
Managed Only to debug code that is managed by the common language runtime. Select Native Only to
debug C++ code. Select Native with Script to debug C++ and JavaScript. Select Mixed (Managed and
Native) to debug both managed and C++ code.
Allow Local Network Loopback Specifies whether access to the IP loopback address is allowed for app
testing. Select Yes to allow use of the loopback address if the client app is on the same machine where the
server application is running; otherwise, select No . This property is available only if the Debugger to
Launch property is set to Remote Machine .
Machine Name Specifies the name of the remote computer to host the debugger. This property is available
only if Debugger to Launch is set to Remote Machine .
Require Authentication Specifies whether the remote computer requires authentication. This property is
available only if Debugger to Launch is set to Remote Machine .
Properties Window
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use this window to view and change the design-time properties and events of selected objects that are located in
editors and designers. You can also use the Proper ties window to edit and view file, project, and solution
properties. You can find Proper ties Window on the View menu. You can also open it by pressing F4 or by typing
Proper ties in the Quick Launch window.
The Proper ties window displays different types of editing fields, depending on the needs of a particular property.
These edit fields include edit boxes, drop-down lists, and links to custom editor dialog boxes. Properties shown in
gray are read-only.

UIElement List
Object name Lists the currently selected object or objects. Only objects from the active editor or designer are
visible. When you select multiple objects, only properties common to all selected objects appear.
Categorized Lists all properties and property values for the selected object, by category. You can collapse a
category to reduce the number of visible properties. When you expand or collapse a category, you see a plus (+) or
minus (-) to the left of the category name. Categories are listed alphabetically.
Alphabetical Alphabetically sorts all design-time properties and events for selected objects. To edit an undimmed
property, click in the cell to its right and enter changes.
Property Pages Displays the Proper ty Pages dialog box or Project Designer for the selected item. Property
Pages displays a subset, the same or a superset of the properties available in the Proper ties window. Use this
button to view and edit properties related to your project's active configuration.
Properties Displays the properties for an object. Many objects also have events that can be viewed using the
Proper ties window.
Sort by Property Source Groups properties by source, such as inheritance, applied styles, and bindings. Only
available when editing XAML files in the designer.
Events Displays the events for an object.

NOTE
This Proper ties window toolbar control is only available when a form or control designer is active in the context of a Visual
C# project. When editing XAML files, events appear on a separate tab of the properties window.

Messages Lists all Windows messages. Allows you to add or delete specified handler functions for the messages
provided for the selected class.
NOTE
This Proper ties window toolbar control is only available when Class View is the active window in the context of a Visual
C++ project.

Overrides Lists all virtual functions for the selected class and allows you to add or delete overriding functions.

NOTE
This Proper ties window toolbar control is only available when Class View is the active window in the context of a Visual
C++ project.

Description pane Shows the property type and a short description of the property. You can turn the description of
the property off and on using the Description command on the shortcut menu.

NOTE
This Proper ties window toolbar control is not available when editing XAML files in the designer.

Thumbnail view Shows a visual representation of the currently selected element when editing XAML files in the
designer.
Search Provides a Search function for properties and events when editing XAML files in the designer. The search
box responds to partial word searches and updates search results as you type.

See Also
Project Properties Reference Customizing window layouts
Toolbox
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Toolbox displays icons for controls and other items that you can add to Visual Studio projects. To open the
Toolbox , click Toolbox on the View menu. You can dock the Toolbox , and you can pin it open or set it to Auto
Hide .
Toolbox icons can be dragged to a design view or pasted in a code editor. Either action adds the fundamental code
to create an instance of the Toolbox item in the active project file.
The Toolbox displays only the items that are appropriate to the type of file you are working in. You can search
within the Toolbox to further filter the items that appear. If your project requires a control that is not supported by
the Client Profile, you can set your project to target the entire framework by editing the project properties.

NOTE
Your computer might show different names or locations for some of the Visual Studio user interface elements in the
following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For
more information, see Customizing Development Settings in Visual Studio.

Help on Toolbox Tabs


The following documents provide more information about specific Toolbox tabs.
Toolbox, Data Tab
Toolbox, Components Tab
Toolbox, HTML Tab
Toolbox, Data Tab
Toolbox, Components Tab
Toolbox, HTML Tab

See Also
Using the Toolbox
Toolbox, Components Tab
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Displays components you can add to Visual Basic and Visual C# designers. In addition to the .NET Framework
components that are included with Visual Studio, such as the MessageQueue and EventLog components, you can
add your own or third-party components to this tab. For more information, see How to: Manipulate Toolbox Tabs.
To display this tab, from the View menu, select Toolbox . In the Toolbox , select the Components tab.
BackgroundWorker Creates a System.ComponentModel.BackgroundWorker component instance that can run an
operation on a separate, dedicated thread.
Director yEntr y Creates a DirectoryEntry component instance that encapsulates a node or object in the Active
Directory hierarchy and can be used to interact with Active Directory service providers.
Director ySearcher Creates a DirectorySearcher component instance that you can use to perform queries against
the Active Directory.
ErrorProvider Creates a System.Windows.Forms.ErrorProvider component instance, which indicates to the end user
that a control on a form has an error associated with it.
EventLog Creates an EventLog component instance you can use to interact with system and custom event logs,
including writing events to a log and reading log data. For more information, see Introduction to the EventLog
Component.
FileSystemWatcher Creates a FileSystemWatcher component instance that you can use to monitor for changes to
any directory or file to which you have access. For more information, see How to: Configure FileSystemWatcher
Component Instances.
HelpProvider Creates a System.Windows.Forms.HelpProvider component instance that provides pop-up or online
Help for controls.
ImageList Creates a System.Windows.Forms.ImageList component instance that provides methods to manage a
collection of System.Drawing.Image objects.
MessageQueue Creates a MessageQueue component instance that you can use to interact with message queues,
including reading messages from and writing messages to queues, processing transactions, and performing queue
administration tasks. For more information, see Using Messaging Components.
PerformanceCounter Creates a PerformanceCounter component instance that you can use to interact with
Windows performance counters, including creating new categories and instances, reading values from counters,
and performing calculations on counter data. For more information, see Monitoring Performance Thresholds.
Process Creates a Process component instance you can use to stop, start, and manipulate the data associated with
processes on your system. For more information, see Monitoring and Managing Windows Processes.
SerialPor t Creates a System.IO.Ports.SerialPort component instance that provides synchronous and event-
driven I/O, access to pin and break states, and access to serial driver properties.
Ser viceController Creates a ServiceController component instance you can use to manipulate existing services,
including starting and stopping services and sending commands to them. For more information, see Monitoring
Windows Services.
Timer Creates a Timer component instance you can use to add time-based functionality to your Windows-based
applications. For more information, see Timer Component.

NOTE
There is also a system-based Timer that you can add to the Toolbox This Timer is optimized for server applications, and the
Windows Forms Timer is best suited for use on Windows Forms.

See Also
Programming with Components Component Programming Walkthroughs Toolbox Choose Toolbox Items Dialog
Box (Visual Studio)
Toolbox, Data Tab
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Displays data objects you can add to a forms and components. The Data tab of the Toolbox appears when you
create a project that has an associated designer. The Toolbox appears by default in the Visual Studio integrated
development environment; if you need to display the Toolbox , select Toolbox from the View menu.

TIP
Running the Data Source Configuration Wizard will automatically create and configure most data items. For more
information, see Creating Data Applications with Visual Studio.

UI Element List
To go directly to the .NET Framework reference page for a component, press F1 on the item in the Toolbox or on
the component item in the tray of the designer.

NAME DESC RIP T IO N

DataSet Adds an instance of a typed or untyped dataset to the form or


component. When you drag this object onto a designer, it
displays a dialog box that allows you to select an existing
typed dataset class or specify that you want to create a new,
blank, untyped dataset. Note: You do not use the DataSet
object on the Toolbox to create a new typed dataset schema
and class. For more information, see Create and configure
datasets.

DataGridView Provides a powerful and flexible way to display data in a


tabular format.

BindingSource Simplifies the process of binding controls to an underlying


data source.

BindingNavigator Represents the navigation and manipulation user interface (UI)


for controls on a form that are bound to data.

See Also
Data Walkthroughs Bind Windows Forms controls to data in Visual Studio Preparing Your Application to Receive
Data Bind controls to data in Visual Studio Validating Data
Toolbox, HTML Tab
1/10/2020 • 7 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The HTML tab of the Toolbox provides components that are useful on Web pages and Web forms. To view this tab,
first open a document for editing in the HTML designer. On the View menu, click Toolbox , and then click the
HTML tab of the Toolbox.
To create an instance of a tool on the HTML tab, either double-click the tool to add it to your document at the
current insertion point, or select the tool and drag it to the desired position on the editing surface.

Tasks
How to: Manage the Toolbox Window
How to: Manipulate Toolbox Tabs

UI Elements
The following tools are available by default on the HTML tab.
Pointer
This tool is selected by default when any Toolbox tab opens. It cannot be deleted. The pointer enables you to drag
objects onto the Design view surface, resize them, and reposition them on the page or form. For more information,
see How to: Manage the Toolbox Window and How to: Manipulate Toolbox Tabs.
Input (Button)
Inserts an input element of type="button" . To change the text that is displayed, edit the name property. By
default, id="Button1" is inserted for the first button, id="Button2" for the second, and so on.
When you drag Input (Button) onto the Design view surface, HTML markup like the following is inserted into
your document:

<input id="Button1" type="button" value="Button" name="Button1">

For more information, see HTML Input Controls, HtmlInputButton Server Control Declarative Syntax, NIB: How to:
Create Scripts and Edit Event Handlers, Button Web Server Controls Content Map, HtmlInputButton, HtmlButton,
and Button.
Input (Reset)
Inserts an input element of type="reset" . To change the text that is displayed, edit the name property. By default,
id="Reset1" is inserted for the first reset button, id="Reset2" for the second, and so on.
When you drag Input (Reset) onto the Design view surface, HTML markup like the following is inserted into your
document:
<input id="Reset1" type="reset" value="Reset" name="Reset1">

For more information, see HTML Input Controls, HtmlInputReset Server Control Declarative Syntax,
HtmlInputButton, and Button.
Input (Submit)
Inserts an input element of type="submit" . To change the text that is displayed, edit the name property. By
default, id="Submit1" is inserted for the first submit button, id="Submit2" for the second, and so on.
When you drag Input (Submit) onto the Design view surface, HTML markup like the following is inserted into
your document:

<input id="Submit1" type="submit" value="Submit" name="Submit1">

For more information, see HTML Input Controls, HtmlInputSubmit Server Control Declarative Syntax,
HtmlInputButton, and Button.
Input (Text)
Inserts an input element of type="text" in your document. To change the default text that is displayed, edit the
value attribute. By default, id="Text1" is inserted for the first text field, id="Text2" for the second, and so on.

When you drag Input (Text) onto the Design view surface, HTML markup like the following is inserted into your
document:

<input id="Text1" TYPE="text" value="Text Field" name="Text1">

For more information, see HTML Input Controls, HtmlInputText Server Control Declarative Syntax, TextBox Web
Server Control Overview, HtmlInputText, and TextBox.

IMPORTANT
It is recommended that you validate all user input. For more information, see Validating User Input in ASP.NET Web Pages.

Input (File)
Inserts an input element of type="file" in your document. By default, id="File1" is inserted for the first file
field, id="File2" for the second, and so on.
When you drag Input (File) onto the Design view surface, HTML markup like the following is inserted into your
document:

<input id="File1" type="file" name="File1">

For more information, see HTML Input Controls, HtmlInputFile Server Control Declarative Syntax, and
HtmlInputFile.

IMPORTANT
It is recommended that you validate all user input. For more information, see Validating User Input in ASP.NET Web Pages.

Input (Password)
Inserts an input element of type="password" . By default, id="Password1" is inserted for the first password field,
id="Password2" for the second, and so on.
When you drag Input (Password) onto the Design view surface, HTML markup like the following is inserted into
your document:

<input id="Password1" type="password" name="Password1">

For more information, see HTML Input Controls, HtmlInputPassword Server Control Declarative Syntax, How to: Set
a TextBox Web Server Control for Password Entry, and Walkthrough: Validating User Input in a Web Forms Page.

IMPORTANT
If your application transmits user names and passwords, you should configure your Web site to use Secure Sockets Layer
(SSL) to encrypt the transmission. For more information, see "Securing Connections with SSL" in the IIS Operations Guide.
Additionally, it is recommended that you validate all user input. For more information, see Validating User Input in ASP.NET
Web Pages.

Input (Check box)


Inserts an input element of type="checkbox" . To change the text that is displayed, edit the name property. By
default, id="Checkbox1" is inserted for the first check box, id="Checkbox2" for the second, and so on.
When you drag Input (Check box) onto the Design view surface, HTML markup like the following is inserted into
your document:

<input id="Checkbox1" type="checkbox" name="Checkbox1">

For more information, see HTML Input Controls, HtmlInputCheckBox Server Control Declarative Syntax, CheckBox
and CheckBoxList Web Server Controls Overview, HtmlInputCheckBox, and CheckBox.
Input (Radio)
Inserts an input element of type="radio" . To change the text that is displayed, edit the name property. By default,
id="Radio1" is inserted for the first radio button, id="Radio2" for the second, and so on.
When you drag Input (Radio) onto the Design view surface, HTML markup like the following is inserted into your
document:

<input id="Radio1" type="radio" name="Radio1">

For more information, see HTML Input Controls, HtmlInputRadioButton Server Control Declarative Syntax,
RadioButton and RadioButtonList Web Server Controls Overview, HtmlInputRadioButton, and RadioButton.
Input (Hidden)
Inserts an input element of type="hidden" . By default, id="Hidden1" is inserted for the first hidden field,
id="Hidden2" for the second, and so on.
When you drag Input (Hidden) onto the Design view surface, HTML markup like the following is inserted into
your document:

<input id="Hidden1" type="hidden" name="Hidden1">


For more information, see HTML Input Controls, HtmlInputHidden Server Control Declarative Syntax, and
HtmlInputHidden.
Textarea
Inserts a textarea element. You can resize the text area, or use its scroll bars to view text that extends beyond its
display area. To change the default text that is displayed, edit the value attribute. By default, id="textarea1" is
inserted the first text area, id=" textarea 2" for the second, and so on.
When you drag Textarea onto the Design view surface, HTML markup like the following is inserted into your
document:

<textarea id=" textarea 1 name=" textarea 1" rows=2 cols=20></textarea>

For more information, see HtmlTextArea Server Control Declarative Syntax, HtmlTextArea, and TextBox.

IMPORTANT
It is recommended that you validate all user input. For more information, see Validating User Input in ASP.NET Web Pages.

Table
Inserts a table element.
When you drag Table onto the Design view surface, HTML markup like the following is inserted into your
document:

<table cellspacing="1" width="75%" border=1> <tr><td></td></tr></table>

For more information, see HtmlTable Server Control Declarative Syntax, Table, TableRow, and TableCell Web Server
Control Overview, HtmlTable, and Table.
Image
Inserts an img element. Edit this element to specify its src and its alt text.
When you drag Image onto the Design view surface, HTML markup like the following is inserted into your
document:

<img alt="" src="">

For more information, see HtmlImage Server Control Declarative Syntax, Image Web Server Control Overview,
HtmlImage, HtmlInputImage, and Image.
Select
Inserts a dropdown select element (without a size attribute). By default, id="select1" is inserted for the first
list box, id="select2" for the second, and so on.
When you drag Select onto the Design view surface, HTML markup like the following is inserted into your
document:

<select id="select1" name="select1"><option selected></option></select>

You can create a multi-line select element by increasing the value of the size property.
For more information, see HtmlSelect Server Control Declarative Syntax, NIB: How to: Create Scripts and Edit Event
Handlers, DropDownList Web Server Control Overview, ListBox Web Server Control Overview, HtmlSelect, and
DropDownList.
Horizontal Rule
Inserts an hr element. To increase the thickness of the line, edit the size attribute.
When you drag Horizontal Rule onto the Design view surface, HTML markup like the following is inserted into
your document:

<hr width="100%" size=1>

For more information, see HTML Horizontal Rule Control.


Div
Inserts a div element that includes an ms_positioning="FlowLayout" attribute. Except for the width and height, this
item is identical to a Flow Layout Panel. To format the text that is contained within the div element, add a
class="stylename" attribute to the opening tag.

When you drag Div onto the Design view surface, HTML markup like the following is inserted into your document:

<div ms_positioning="FlowLayout" style="width: 70px; position: relative; height: 15px">Label</div>

For more information, see HTML Div Control, Label Web Server Control Overview, and Label.

See Also
Toolbox Standard Tab, Toolbox HTML Controls
Devenv Command Line Switches
10/18/2019 • 5 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Devenv lets you set various options for the integrated development environment (IDE), and also build, debug,
and deploy projects, from the command line. Use these switches to run the IDE from a script or a .bat file, for
example, a nightly build script, or to start the IDE in a particular configuration.

NOTE
For build-related tasks, it is now recommended that you use MSBuild instead of devenv. For more information, see
Command-Line Reference.

NOTE
You must run devenv as an adminstrator in order to use the /Setup (devenv.exe) and /InstallVSTemplates (devenv.exe)
switches.

Devenv Switch Syntax


By default, devenv commands pass switches to the devenv.com utility.
The devenv.com utility provides for the delivery of output through standard system streams, such as stdout
and stderr , and determines the appropriate I/O redirection when it captures output, for example, to a .txt file.
Commands that begin instead with devenv.exe can use the same switches, but will send them to the
devenv.exe program, bypassing the devenv.com utility.
The syntax rules for devenv switches resemble those for other DOS command-line utilities. The following
syntax rules apply to all devenv switches and their arguments:
Commands begin with devenv .
Switches are not case-sensitive.
When specifying a solution or project, the first argument is the name of the solution file or project file,
including file path.
If the first argument is a file that is not a solution or project, that file will open in the appropriate editor, in
a new instance of the IDE.
When you supply a project file name instead of a solution file name, a devenv command will search the
parent folder of the project file for a solution file that has the same name. For example, the command
devenv /build myproject1.vbproj will search the parent folder for a solution file that is named
"myproject1.sln".
NOTE
One and only one solution file that references this project should be located in its parent folder. If the parent
folder contains no solution file that references this project, or if the parent folder contains two or more solution
files that reference it, then a temporary solution file will be created that is named for this project and references it.

When file paths and file names include spaces, you must enclose them in double quotation marks ("").
For example, "c:\project a\".
Insert one space character between switches and arguments on the same line. For example, the
command devenv /log output.txt opens the IDE and outputs all log information for that session to
output.txt.
You cannot use pattern-matching syntax in devenv commands.

Devenv Switches
Use the following command-line switches to display the IDE and perform the described task.

C O M M A N D L IN E SW ITC H DESC RIP T IO N

/Command (devenv.exe) Starts the IDE and executes the specified command.

/DebugExe (devenv.exe) Loads a Visual C++ executable under the control of the
debugger. This switch is not available for Visual Basic or
Visual C# executables. For more information, see
Automatically start a process in the debugger.

/LCID (devenv.exe) or /l Sets the default language for the IDE. If the specified
language is not included in your installation of Visual Studio,
this setting will be ignored.

/Log (devenv.exe) Starts Visual Studio and logs all activity to the log file.

/Run (devenv.exe) or /r Compiles and runs the specified solution.

/Runexit (devenv.exe) Compiles and runs the specified solution, minimizes the IDE
when the solution is run, and closes the IDE after the
solution has finished running.

/UseEnv (devenv.exe) Causes the IDE to use PATH, INCLUDE, and LIB environment
variables for Visual C++ compilation instead of the settings
specified in the VC++ Directories section of Projects
options in the Options dialog box. For more information,
see Setting the Path and Environment Variables for
Command-Line Builds

/Edit (devenv.exe) Opens the specified files in a running instance of this


application. If there are no running instances, it will start a
new instance with a simplified window layout.

/ResetAddin (devenv.exe) Starts an instance of the Visual Studio IDE without loading
the specified Add-in.
C O M M A N D L IN E SW ITC H DESC RIP T IO N

/SafeMode (devenv.exe) Starts Visual Studio in safe mode, and loads only the default
environment and services, and shipped versions of third-
party packages.

/ResetSkipPkgs (devenv.exe) Clears all SkipLoading tags that have been added to
VSPackages by users who want to avoid loading problem
VSPackages.

/Setup (devenv.exe) Forces Visual Studio to merge resource metadata that


describes menus, toolbars, and command groups, from all
VSPackages available.

Use the following command line switches to perform the described task. These command-line switches do not
display the IDE.

C O M M A N D L IN E SW ITC H DESC RIP T IO N

/? (devenv.exe) Displays help for devenv switches in the Command


Prompt window .

Devenv /?

/Build (devenv.exe) Builds the specified solution or project according to the


configuration of the specified solution.

Devenv myproj.csproj /build

/Clean (devenv.exe) Deletes any files created by the build command, without
affecting source files.

Devenv myproj.csproj /clean

/Deploy (devenv.exe) Builds the solution, along with files necessary for
deployment, according to the solutions configuration.

Devenv myproj.csproj /deploy

/Diff Compares two files. Takes four parameters:SourceFile,


TargetFile,
SourceDisplayName(optional),TargetDisplayName(optional).

/InstallVSTemplates (devenv.exe) Registers project or item templates that are located in


<VisualStudioInstallDir>\Common7\IDE\ProjectTemplates or
<VisualStudioInstallDir>\Common7\IDE\ItemTemplates so
that they can be accessed through the New Project and
Add New Item dialog boxes.

Devenv /InstallVSTemplates

/Out (devenv.exe) Lets you specify a file to receive errors when you build.

Devenv myproj.csproj /build /out log.txt

/Project (devenv.exe) The project to build, clean, or deploy. You can use this switch
only if you have also supplied the /build, /rebuild, /clean, or
/deploy switch.
C O M M A N D L IN E SW ITC H DESC RIP T IO N

/ProjectConfig (devenv.exe) Specifies the project configuration to build or deploy. You


can use this switch only if you have also supplied the
/project switch.

/Rebuild (devenv.exe) Cleans and then builds the specified solution or project
according to the configuration of the specified solution.

/ResetSettings (devenv.exe) Restores Visual Studio default settings. Optionally resets the
settings to the specified .vssettings file.

/Updateconfiguration (devenv.exe) Notifies Visual Studio to merge the Visual Studio packages
on the system and check the MEF cache for any changes.

/Upgrade (devenv.exe) Upgrades the specified solution file and all its project files, or
the specified project file, to the current Visual Studio formats
for these files.

See Also
General, Environment, Options Dialog Box
/? (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Displays a message box listing all devenv switches, with a brief description of each one.

Syntax
devenv /?

See Also
Devenv Command Line Switches
/Build (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Builds a solution using a specified solution configuration file.

Syntax
Devenv SolutionName /build SolnConfigName [/project ProjName [/projectconfig ProjConfigName]]

Arguments
SolutionName Required. The full path and name of the solution file.
SolnConfigName Required. The name of the solution configuration that will be used to build the solution named in
SolutionName .
/project ProjName Optional. The path and name of a project file within the solution. You can enter a relative path
from the SolutionName folder to the project file, or the project's display name, or the full path and name of the
project file.
/projectconfig ProjConfigName Optional. The name of a project build configuration to be used when building the
/project named.

Remarks
This switch performs the same function as the Build Solution menu command within the integrated
development environment (IDE).
Enclose strings that include spaces in double quotation marks.
Summary information for builds, including errors, can be displayed in the Command window, or in any log file
specified with the /out switch.
This command only builds projects that have changed since the last build. To build all projects in a solution, use
/Rebuild (devenv.exe).

Example
This example builds the project CSharpConsoleApp , using the Debug project build configuration within the Debug
solution configuration of MySolution .

devenv "C:\Documents and Settings\someuser\My Documents\Visual Studio\Projects\MySolution\MySolution.sln"


/build Debug /project "CSharpWinApp\CSharpWinApp.csproj" /projectconfig Debug
See Also
Building and Cleaning Projects and Solutions in Visual Studio Devenv Command Line Switches /Rebuild
(devenv.exe) /Clean (devenv.exe) /Out (devenv.exe)
/Clean (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Cleans all intermediary files and output directories.

Syntax
devenv FileName /Clean [ /project projectnameorfile [/projectconfig name ] ]

Arguments
FileName Required. The full path and name of the solution file or project file.
/project ProjName Optional. The path and name of a project file within the solution. You can enter a relative path
from the SolutionName folder to the project file, or the project's display name, or the full path and name of the
project file.
/projectconfig ProjConfigName Optional. The name of a project build configuration to be used when cleaning the
/project named.

Remarks
This switch performs the same function as the Clean Solution menu command within the integrated
development environment (IDE).
Enclose strings that include spaces in double quotation marks.
Summary information for cleans and builds, including errors, can be displayed in the Command window, or in
any log file specified with the /out switch.

Example
The first example cleans the MySolution solution, using the default configuration specified in the solution file.
The second example cleans the project CSharpConsoleApp , using the Debug project build configuration within the
Debug solution configuration of MySolution .

Devenv "C:\Documents and Settings\someuser\My Documents\Visual Studio\Projects\MySolution\MySolution.sln"


/Clean

devenv "C:\Documents and Settings\someuser\My Documents\Visual Studio\Projects\MySolution\MySolution.sln"


/Clean /project "CSharpWinApp\CSharpWinApp.csproj" /projectconfig "Debug"

See Also
Devenv Command Line Switches /Build (devenv.exe) /Rebuild (devenv.exe) /Out (devenv.exe)
/Command (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Executes the specified command after launching the Visual Studio integrated development environment (IDE).

Syntax
devenv /command CommandName

Arguments
CommandName Required. The complete name of a Visual Studio command or its alias, enclosed in double quotation
marks. For more information about command and alias syntax, see Visual Studio Commands.

Remarks
After startup is complete, the IDE executes the named command. If you use this switch, the IDE does not display the
Visual Studio Start Page on startup.
If an add-in exposes a command, you can use this switch to launch the add-in from the command line. For more
information, see How to: Control Add-Ins By Using the Add-In Manager.

Example
This example launches Visual Studio and automatically runs the macro Open Favorite Files.

devenv /command "Macros.MyMacros.Module1.OpenFavoriteFiles"

See Also
Devenv Command Line Switches Visual Studio Command Aliases
/DebugExe (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Opens the specified executable file to be debugged.

Syntax
Devenv /debugexe ExecutableFile

Arguments
ExecutableFile Required. The path and file name of an .exe file.
If the .exe file is not found or does not exist, no warning or error is displayed and Visual Studio starts normally.

Remarks
Any strings following the ExecutableFile parameter are passed to that file as arguments.

Example
The following example opens the file MyApplication.exe for debugging.

Devenv.exe /debugexe MyApplication.exe

See Also
Devenv Command Line Switches
/Deploy (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Deploys a solution after a build or rebuild. Applies to managed code projects only.

Syntax
devenv SolutionName /deploy SolnConfigName [/project ProjName] [/projectconfig ProjConfigName] [/out
LogFileName]

Arguments
SolnConfigName Required. The name of the solution configuration that will be used to build the solution named in
SolutionName .
SolutionName Required. The full path and name of the solution file.
/project ProjName Optional. The path and name of a project file within the solution. You can enter a relative path
from the SolutionName folder to the project file, or the project's display name, or the full path and name of the
project file.
/projectconfig ProjConfigName Optional. The name of a project build configuration to be used when building the
/project named.

Remarks
The specified project must be a deployment project. If the specified project is not a deployment project, when the
project that has been built is passed to be deployed, it fails with an error.
Enclose strings that include spaces in double quotation marks.
Summary information for builds, including errors, can be displayed in the Command window, or in any log file
specified with the /out switch.

Example
This example deploys the project CSharpConsoleApp , using the Release project build configuration within the
Release solution configuration of MySolution .

devenv "C:\Documents and Settings\someuser\My Documents\Visual Studio\Projects\MySolution\MySolution.sln"


/deploy Release /project "CSharpWinApp\CSharpWinApp.csproj" /projectconfig Release

See Also
Devenv Command Line Switches /Project (devenv.exe) /Build (devenv.exe) /Clean (devenv.exe) /Rebuild
(devenv.exe) /Out (devenv.exe)
/Diff
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Compares two files. The differences are displayed in a special Visual Studio window.

Syntax
devenv /Diff SourceFile, TargetFile, [SourceDisplayName],[TargetDisplayName]

Arguments
SourceFile Required. The full path and name of the first file to be compared.
TargetFile Required. The full path and name of the second file to be compared
SourceDisplayName Optional. The display name of the first file.
TargetDisplayName Optional. The display name of the second file.
/Edit (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Opens the specified file in an existing instance of Visual Studio.

Syntax
Devenv /edit [file1[ file2]]

Arguments
file1 Optional. The file to open in an existing instance of Visual Studio. If no instance of Visual Studio exists, a new
instance is created with a simplified window layout, and file1 is opened in the new instance.
file2 Optional. One or more additional files to open in the existing instance of Visual Studio.

Remarks
If no file is specified and there is an existing instance of Visual Studio, the existing instance of Visual Studio receives
focus. If no file is specified and there is no existing instance of Visual Studio, a new instance of Visual Studio is
created with a simplified window layout.
If the existing instance of Visual Studio is in a modal state, for example, if the Options dialog box is open, the file
will open in the existing instance when Visual Studio exits the modal state.

Example
This example opens the file MyFile.cs in an existing instance of Visual Studio or opens the file in a new instance of
Visual Studio if one does not already exist.

devenv /edit MyFile.cs

See Also
Devenv Command Line Switches
/LCID (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Sets the default language used for text, currency, and other values within the integrated development environment
(IDE).

Syntax
devenv {/LCID|/l} LocaleID

Arguments
LocaleID Required. The LCID (locale ID) of the language you specify.

Remarks
Loads the IDE and sets the default natural language for the environment. This change is persisted between sessions
and reflected on the International Settings pane of the Environment options in the Options dialog box in the
IDE.
If the specified language is not available on the user's system, the /LCID switch is ignored.
The following table lists the LCIDs of the languages supported by Visual Studio.

L A N GUA GE L C ID

Chinese (Simplified) 2052

Chinese (Traditional) 1028

English 1033

French 1036

German 1031

Italian 1040

Japanese 1041

Korean 1042

Spanish 3082
Example
This example loads the IDE with English resources strings.

devenv /LCID 1033

See Also
Devenv Command Line Switches International Settings, Environment, Options Dialog Box Customizing window
layouts
/Log (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Logs all activity to the log file for troubleshooting. This file appears after you've called devenv /log at least once. By
default, the log file is:
%APPDATA%\Microsoft\VisualStudio\Version\ActivityLog.xml
where Version is the Visual Studio version. However, you may specify a different path and file name.

Syntax
Devenv /log Path\NameOfLogFile

Remarks
This switch must appear at the end of the command line, after all other switches.
The log is written for all instances of Visual Studio that you've invoked with the /log switch. It doesn't log instances
of Visual Studio that you've invoked without the switch.

See Also
Devenv Command Line Switches
/Out (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Specifies a file to store and display errors when you run, build, rebuild, or deploy a solution.

Syntax
devenv /out FileName

Arguments
FileName Required. The path and name of the file to receive errors when you build an executable.

Remarks
If a file name that does not exist is specified, the file is created automatically. If the file already exists, the results
are appended to the existing contents of the file.
Command line build errors are displayed in the Command window and the Solution Builder view of the Output
window. This option is useful if you are running unattended builds and need to see the results.

Example
This example runs MySolution and writes errors to the file MyErrorLog.txt .

devenv /run "C:\Documents and Settings\someuser\My Documents\Visual


Studio\Projects\MySolution\MySolution.sln" /out "C:\MyErrorLog.txt"

See Also
Devenv Command Line Switches /Run (devenv.exe) /Build (devenv.exe) /Rebuild (devenv.exe) /Deploy
(devenv.exe)
/Project (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Identifies a single project within the specified solution configuration to build, clean, rebuild, or deploy.

Syntax
devenv SolutionName {/build|/clean|/rebuild|/deploy} SolnConfigName
[/project ProjName] [/projectconfig ProjConfigName]

Arguments
/build Builds the project specified by /project ProjName .
/clean Cleans all intermediary files and output directories created during a build.
/rebuild Cleans then builds the project specified by /project ProjName .
/deploy Specifies that the project be deployed after a build or rebuild.
SolnConfigName Required. The name of the solution configuration that will be applied to the solution named in
SolutionName .
SolutionName Required. The full path and name of the solution file.
/project ProjName Optional. The path and name of a project file within the solution. You can enter a relative path
from the SolutionName folder to the project file, or the project's display name, or the full path and name of the
project file.
/projectconfig ProjConfigName Optional. The name of a project build configuration to be applied to the /project
named.

Remarks
Must be used part of a devenv /build , / clean , /rebuild , or /deploy command.
Enclose strings that include spaces in double quotation marks.
Summary information for builds, including errors, can be displayed in the Command window, or in any log
file specified with the /out switch.

Example
This example builds the project CSharpConsoleApp , using the Debug project build configuration within the Debug
solution configuration of MySolution .
devenv "C:\Documents and Settings\someuser\My Documents\Visual Studio\Projects\MySolution\MySolution.sln"
/build Debug /project "CSharpWinApp\CSharpWinApp.csproj" /projectconfig Debug

See Also
Devenv Command Line Switches /ProjectConfig (devenv.exe) /Build (devenv.exe) /Clean (devenv.exe) /Rebuild
(devenv.exe) /Deploy (devenv.exe) /Out (devenv.exe)
/ProjectConfig (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Specifies a project build configuration to be applied when you build, clean, rebuild, or deploy the project named in
the /project argument.

Syntax
devenv SolutionName {/build|/clean|/rebuild|/deploy} SolnConfigName [/project ProjName] [/projectconfig
ProjConfigName]

Arguments
/build Builds the project specified by /project ProjName .
/clean Cleans all intermediary files and output directories created during a build.
/rebuild Cleans then builds the project specified by /project ProjName .
/deploy Specifies that the project be deployed after a build or rebuild.
SolnConfigName Required. The name of the solution configuration that will be applied to the solution named in
SolutionName .
SolutionName Required. The full path and name of the solution file.
/project ProjName Optional. The path and name of a project file within the solution. You can enter a relative path
from the SolutionName folder to the project file, or the project's display name, or the full path and name of the
project file.
/projectconfig ProjConfigName Optional. The name of a project build configuration to be applied to the /project
named.

Remarks
Must be used with the /project switch as part of a devenv /build , / clean , /rebuild , or /deploy
command.
Enclose strings that include spaces in double quotation marks.
Summary information for builds, including errors, can be displayed in the Command window, or in any log
file specified with the /out switch.

Example
This example builds the project CSharpConsoleApp , using the Debug project build configuration within the Debug
solution configuration of MySolution .

devenv "C:\Documents and Settings\someuser\My Documents\Visual Studio\Projects\MySolution\MySolution.sln"


/build Debug /project "CSharpWinApp\CSharpWinApp.csproj" /projectconfig Debug

See Also
Devenv Command Line Switches /Project (devenv.exe) /Build (devenv.exe) /Clean (devenv.exe) /Rebuild
(devenv.exe) /Deploy (devenv.exe) /Out (devenv.exe)
/Rebuild (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Cleans and then builds the specified solution configuration.

Syntax
devenv SolutionName /rebuild SolnConfigName [/project ProjName] [/projectconfig ProjConfigName]

Arguments
SolnConfigName Required. The name of the solution configuration that will be used to rebuild the solution named
in SolutionName .
SolutionName Required. The full path and name of the solution file.
/project ProjName Optional. The path and name of a project file within the solution. You can enter a relative path
from the SolutionName folder to the project file, or the project's display name, or the full path and name of the
project file.
/projectconfig ProjConfigName Optional. The name of a project build configuration to be used when rebuilding
the /project named.

Remarks
This switch performs the same function as the Rebuild Solution menu command within the integrated
development environment (IDE).
Enclose strings that include spaces in double quotation marks.
Summary information for cleans and builds, including errors, can be displayed in the Command window,
or in any log file specified with the /out switch.

Example
This example cleans and rebuilds the project CSharpWinApp , using the Debug project build configuration within
the Debug solution configuration of MySolution .

devenv "C:\Documents and Settings\someuser\My Documents\Visual Studio\Projects\MySolution\MySolution.sln"


/rebuild Debug /project "CSharpWinApp\CSharpWinApp.csproj" /projectconfig Debug

See Also
Devenv Command Line Switches /Build (devenv.exe) /Clean (devenv.exe) /Out (devenv.exe)
/ResetAddin (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Removes commands and command UI associated with the specified Add-in.

Syntax
Devenv /ResetAddin AddIn

Arguments
AddIn Optional. The command name of the Add-in.

Remarks
By default, the command name of the add-in is equal to <AddInSolutionName>.Connect.<AddInSolutionName>,
and appears in Connect.cs as the commandName parameter of the Exec method. You can also verify the command
name by starting to type the name of the add-in into the Commands window in Visual Studio, and using
Intellisense to fill in the rest.

Example
The following example starts Visual Studio and prevents the MyAddin add-in from running at startup.

Devenv.exe /ResetAddin MyAddin.Connect.MyAddin

See Also
Customizing Development Settings in Visual Studio Devenv Command Line Switches
/InstallVSTemplates (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Registers project or item templates that are located in <Visual Studio installation
path>\Common7\IDE\ProjectTemplates\ or <Visual Studio installation path>\Common7\IDE\ItemTemplates\ so
that they can be accessed through the New Project and Add New Item dialog boxes.

WARNING
This switch is supported only for Visual Studio partner development, and is not available in Express editions. You must run
devenv as an administrator in order to use the /Setup (devenv.exe) and /InstallVSTemplates (devenv.exe) switches. For more
information, see User Permissions.

Syntax
devenv.exe /InstallVSTemplates

Remarks
See Also
Devenv Command Line Switches
/ResetSettings (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Restores Visual Studio default settings and automatically launches the Visual Studio IDE. Optionally resets the
settings to a specified .vssettings file.
The default settings are determined by the profile that was selected when Visual Studio was first launched.

Syntax
Devenv /ResetSettings SettingsFile

Arguments
SettingsFile The full path and name of the .vssettings file to apply to Visual Studio.
To restore the General Development Settings profile, use General .

Remarks
If no SettingsFile is specified, you will be prompted to select a default collection of settings the next time you
start Visual Studio.

Example
The following command line applies the settings stored in the file MySettings.vssettings .

Devenv.exe /ResetSettings "C:\My Files\MySettings.vssettings"

See Also
Customizing Development Settings in Visual Studio Devenv Command Line Switches
/ResetSkipPkgs (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Clears all options to skip loading added to VSPackages by users wishing to avoid loading problem VSPackages,
then starts Visual Studio.

Syntax
Devenv /ResetSkipPkgs

Remarks
The presence of a SkipLoading tag disables the loading of a VSPackage; clearing the tag re-enables the loading of
the VSPackage.

Example
The following example clears all SkipLoading tags.

Devenv.exe /ResetSkipPkgs

See Also
Devenv Command Line Switches
/Run (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Compiles and runs the specified project or solution.

Syntax
devenv {/run|/r} {SolutionName|ProjectName}

Arguments
SolutionName Required. The full path and name of a solution file.
ProjectName Required. The full path and name of a project file.

Remarks
Compiles and runs the specified project or solution according to the settings specified for the active solution
configuration. This switch launches the integrated development environment (IDE) and leaves it active after the
project or solution has completed running.
Enclose strings that include spaces in double quotation marks.
Summary information, including errors, can be displayed in the Command window, or in any log file
specified with the /out switch.

Example
This example runs the solution MySolution using the active deployment configuration.

devenv /run "C:\Documents and Settings\someuser\My Documents\Visual Studio\Projects\MySolution\MySolution.sln"

See Also
Devenv Command Line Switches /Runexit (devenv.exe) /Build (devenv.exe) /Rebuild (devenv.exe) /Out (devenv.exe)
/Runexit (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Compiles and runs the specified project or solution, and then closes the integrated development environment
(IDE).

Syntax
devenv /runexit {SolutionName|ProjectName}

Arguments
SolutionName Required. The full path and name of a solution file.
ProjectName Required. The full path and name of a project file.

Remarks
Compiles and runs the specified project or solution according to the settings specified for the active solution
configuration. This switch minimizes the IDE while the project or solution is run, and it closes the IDE after the
project or solution has completed running.
Enclose strings that include spaces in double quotation marks.
Summary information, including errors, can be displayed in the Command window, or in any log file
specified with the /out switch.

Example
This example runs the solution MySolution in a minimized IDE using the active deployment configuration, and
then closes the IDE.

devenv /runexit "C:\Documents and Settings\someuser\My Documents\Visual


Studio\Projects\MySolution\MySolution.sln"

See Also
Devenv Command Line Switches /Run (devenv.exe) /Build (devenv.exe) /Rebuild (devenv.exe) /Out (devenv.exe)
/SafeMode (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Starts Visual Studio in safe mode, loading only the default environment and services.

Syntax
devenv /SafeMode

Remarks
This switch prevents all third-party VSPackages from loading when Visual Studio starts, thus ensuring stable
execution.

Description
The following example starts Visual Studio in safe mode.

Code
Devenv.exe /SafeMode

See Also
Devenv Command Line Switches
/Setup (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Forces Visual Studio to merge the resource metadata that describes menus, toolbars, and command groups, from
all available VSPackages.

Syntax
devenv /setup

Remarks
This switch takes no arguments. The devenv /setup command is typically given as the last step of the installation
process. Use of the /setup switch does not start Visual Studio.
You must run devenv as an administrator in order to use the /setup (devenv.exe) and /InstallVSTemplates
(devenv.exe) switches.

Example
This example shows the last step in the installation of a version of Visual Studio that includes VSPackages.

devenv /setup

See Also
Devenv Command Line Switches
/Updateconfiguration (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Notifies Visual Studio to merge the Visual Studio packages on the system and check the MEF cache for any
changes.

Syntax
devenv /updateconfiguration

Remarks
Visual Studio runs this command automatically when you install a VSIX package. You should run
devenv.exe /updateconfiguration after patching your files so that Visual Studio updates the MEF cache. This
enables you to evaluate whether your fix is adequate.

Example
The following command line causes Visual Studio to merge the Visual Studio packages on the system and check
the MEF cache for any changes.

Devenv.exe /updateconfiguration

See Also
Customizing Development Settings in Visual Studio Devenv Command Line Switches
/Upgrade (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Updates the solution file and all of its project files, or the project file specified, to the current Visual Studio formats
for these files.

Syntax
devenv SolutionFile | ProjectFile /upgrade

Arguments
SolutionFile Required if you are upgrading an entire solution and its projects. The path and name of a solution
file. You can enter just the name of the solution file, or a full path and the name of the solution file. If the folder or
file named does not yet exist, it will be created.
ProjectFile Required if you are upgrading a single project. The path and name of a project file within the solution.
You can enter just the name of the project file, or a full path and the name of the project file. If the folder or file
named does not yet exist, it will be created.

Remarks
Backups are automatically created and copied to a directory named Backup that is created in the current directory.
Source-controlled solutions or projects must be checked out before they can be upgraded.
Using the /upgrade switch does not start Visual Studio. Results of the upgrade can be seen in the Upgrade Report
for the development language of the solution or project. No error or usage info is returned. For more information
on upgrading projects in Visual Studio, see How to: Troubleshoot Unsuccessful Visual Studio Project Upgrades.

Example
This example upgrades a solution file named "MyProject.sln" in your default folder for Visual Studio solutions.

devenv "MyProject.sln" /upgrade

See Also
How to: Troubleshoot Unsuccessful Visual Studio Project Upgrades Devenv Command Line Switches
/UseEnv (devenv.exe)
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Starts Visual Studio and loads environmental variables into the VC++ Directories dialog box.

Syntax
Devenv /useenv

Example
The following example starts Visual Studio and loads environment variables into the VC++ Directories dialog
box.

Devenv.exe /useenv

See Also
Devenv Command Line Switches
Visual Studio Commands
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Visual Studio commands allow you to invoke a command from the Command window, Immediate window,
or Find/Command box. In each case, the greater than sign ( > ) is used to indicate that a command rather
than a search or debug operation is to follow.
You can find a complete list of commands and their syntax in the Keyboard, Environment Options dialog
box.
The escape character for Visual Studio commands is a caret (^) character, which means that the character
immediately following it is interpreted literally, rather than as a control character. This can be used to embed
straight quotation marks ("), spaces, leading slashes, carets, or any other literal characters in a parameter or
switch value, with the exception of switch names. For example,

>Edit.Find ^^t /regex

A caret functions the same whether it is inside or outside quotation marks. If a caret is the last character on
the line, it is ignored.
In localized versions of the IDE, command names can be entered either in the native language of the IDE or in
English. For example, you can type either File.NewFile or Fichier.NouveauFichier in the French IDE to
execute the same command.
Many commands have aliases. For a list of command aliases, see Visual Studio Command Aliases.
The following commands take arguments and/or switches.

C OMMAND NAME DESC RIP T IO N

Add Existing Item Adds an existing file to the current solution and opens it.

Add Existing Project Adds an existing project to the current solution.

Add New Item Adds a new solution item, such as an .htm, .css, .txt, or
frameset to the current solution and opens it.

Alias Creates a new alias for a complete command, complete


command and arguments, or even another alias.

Evaluate Statement Evaluates and displays the given statement.

Find Searches files using a subset of the options available on the


Find and Replace control.
C OMMAND NAME DESC RIP T IO N

Find in Files Searches files using a subset of the options available on the
Find in Files.

Go To Moves the cursor to the specified line.

List Call Stack Displays the current call stack.

List Disassembly Begins the debug process and allows you to specify how
errors are handled.

List Memory Displays the contents of the specified range of memory.

List Modules Lists the modules for the current process.

List Registers Displays a list of registers.

List Source Displays the specified lines of source code.

List Threads Displays a list of the threads in the current program.

Log Command Window Output Copies all input and output from the Command window
into a file.

New File Creates a new file and adds it to the currently selected
project.

Open File Opens an existing file and allows you to specify an editor.

Open Project Opens an existing project and allows you to add the
project to the current solution.

Open Solution Opens an existing solution.

Print Evaluates the expression and displays the results or the


specified text.

Quick Watch Command Displays the selected or specified text in the Expression
field of the Quick Watch dialog box.

Replace Replaces text in files using a subset of the options available


on the Find and Replace control.

Replace in Files Replaces text in files using a subset of the options available
in the Replace in Files.

Set Current Stack Frame Allows you to view a particular stack frame.

Set Current Thread Allows you to view a particular thread.

Set Radix Determines the number of bytes to view.


C OMMAND NAME DESC RIP T IO N

Shell Launches programs from within Visual Studio as though


the command has been executed from the command
prompt.

ShowWebBrowser Command Displays the URL you specify in a Web browser window
either within the integrated development environment
(IDE) or external to the IDE.

Start Begins the debug process and allows you to specify how
errors are handled.

Path Sets the list of directories for the debugger to search for
symbols.

Toggle Breakpoint Turns the breakpoint either on or off, depending on its


current state, at the current location in the file.

Watch Command Creates and opens a specified instance of a Watch window.

See Also
Command Window Find/Command Box Visual Studio Command Aliases
Visual Studio Command Aliases
10/18/2019 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Aliases provide a means for entering a command into the Find/Command box or Command window by
shortening the text needed to execute the command. For example, instead of entering >File.OpenFile to
display the Open File dialog box, you can use the pre-defined alias >of .
Type alias in the Command window to display a list of the current aliases and their definitions. Type >cls
to clear the contents of the Command window. If you want to see an alias for a specific command, type
alias <command name> .

You can easily create your own alias for one of the Visual Studio commands (with or without arguments). For
example, the syntax for aliasing File.NewFile MyFile.txt is alias MyAlias File.NewFile MyFile.txt . You can
delete one of your aliases with alias <alias name> /delete
The table below contains a list of the pre-defined Visual Studio command aliases. Some command names
have more than one pre-defined alias. Click the links for the command names below to display detailed topics
that explain the correct syntax, arguments, and switches for those commands.

C OMMAND NAME A L IA S C O M P L ET E N A M E

Print Command ? Debug.Print

Quick Watch Command ?? Debug.Quickwatch

Add New Project AddProj File.AddNewProject

Alias Command Alias Tools.Alias

Autos window Autos Debug.Autos

Breakpoints window bl Debug.Breakpoints

Toggle Breakpoint bp Debug.ToggleBreakPoint

Call Stack window CallStack Debug.CallStack

Clear Bookmarks ClearBook Edit.ClearBookmarks

Close Close File.Close

Close All Documents CloseAll Window.CloseAllDocuments

Clear All cls Edit.ClearAll


C OMMAND NAME A L IA S C O M P L ET E N A M E

Command mode cmd View.CommandWindow

View Code code View.ViewCode

List Memory Command d Debug.ListMemory

List Memory Command as ANSI da Debug.ListMemory /Ansi

List Memory Command One Byte db Debug.ListMemory /Format:OneByte


format

List Memory Command as ANSI with dc Debug.ListMemory


Four Byte format /Format:FourBytes /Ansi

List Memory Command Four Byte dd Debug.ListMemory


format /Format:FourBytes

Delete to BOL DelBOL Edit.DeleteToBOL

Delete to EOL DelEOL Edit.DeleteToEOL

Delete Horizontal Whitespace DelHSp Edit.DeleteHorizontalWhitespace

View Designer designer View.ViewDesigner

List Memory Command Float format df Debug.ListMemory/Format:Float

Disassembly window disasm Debug.Disassembly

List Memory Command Eight Byte dq Debug.ListMemory


format /Format:EightBytes

List Memory Command as Unicode du Debug.ListMemory /Unicode

Evaluate Statement Command eval Debug.EvaluateStatement

Exit Exit File.Exit

Format Selection format Edit.FormatSelection

Full Screen FullScreen View.FullScreen

Start Command g Debug.Start

Go To Command GotoLn Edit.GoTo

Go to Brace GotoBrace Edit.GotoBrace

F1Help Help Help.F1Help

Immediate Mode immed Tools.ImmediateMode


C OMMAND NAME A L IA S C O M P L ET E N A M E

Insert File as Text InsertFile Edit.InsertFileAsText

List Call Stack Command kb Debug.ListCallStack

Make Lower Case Lcase Edit.MakeLowercase

Cut Line LineCut Edit.LineCut

Delete Line LineDel Edit.LineDelete

List Members ListMembers Edit.ListMembers

Locals window Locals Debug.Locals

Log Command Window Output Log Tools.LogCommandWindowOutput


Command

Command Window Mark Mode mark Tools.CommandWindowMarkMode

Memory window Memory Memory1 Debug.Memory1

Memory Window 2 Memory2 Debug.Memory2

Memory Window 3 Memory3 Debug.Memory3

Memory Window 4 Memory4 Debug.Memory4

Set Radix Command n Debug.SetRadix

ShowWebBrowser Command nav navigate View.ShowWebBrowser

Next Bookmark NextBook Edit.NextBookmark

New File Command nf File.NewFile

New Project np NewProj File.NewProject

Open File Command of Open File.OpenFile

Open Project Command op File.OpenProject

Collapse to Definitions/Stop Outlining OutlineDefs StopOutlining Edit.CollapsetoDefinitions

Step Over p Debug.StepOver

Parameter Information ParamInfo Edit.ParameterInfo

Step Out pr Debug.StepOut

Previous Bookmark PrevBook Edit.PreviousBookmark


C OMMAND NAME A L IA S C O M P L ET E N A M E

Print File print File.Print

Properties Window props View.PropertiesWindow

Stop q Debug.StopDebugging

Redo redo Edit.Redo

Registers window registers Debug.Registers

Run to Cursor rtc Debug.RunToCursor

Save Selected Items save File.SaveSelectedItems

Save All SaveAll File.SaveAll

Save As SaveAs File.SaveSelectedItemsAs

Shell Command shell Tools.Shell

Stop Find In Files StopFind Edit.FindInFiles /stop

Swap Anchor SwapAnchor Edit.SwapAnchor

Step Into t Debug.StepInto

Tabify Selection tabify Edit.TabifySelection

Tasklist window TaskList View.TaskList

Threads window Threads Debug.Threads

Tile Horizontally TileH Window.TileHorizontally

Tile Vertically TileV Window.TileVertically

Toggle Bookmark ToggleBook Edit.ToggleBookmark

Toolbox window toolbox View.Toolbox

List Disassembly Command u Debug.ListDisassembly

Make Uppercase Ucase Edit.MakeUppercase

Undo undo Edit.Undo

Untabify Selection Untabify Edit.UntabifySelection

Watch window Watch Debug.WatchN


C OMMAND NAME A L IA S C O M P L ET E N A M E

Toggle Word Wrap WordWrap Edit.ToggleWordWrap

List Processes | Debug.ListProcesses

List Threads Command ~ ~*k ~*kb Debug.ListThreads Debug.ListTheads


/AllThreads

See Also
Visual Studio Commands Command Window Find/Command Box
Add Existing Item Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Adds an existing file to the current solution and opens it.

Syntax
File.AddExistingItem filename [/e:editorname]

Arguments
filename Required. The full path and file name, with extension, of the item to add to the current solution. If the file
path or file name contains spaces, enclose the entire path in quotation marks.

Switches
/e: editorname Optional. Name of the editor in which the file will be opened. If the argument is specified but no
editor name is supplied, the Open With dialog box appears.
The /e: editorname argument syntax uses the editor names as they appear in the Open With Dialog Box ,
enclosed in quotation marks. For example, to open a style sheet in the source code editor, you would enter the
following for the /e: editorname argument.

/e:"Source Code (text) Editor"

Remarks
Autocompletion tries to locate the correct path and file name as you type.

Example
This example adds the file, Form1.frm, to the current solution.

>File.AddExistingItem "C:\public\solution files\Form1.frm"

See Also
Visual Studio Commands Command Window Find/Command Box Visual Studio Command Aliases
Add Existing Project Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Adds an existing project to the current solution.

Syntax
File.AddExistingProject filename

Arguments
filename Optional. The full path and project name, with extension, of the project to add to the solution.
If the filename argument includes spaces, it must be enclosed in quotation marks.
If no filename is specified, the command will open the file dialog so that user can pick a project.

Remarks
Auto completion tries to locate the correct path and file name as you type.

Example
This example adds the Visual Basic project, TestProject1, to the current solution.

>File.AddExistingProject "c:\visual studio projects\TestProject1.vbproj"

See Also
Visual Studio Commands Command Window Find/Command Box Visual Studio Command Aliases
Add New Item Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Adds a new solution item, such as an .htm, .css, .txt, or frameset to the current solution and opens it.

Syntax
File.AddNewItem [filename] [/t:templatename] [/e:editorname]

Arguments
filename Optional. The path and file name of the item to add to the solution.

Switches
/t: templatename Optional. Specifies the type of file to be created. If no template name is given, a text file is created
by default.
The /t: templatename argument syntax mirrors the information found in the Add New Solution Item dialog box.
You must enter the complete category followed by the file type, separating the category name from the file type by
a backslash ( \ ) and enclosing the entire string in quotation marks.
For example, to create a new text file, you would enter the following for the /t: templatename argument.

/t:"General\Style Sheet"

/e: editorname Optional. The name of the editor in which the file will be opened. If the argument is specified but no
editor name is supplied, the Open With dialog box appears.
The /e: editorname argument syntax uses the editor names as they appear in the Open With Dialog Box ,
enclosed in quotation marks.
For example, to open a style sheet in the source code editor, you would enter the following for the /e: editorname
argument.

/e:"Source Code (text) Editor"

Example
This example adds a new solution item, MyHTMLpg, to the current solution.
>File.AddNewItem MyHTMLpg /t:"General\HTML Page"

See Also
Visual Studio Commands Command Window Find/Command Box Visual Studio Command Aliases
Alias Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Creates a new alias for a complete command, complete command and arguments, or another alias.

TIP
Typing >alias without any arguments displays the current list of aliases and their definitions.

Syntax
Tools.Alias [/delete] [/reset] [aliasname] [aliasstring]

Arguments
aliasname Optional. The name for the new alias. If no value is supplied for aliasname , a list of the current aliases
and their definitions appears.
aliasstring Optional. The complete command name or existing alias and any parameters that you want to create
as an alias. If no value is supplied for aliasstring , the alias name and alias string for the specified alias displays.

Switches
/delete or /del or /d Optional. Deletes the specified alias, removing it from autocompletion.
/reset Optional. Resets the list of pre-defined aliases to its original settings. That is, it restores all pre-defined
aliases and removes all user-defined aliases.

Remarks
Since aliases represent commands, they must be located at the beginning of the command line.
When issuing this command, you should include the switches immediately after the command, not after the
aliases, otherwise the switch itself will be included as part of the alias string.
The /reset switch asks for a confirmation before the aliases are restored. There is no short form of /reset .

Examples
This example creates a new alias, upper , for the complete command Edit.MakeUpperCase.

>Tools.Alias upper Edit.MakeUpperCase


This example deletes the alias, upper .

>Tools.alias /delete upper

This example displays a list of all current aliases and definitions.

>Tools.Alias

See Also
Visual Studio Commands Command Window Find/Command Box Visual Studio Command Aliases
Evaluate Statement Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Evaluates and displays the given statement.

Syntax
Debug.EvaluateStatement text

Arguments
text Required. The statement to evaluate.

Remarks
The window used to enter the EvaluateStatement command determines whether an equals sign (=) is
interpreted as a comparison operator or as an assignment operator.
In the Command window, an equals sign (=) is interpreted as a comparison operator. So, for example, if the values
of variables a and b are different, then the command

>Debug.EvaluateStatement(a=b)

will return a value of false .


In the Immediate window, by contrast, an equals sign (=) is interpreted as an assignment operator. So, for
example, the command

>Debug.EvaluateStatement(a=b)

will assign to variable a the value of variable b .

Example
>Debug.EvaluateStatement(a+b)

See Also
Print Command Visual Studio Commands Command Window Find/Command Box Visual Studio Command Aliases
Find Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Searches files using a subset of the options available on the Find in Files tab of the Find and Replace window.

Syntax
Edit.Find findwhat [/case] [/doc | /proc | /open | /sel]
[/markall] [/options] [/reset] [/up] [/wild | /regex] [/word]

Arguments
findwhat Required. The text to match.

Switches
/case or /c Optional. Matches occur only if the uppercase and lowercase characters exactly match those specified in
the findwhat argument.
/doc or /d Optional. Searches the current document only. Specify only one of the available search scopes, /doc ,
/proc , /open , or /sel .

/markall or /m Optional. Places a graphic on each line that contains a search match within the current document.
/open or /o Optional. Searches all open documents as if they were one document. Specify only one of the available
search scopes, /doc , /proc , /open , or /sel .
/options or /t Optional. Displays a list of the current find option settings and does not perform a search.
/proc or /p Optional. Searches the current procedure only. Specify only one of the available search scopes, /doc ,
/proc , /open , or /sel .

/reset or /e Optional. Returns the find options to their default settings and does not perform a search.
/sel or /s Optional. Searches the current selection only. Specify only one of the available search scopes, /doc ,
/proc , /open , or /sel .

/up or /u Optional. Searches from the current location in the file toward the beginning of the file. By default,
searches begin at the current location in the file and searches towards the end of the file.
/regex or /r Optional. Uses pre-defined special characters in the findwhat argument as notations that represent
patterns of text rather than the literal characters. For a complete list of regular expression characters, see Regular
Expressions.
/wild or /l Optional. Uses pre-defined special characters in the findwhat argument as notations to represent a
character or sequence of characters.
/word or /w Optional. Searches only for whole words.

Example
This example performs a case-sensitive search for the word "somestring" in the currently selected section of code.

>Edit.Find somestring /sel /case

See Also
Command Window Find/Command Box Visual Studio Commands Visual Studio Command Aliases
Find in Files Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Search files using a subset of the options available on the Find in Files tab of the Find and Replace window.

Syntax
Edit.FindinFiles findwhat [/case] [/ext:extensions]
[/lookin:searchpath] [/names] [/options] [/reset] [/stop] [/sub]
[/text2] [/wild|/regex] [/word]

Arguments
findwhat Required. The text to match.

Switches
/case or /c Optional. Matches occur only if the uppercase and lowercase characters exactly match those specified in
the findwhat argument.
/ext: extensions Optional. Specifies the file extensions for the files to be searched. If not specified, the previous
extension is used if one was previously entered.
/lookin: searchpath Optional. Directory to search. If the path contains spaces, enclose the entire path in quotation
marks.
/names or /n Optional. Displays a list of file names that contain matches.
/options or /t Optional. Displays a list of the current find option settings and does not perform a search.
/regex or /r Optional. Uses pre-defined special characters in the findwhat argument as notations that represent
patterns of text rather than the literal characters. For a complete list of regular expression characters, see Regular
Expressions.
/reset or /e Optional. Returns the find options to their default settings and does not perform a search.
/stop Optional. Halts the current search operation if one is in progress. Search ignores all other arguments when
/stop has been specified. For example, to stop the current search you would enter the following:

>Edit.FindinFiles /stop

/sub or /s Optional. Searches the subfolders within the directory specified in the /lookin: searchpath argument.
/text2 or /2 Optional. Displays the results of the search in the Find Results 2 window.
/wild or /l Optional. Uses pre-defined special characters in the findwhat argument as notations to represent a
character or sequence of characters.
/word or /w Optional. Searches only for whole words.

Example
This example searches for btnCancel in all .cls files located in the folder "My Visual Studio Projects" and displays the
match information in the Find Results 2 Window.

>Edit.FindinFiles btnCancel /lookin:"c:/My Visual Studio Projects" /ext:*.cls /text2

See Also
Find in Files Command Window Find/Command Box Visual Studio Commands Visual Studio Command Aliases
Go To Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Moves the cursor to the specified line.

Syntax
Edit.GoTo [linenumber]

Arguments
linenumber Optional. An integer representing the number of the line to go to.

Remarks
The line numbering begins at one. If the value of linenumber is less than one, the first line displays. If the value of
linenumber is greater than the number of the last line, the last line displays.

If a value for linenumber is not specified, the Go To Line dialog box displays.
The alias for this command is GoToLn.

Example
>Edit.GoTo 125

See Also
Visual Studio Commands Command Window Find/Command Box Visual Studio Command Aliases
Import and Export Settings Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Imports, exports, or resets Visual Studio settings.

Syntax
Tools.ImportandExportSettings [/export:filename | /import:filename | /reset]

Switches
/export: filename Optional. Exports the current settings to the specified file.
/import: filename Optional. Imports the settings in the specified file.
/reset Optional. Resets the current settings.

Remarks
Running this command with no switches opens the Impor t and Expor t Settings wizard. For more information,
see How to: Share Settings Between Computers or Visual Studio Versions.

Example
The following command exports the curent settings to the file MyFile.vssettings .

Tools.ImportandExportSettings /export:"c:\Files\MyFile.vssettings"

See Also
Customizing Development Settings in Visual Studio Visual Studio Commands
List Call Stack Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Displays the current call stack.

Syntax
Debug.ListCallStack [/Count:number] [/ShowTypes:yes|no]
[/ShowNames:yes|no] [/ShowValues:yes|no] [/ShowModule:yes|no]
[/ShowLineOffset:yes|no] [/ShowByteOffset:yes|no]
[/ShowLanguage:yes|no] [/IncludeCallsAcrossThreads:yes|no]
[/ShowExternalCode:yes|no] [Thread:n] [index]

Arguments
index Optional. Sets the current stack frame and displays no output.

Switches
Each switch can be invoked using either its complete form or a short form.
/Count: number [or] /C: number Optional. Maximum number of call stacks to display. The default value is unlimited.
/ShowTypes: yes | no [or] /T: yes | no Optional. Specifies whether to display parameter types. Default value is
yes .

/ShowNames: yes | no [or] /N: yes | no Optional. Specifies whether to display parameter names. Default value is
yes .

/ShowValues: yes | no [or] /V: yes | no Optional. Specifies whether to display parameter values. Default value is
yes .

/ShowModule: yes | no [or] /M: yes | no Optional. Specifies whether to display the module name. Default value is
yes .

/ShowLineOffset: yes | no [or] /#: yes | no Optional. Specifies whether to display the line offset. Default value is
no .

/ShowByteOffset: yes | no [or] /B: yes | no Optional. Specifies whether to display the byte offset. Default value is
no .

/ShowLanguage: yes | no [or] /L: yes | no Optional. Specifies whether to display the language. Default value is
no .

/IncludeCallsAcrossThreads: yes | no [or] /I: yes | no Optional. Specifies whether to include calls to or from other
threads. Default value is no .
/ShowExternalCode: yes | no Optional. Specifies whether to display Just My Code for the callstack. When Just My
Code is off, all non-user code is displayed. When Just My Code is on, non-user code is displayed as [external] in
the callstack output.
Thread: n Optional. Displays the callstack for thread n . If no thread is specified, diplays the callstack for the
current thread.

Remarks
Changes made to the arguments or switches apply to future invocations of this command. If you issue
Debug.ListCallStackby itself, the entire call stack displays. If you specify an index, for example,

Debug.ListCallStack 2

then the current stack frame is set to that frame (in this case, the second frame).
You can also write this command using its pre-defined alias, kb. For example, you can enter

kb 2

to set the current stack frame to the second frame.

Example
>Debug.CallStack /Count:4 /ShowTypes:yes

See Also
List Disassembly Command List Threads Command Visual Studio Commands Command Window Find/Command
Box Visual Studio Command Aliases
List Disassembly Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Begins the debug process and allows you to specify how errors are handled.

Syntax
Debug.ListDisassembly [/count:number] [/endaddress:expression]
[/codebytes:yes|no] [/source:yes|no] [/symbolnames:yes|no]
[/linenumbers:yes|no]

Switches
Each switch can be invoked using either its complete form or a short form.
/count: number [or] /c: number [or] /length: number [or] /l: number Optional. Number of instructions to display.
Default value is 8.
/endaddress: expression [or] /e: expression Optional. Address at which to stop disassembly.
/codebytes: yes | no [or] /bytes: yes | no [or] /b: yes | no Optional. Indicates whether to display code bytes.
Default value is no .
/source: yes | no [or] /s: yes | no Optional. Indicates whether to display source code. Default value is no .
/symbolnames: yes | no [or] /names: yes | no [or] /n: yes | no Optional. Indicates whether to display symbols
names. Default value is yes .
[/linenumbers: yes | no ] Optional. Enables the viewing of line numbers associated with the source code. The
/source switch must have a value of yes to use the /linenumbers switch.

Example
>Debug.ListDisassembly

See Also
List Call Stack Command List Threads Command Visual Studio Commands Command Window Find/Command
Box Visual Studio Command Aliases
List Memory Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Displays the contents of the specified range of memory.

Syntax
Debug.ListMemory [/ANSI|Unicode] [/Count:number] [/Format:formattype]
[/Hex|Signed|Unsigned] [expression]

Arguments
expression Optional. The memory address from which to begin displaying memory.

Switches
/ANSI|Unicode Optional. Display the memory as characters corresponding to the bytes of memory, either ANSI
or Unicode.
/Count: number Optional. Determines how many bytes of memory to display, starting at expression .
/Format: formattype Optional. Format type for viewing memory information in the Memor y window; may be
OneByte, TwoBytes, FourBytes, EightBytes, Float (32-bit), or Double (64-bit). If OneByte is used, /Unicode is
unavailable.
/Hex|Signed|Unsigned Optional. Specifies the format for viewing numbers: as signed, unsigned, or hexadecimal.

Remarks
Instead of writing out a complete Debug.ListMemor y command with all switches, you can invoke the
command using predefined aliases with certain switches preset to specified values. For example, instead of
entering:

>Debug.ListMemory /Format:float /Count:30 /Unicode

you can write:

>df /Count:30 /Unicode

Here is a list of the available aliases for the Debug.ListMemor y command:


A L IA S C O M M A N D A N D SW ITC H ES

d Debug.ListMemory

da Debug.ListMemory /Ansi

db Debug.ListMemory /Format:OneByte

dc Debug.ListMemory /Format:FourBytes /Ansi

dd Debug.ListMemory /Format:FourBytes

df Debug.ListMemory /Format:Float

dq Debug.ListMemory /Format:EightBytes

du Debug.ListMemory /Unicode

Example
>Debug.ListMemory /Format:float /Count:30 /Unicode

See Also
List Call Stack Command List Threads Command Visual Studio Commands Command Window Find/Command
Box Visual Studio Command Aliases
List Modules Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Lists the modules for the current process.

Syntax
Debug.ListModules [/Address:yes|no] [/Name:yes|no] [/Order:yes|no]
[/Path:yes|no] [/Process:yes|no] [/SymbolFile:yes|no]
[/SymbolStatus:yes|no] [/Timestamp:yes|no] [/Version:yes|no]

Parameters
/Address: yes|no Optional. Specifies whether to show the memory addresses of the modules. Default value is yes .
/Name: yes|no Optional. Specifies whether to show the names of the modules. Default value is yes .
/Order: yes|no Optional. Specifies whether to show the order of the modules. Default value is no .
/Path: yes|no Optional. Specifies whether to show the paths of the modules. Default value is yes .
/Process: yes|no Optional. Specifies whether to show the processes of the modules. Default value is no .
/SymbolFile: yes|no Optional. Specifies whether to show the symbol files of the modules. Default value is no .
/SymbolStatus: yes|no Optional. Specifies whether to show the symbol statuses of the modules. Default value is
yes .

/Timestamp: yes|no Optional. Specifies whether to show the timestamps of the modules. Default value is no .
/Version: yes|no Optional. Specifies whether to show the versions of the modules. Default value is no .

Remarks
Example
This example lists the module names, addresses, and timestamps for the current process.

Debug.ListModules /Address:yes /Name:yes /Order:no /Path:no /Process:no /SymbolFile:no /SymbolStatus:no


/Timestamp:yes /Version:no

See Also
Visual Studio Commands Command Window How to: Use the Modules Window
List Registers Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Displays the value of the selected registers and lets you modify the list of registers to show.

Syntax
Debug.ListRegisters [/Display [{register|registerGroup}...]] [/List]
[/Watch [{register|registerGroup}...]]
[/Unwatch [{register|registerGroup}...]]

Switches
/Display [{ register | registerGroup }...] Displays the values of the specified register or registerGroup . If no
register or registerGroup is specified, the default list of registers is displayed. If no switch is specified, the
behavior is the same. For example:
Debug.ListRegisters /Display eax

is equivalent to
Debug.ListRegisters eax

/List Displays all register groups in the list.


/Watch [{ register | registerGroup }...] Adds one or more register or registerGroup values to the list.
/Unwatch [{ register | registerGroup }...] Removes one or more register or registerGroup values from the list.

Remarks
The alias r can be used in place of Debug.ListRegisters .

Example
This example uses the Debug.ListRegisters alias r to display the values of the register group Flags .

r /Display Flags

See Also
Visual Studio Commands Debugging Basics: Registers Window How to: Use the Registers Window
List Source Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Displays the specified lines of source code.

Syntax
Debug.ListSource [/Count:number] [/Current] [/File:filename]
[/Line:number] [/ShowLineNumbers:yes|no]

Switches
/Count: number Optional. Specifies the number of lines to display.
/Current Optional. Shows the current line.
/File: filename Optional. Path of the file to show. If no filename is specified, the command shows the source code
for the line of the current statement.
/Line: number Optional. Shows a specific line number.
/ShowLineNumbers: yes|no Optional. Specifies whether to display line numbers.

Remarks
Example
This example lists the source code from line 4 of the file Form1.vb, with line numbers visible.

Debug.ListSource /File:"C:\Visual Studio Projects\Form1.vb" /Line:4 /ShowLineNumbers:yes

See Also
Visual Studio Commands Command Window
List Threads Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Displays a list of the threads in the current program.

Syntax
Debug.ListThreads [index]

Arguments
index Optional. Selects a thread by its index to be the current thread.

Remarks
When specified, the index argument marks the indicated thread as the current thread. An asterisk (*) is displayed
in the list next to the current thread.

Example
>Debug.ListThreads

See Also
List Call Stack Command List Disassembly Command Visual Studio Commands Command Window
Find/Command Box Visual Studio Command Aliases
Log Command Window Output Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Copies all input and output from the Command window into a file.

Syntax
Tools.LogCommandWindowOutput [filename] [/on|/off] [/overwrite]

Arguments
filename Optional. The name of the log file. By default, the file is created in the user's profile folder. If the file name
already exists, the log is appended to the end of the existing file. If no file is specified, the last file specified is used.
If no previous file exists, a default log file is created, called cmdline.log.

TIP
To change the location where the log file is saved, enter the full path of the file, surrounded by quotation marks if the path
contains any spaces.

Switches
/on Optional. Starts the log for the Command window in the specified file and appends the file with the new
information.
/off Optional. Stops the log for the Command window.
/overwrite Optional. If the file specified in the filename argument matches an existing file, the file is overwritten.

Remarks
If no file is specified, the file cmdline.log is created by default. By default, the alias for this command is Log.

Examples
This example creates a new log file, cmdlog, and starts the command log.

>Tools.LogCommandWindowOutput cmdlog

This example stops logging commands.

>Tools.LogCommandWindowOutput /off
This example resumes the logging of commands in the previously used log file.

>Tools.LogCommandWindowOutput /on

See Also
Visual Studio Commands Command Window Find/Command Box Visual Studio Command Aliases
New File Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Creates a new file and opens it. The file appears under the Miscellaneous Files folder.

Syntax
File.NewFile [filename] [/t:templatename] [/editor:editorname]

Arguments
filename Optional. Name for the file. If no name is supplied, a default name is provided. If no template name is
listed, a text file is created.

Switches
/t: templatename Optional. Specifies the type of file to be created.
The /t: templatename argument syntax mirrors the information found in the New File Dialog Box. Enter the category
name followed by a backslash ( \ ) and the template name, and enclose the entire string in quotation marks.
For example, to create a new Visual C++ source file, you would enter the following for the /t: templatename
argument.

/t:"Visual C++\C++ File (.cpp)"

The example above indicates that the C++ File template is located under the Visual C++ category in the New File
dialog box.
/e: editorname Optional. Name of the editor in which the file will be opened. If the argument is specified but no
editor name is supplied, the Open With dialog box appears.
The /e: editorname argument syntax uses the editor names as they appear in the Open With Dialog Box, enclosed
in quotation marks.
For example, to open a file in the source code editor, you would enter the following for the /e: editorname
argument.

/e:"Source Code (text) Editor"

Example
This example creates a new Web page "test1.htm" and opens it in the source code editor.
>File.NewFile test1 /t:"General\HTML Page" /e:"Source Code (text) Editor"

See Also
Visual Studio Commands Command Window Immediate Window Find/Command Box Visual Studio Command
Aliases
Open File Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Opens an existing file and allows you to specify an editor.

Syntax
File.OpenFile filename [/e:editorname]

Arguments
filename Required. The full or partial path and file name of the file to open. Paths containing spaces must be
enclosed in quotation marks.

Switches
/e: editorname Optional. Name of the editor in which the file will be opened. If the argument is specified but no
editor name is supplied, the Open With dialog box appears.
The /e: editorname argument syntax uses the editor names as they appear in the Open With Dialog Box, enclosed
in quotation marks.
For example, to open a file in the source code editor, you would enter the following for the /e: editorname
argument.

/e:"Source Code (text) Editor"

Remarks
As you enter a path, auto completion tries to locate the correct path and file name.

Example
This example opens the style file "Test1.css" in the source code editor.

>File.OpenFile "C:\My Projects\project1\Test1.css" /e:"Source Code (text) Editor"

See Also
Visual Studio Commands Command Window Immediate Window Find/Command Box Visual Studio Command
Aliases
Open Project Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Opens an existing project.

Syntax
File.OpenProject filename

Arguments
filename Required. The full path and file name of the project to open.
The syntax for the filename argument requires that paths containing spaces use quotation marks.

Remarks
Auto completion tries to locate the correct path and file name as you type.
This command is not available while debugging.

Example
This example opens the Visual Basic project, Test1.

>File.OpenProject "C:\My Projects\Test1\Test1.vbproj"

See Also
Visual Studio Commands Command Window Find/Command Box Visual Studio Command Aliases
Open Solution Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Opens an existing solution, closing any other open solutions.

Syntax
File.OpenSolution filename

Arguments
Filename Required. The full path and file name of the solution to open.
The syntax for the filename argument requires that paths containing spaces use quotation marks.

Remarks
Auto completion tries to locate the correct path and file name as you type.

Example
This example opens the solution, Test1.sln.

>File.OpenSolution "c:\MySolutions\Test1\Test1.sln"

See Also
Visual Studio Commands Command Window Find/Command Box Visual Studio Command Aliases
Print Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Evaluates an expression, or displays specified text.

Syntax
Debug.Print text

Arguments
text Required. The expression to evaluate or the text to display.

Remarks
You can use the question mark (?) as an alias for this command. So, for example, the command

>Debug.Print expA

can also be written

>? expA

Both versions of this command will return the current value of the expression expA .

Example
>Debug.Print varA

See Also
Evaluate Statement Command Visual Studio Commands Command Window Find/Command Box Visual Studio
Command Aliases
Quick Watch Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Displays the selected or specified text in the Expression field of the QuickWatch Dialog Box. You can use this dialog
box to calculate the current value of a variable or expression recognized by the debugger, or the contents of a
register. In addition, you can change the value of any non-const variable or the contents of any register.

Syntax
Debug.QuickWatchq [text]

Arguments
text Optional. The text to add to the QuickWatch dialog box.

Remarks
If text is omitted, the currently selected text or word at the cursor is added to the Watch window.

Example
>Debug.QuickWatch

See Also
How to: Use the QuickWatch Dialog Box Visual Studio Commands Command Window Find/Command Box Visual
Studio Command Aliases
Replace Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Replaces text in files using a subset of the options available on the Replace in Files tab of the Find and Replace
window.

Syntax
Edit.Replace findwhat replacewith [/all] [/case]
[/doc|/proc|/open|/sel] [/hidden] [/options] [/reset] [/up]
[/wild|/regex] [/word]

Arguments
findwhat Required. The text to match.
replacewith Required. The text to substitute for the matched text.

Switches
/all or /a Optional. Replaces all occurrences of the search text with the replacement text.
/case or /c Optional. Matches occur only if when the uppercase and lowercase characters exactly match those
specified in the findwhat argument.
/doc or /d Optional. Searches the current document only. Specify only one of the available search scopes, /doc ,
/proc , /open , or /sel .

/hidden or /h Optional. Searches concealed and collapsed text, such as the metadata of a design-time control, a
hidden region of an outlined document, or a collapsed class or method.
/open or /o Optional. Searches all open documents as if they were one document. Specify only one of the available
search scopes, /doc , /proc , /open , or /sel .
/options or /t Optional. Displays a list of the current find option settings and does not perform a search.
/proc or /p Optional. Searches the current procedure only. Specify only one of the available search scopes, /doc ,
/proc , /open , or /sel .

/regex or /r Optional. Uses pre-defined special characters in the findwhat argument as notations that represent
patterns of text rather than the literal characters. For a complete list of regular expression characters, see Regular
Expressions.
/reset or /e Optional. Returns the find options to their default settings and does not perform a search.
/sel or /s Optional. Searches the current selection only. Specify only one of the available search scopes, /doc ,
/proc , /open , or /sel .
/up or /u Optional. Searches from the current location in the file toward the top of the file. By default, searches
begin at the current location in the file and advance toward the bottom of the file.
/wild or /l Optional. Uses pre-defined special characters in the findwhat argument as notations to represent a
character or sequence of characters.
/word or /w Optional. Searches only for whole words.

Example
This example replaces btnSend with btnSubmit in all open documents.

>Edit.Replace btnSend btnSubmit /open

See Also
Finding and Replacing Text Command Window Find/Command Box Visual Studio Commands Visual Studio
Command Aliases
Replace In Files Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Replaces text in files using a subset of the options available on the Replace in Files tab of the Find and Replace
window.

Syntax
Edit.ReplaceinFiles findwhat replacewith [/all] [/case]
[/ext:extensions] [/keep] [/lookin:searchpath] [/options] [/regex]
[/reset] [/stop] [/sub] [/text2] [/wild] [/word]

Arguments
findwhat Required. The text to match.
replacewith Required. The text to substitute for the matched text.

Switches
/all or /a Optional. Replaces all occurrences of the search text with the replacement text.
/case or /c Optional. Matches occur only if when the uppercase and lowercase characters exactly match those
specified in the findwhat argument.
/ext: extensions Optional. Specifies the file extensions for the files to be searched.
/keep or /k Optional. Specifies that all modified files are left open.
/lookin: searchpath Optional. Directory to search. If the path contains spaces, enclose the entire path in quotation
marks.
/options or /t Optional. Displays a list of the current find option settings and does not perform a search.
/regex or /r Optional. Uses pre-defined special characters in the findwhat argument as notations that represent
patterns of text rather than the literal characters. For a complete list of regular expression characters, see Regular
Expressions.
/reset or /e Optional. Returns the find options to their default settings and does not perform a search.
/stop Optional. Halts the current search operation if one is in progress. Replace ignores all other arguments when
/stop has been specified. For example, to stop the current replacement you would enter the following:

>Edit.ReplaceinFiles /stop

/sub or /s Optional. Searches the subfolders within the directory specified in the /lookin: searchpath argument.
/text2 or /2 Optional. Displays the results of the replacement in the Find Results 2 window.
/wild or /l Optional. Uses pre-defined special characters in the findwhat argument as notations to represent a
character or sequence of characters.
/word or /w Optional. Searches for only whole words.

Example
This example searches for btnCancel and replaces it with btnReset in all .cls files located in the folder "my visual
studio projects" and displays the replacement information in the Find Results 2 window.

>Edit.ReplaceinFiles btnCancel btnReset /lookin:"c:/my visual studio projects" /ext:.cls /text2

See Also
Finding and Replacing Text Replace in Files Command Window Find/Command Box Visual Studio Commands
Visual Studio Command Aliases
Set Current Process
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Sets the specified process as the active process in the debugger.

Syntax
Debug.SetCurrentProcess index

Arguments
index Required. The index of the process.

Remarks
You can attach to multiple processes when you are debugging, but only one process is active in the dubber at any
given time. You can use the SetCurrentProcess command to set the active process.

Example
>Debug.SetCurrentProcess 1

See Also
Visual Studio Commands Command Window Visual Studio Command Aliases
Set Current Stack Frame Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Allows you to set a particular stack frame.

Syntax
Debug.SetCurrentStackFrame index

Arguments
index Required. Selects a stack frame by its index.

Example
>Debug.SetCurrentStackFrame 1

See Also
Visual Studio Commands Command Window Find/Command Box Visual Studio Command Aliases
Set Current Thread Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Sets the specified thread as the current thread.

Syntax
Debug.SetCurrentThread index

Arguments
index Required. Selects a thread by its index.

Example
>Debug.SetCurrentThread 1

See Also
Visual Studio Commands Command Window Find/Command Box Visual Studio Command Aliases
Set Radix Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Sets or returns the numeric base used to display integer values.

Syntax
Debug.SetRadix [10 | 16 | hex | dec]

Arguments
10 or 16 or hex or dec Optional. Indicates decimal (10 or dec) or hexadecimal (16 or hex). If an argument is
omitted, then the current radix value is returned.

Example
This example sets the environment to display integer values in hexadecimal format.

>Debug.SetRadix hex

See Also
Visual Studio Commands Command Window Find/Command Box Visual Studio Command Aliases
Shell Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Launches executable programs from within Visual Studio.

Syntax
Tools.Shell [/command] [/output] [/dir:folder] path [args]

Arguments
path Required. The path and file name of the file to execute or the document to open. A full path is required if the
specified file is not in one of the directories in the PATH environment variable.
args Optional. Any arguments to pass to the invoked program.

Switches
/commandwindow [or] /command [or] /c [or] /cmd Optional. Specifies that the output for the executable is
displayed in the Command window.
/dir: folder [or] /d: folder Optional. Specifies the working directory to be set when the program is run.
/outputwindow [or] /output [or] /out [or] /o Optional. Specifies that the output for the executable is displayed in
the Output window.

Remarks
The /dir /o /c switches must be specified immediately after Tools.Shell . Anything specified after the name of the
executable is passed to it as command line arguments.
The predefined alias Shell can be used in place of Tools.Shell .
Cau t i on

If the path argument supplies the directory path as well as the file name, you should enclose the entire pathname
in literal quotes ("""), as in the following:

Tools.Shell """C:\Program Files\SomeFile.exe"""

Each set of three double quotes (""") is interpreted by the Shell processor as a single double quote character.
Thus, the preceding example actually passes the following path string to the Shell command:

"C:\Program Files\SomeFile.exe"
Cau t i on

If you do not enclose the path string in literal quotes ("""), Windows will use only the portion of the string up to the
first space. For example, if the path string above were not quoted properly, Windows would look for a file named
"Program" located in the C:\ root directory. If a C:\Program.exe executable file were actually available, even one
installed by illicit tampering, Windows would attempt to execute that program in place of the desired "c:\Program
Files\SomeFile.exe" program.

Example
The following command uses xcopy.exe to copy the file MyText.txt into the Text folder. The output from
xcopy.exe is displayed in both the Command Window and the Output window.

>Tools.Shell /o /c xcopy.exe c:\MyText.txt c:\Text\MyText.txt

See Also
Visual Studio Commands Command Window Output Window Find/Command Box Visual Studio Command
Aliases
ShowWebBrowser Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Displays the URL you specify in a Web browser window either within the integrated development environment
(IDE) or external to the IDE.

Syntax
View.ShowWebBrowser URL [/new][/ext]

Arguments
URL Required. URL (Uniform Resource Locator) for the Web site.

Switches
/new Optional. Specifies that the page appears in a new instance of the Web browser.
/ext Optional. Specifies that the page appears in the default Web browser outside of the IDE.

Remarks
The alias for the ShowWebBrowser command is navigate or nav .

Example
The following example displays the MSDN Online home page in a Web browser outside of the IDE. If an instance of
the Web browser is already open, it is used; otherwise a new instance is launched.

>View.ShowWebBrowser https://msdn.microsoft.com /ext

See Also
Visual Studio Commands Command Window Find/Command Box Visual Studio Command Aliases
Start Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Begins debugging the startup project.

Syntax
Debug.Start [address]

Arguments
address Optional. The address at which the program suspends execution, similar to a breakpoint in source code.
This argument is only valid in debug mode.

Remarks
The Star t command, when executed, performs a RunToCursor operation to the specified address.

Example
This example starts the debugger and ignores any exceptions that occur.

>Debug.Start

See Also
Visual Studio Commands Command Window Find/Command Box Visual Studio Command Aliases
Symbol Path Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Sets the list of directories for the debugger to search for symbols.

Syntax
Debug.SymbolPath pathname1;pathname2;... pathnameN

Arguments
pathname Optional. A semi-colon delimited list of paths for the debugger to search for symbols.

Remarks
If no pathname is specified, the command lists the current symbol paths.

Example
This example adds two paths to the list of symbol directories.

Debug.SymbolPath C:\Symbol Path 1;C:\Symbol Path 2

Example
This example displays a semi-colon delimited list of current symbol paths.

Debug.SymbolPath

See Also
Command Window Visual Studio Commands
Toggle Breakpoint Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Turns the breakpoint either on or off, depending on its current state, at the current location in the file.

Syntax
Debug.ToggleBreakpoint [text]

Arguments
text Optional. If text is specified, the line is marked as a named breakpoint. Otherwise, the line is marked as an
unnamed breakpoint, which is similar to what happens when you press F9.

Example
The following example toggles the current breakpoint.

>Debug.ToggleBreakpoint

See Also
Visual Studio Commands Command Window Find/Command Box Visual Studio Command Aliases
Watch Command
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Creates and opens a specified instance of a Watch window. You can use a Watch window to calculate the values of
variables, expressions, and registers, to edit these values, and to save the results.

Syntax
Debug.Watch[index]

Arguments
index Required. The instance number of the watch window.

Remarks
The index must be an integer. Valid values are 1, 2, 3, or 4.

Example
>Debug.Watch1

See Also
Autos and Locals Windows How to: Edit a Value in a Variable Window How to: Use the QuickWatch Dialog Box
Visual Studio Commands Command Window Find/Command Box Visual Studio Command Aliases
XML Tools in Visual Studio
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Extensible Markup Language (XML)* is a markup language that provides a format for describing data. This
facilitates more precise declarations of content and more meaningful search results across multiple platforms. In
addition, XML enables the separation of presentation from data. For example, in HTML you use tags to tell the
browser to display data as bold or italic; in XML you use tags only to describe data, such as city name, temperature,
and barometric pressure. In XML you use style sheets such as Extensible Stylesheet Language (XSL) and cascading
style sheets (CSS) to present the data in a browser. XML separates the data from the presentation and the process.
This enables you to display and process the data as you want to, by applying different style sheets and applications.
XML is a subset of SGML that is optimized for delivery over the Web. It is defined by the World Wide Web
Consortium (W3C). This standardization guarantees that structured data will be uniform and independent of
applications or vendors.
XML is at the core of many features of Visual Studio and the .NET Framework. The following topic list names the
tools and features related to XML that are offered in Visual Studio and the .NET Framework.
For more information, see the XML Developer Center, which provides the latest documentation, technical
information, downloads, newsgroups, and other resources for XML developers.

In This Section
Working with XML Data Discusses the role of XML in the way data is handled in Visual Studio.
Debugging XSLT Provides links to topics about using the Visual Studio debugger to debug XSLT.

Reference
Microsoft.VisualStudio.XmlEditor Exposes the XML Editor parse tree through System.Xml.Linq for any XML
documents.
XML Standards Reference Provides information about XML technologies, including XML, Document Type Definition
(DTD), XML Schema definition language (XSD), and XSLT.
System.Xml Describes the classes and other elements that make up the System.Xml namespace and provides links
to more detailed information on each item.
System.Xml.Serialization Describes the classes and other elements that make up the System.Xml.Serialization
namespace and provides links to more detailed information about each item.

Related Sections
XML Document Object Model (DOM) Describes how the XmlDocument and its associated classes comply with the
W3C Document Object Model (Core) Level 1 and Level 2 namespace support specifications.
Reading XML with the XmlReader Describes how the XmlReader provides noncached, forward only, read-only
access to XML data over an XML stream.
Writing XML with the XmlWriter Describes how the XmlWriter provides noncached, forward only, way of
generating XML streams and helps you build XML documents that comply with the W3C standard.
XSLT Transformations Describes how the XslCompiledTransform class implements the XSLT 1.0 recommendation.
Process XML Data Using the XPath Data Model Describes how the XPathNavigator class can process XML data
stored in an XPathDocument or an XmlDocument object. The XPathNavigator class is based on the XQuery 1.0 and
XPath 2.0 Data Model and can be used to navigate and edit XML data.
XML Schema Object Model (SOM) Describes the classes used for creating and manipulating XML Schemas, by
providing an XmlSchema class to load and edit a schema.
Visual Studio for Applications Reference
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Visual Studio for Applications namespaces provide interfaces for integrating .NET Framework script engines
into applications.
MSBuild
8/2/2019 • 9 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Microsoft Build Engine is a platform for building applications. This engine, which is also known as MSBuild,
provides an XML schema for a project file that controls how the build platform processes and builds software.
Visual Studio uses MSBuild, but it doesn't depend on Visual Studio. By invoking msbuild.exe on your project or
solution file, you can orchestrate and build products in environments where Visual Studio isn't installed.
Visual Studio uses MSBuild to load and build managed projects. The project files in Visual Studio (.csproj,.vbproj,
vcxproj, and others) contain MSBuild XML code that executes when you build a project by using the IDE. Visual
Studio projects import all the necessary settings and build processes to do typical development work, but you can
extend or modify them from within Visual Studio or by using an XML editor.
For information about MSBuild for C++, see MSBuild (Visual C++).
The following examples illustrate when you might run builds by using an MSBuild command line instead of the
Visual Studio IDE.
Visual Studio isn't installed.
You want to use the 64-bit version of MSBuild. This version of MSBuild is usually unnecessary, but it allows
MSBuild to access more memory.
You want to run a build in multiple processes. However, you can use the IDE to achieve the same result on
projects in C++ and C#.
You want to modify the build system. For example, you might want to enable the following actions:
Preprocess files before they reach the compiler.
Copy the build outputs to a different place.
Create compressed files from build outputs.
Do a post-processing step. For example, you might want to stamp an assembly with a different
version.
You can write code in the Visual Studio IDE but run builds by using MSBuild. As another alternative, you can
build code in the IDE on a development computer but use an MSBuild command line to build code that's
integrated from multiple developers.

NOTE
You can use Team Foundation Build to automatically compile, test, and deploy your application. Your build system can
automatically run builds when developers check in code (for example, as part of a Continuous Integration strategy) or
according to a schedule (for example, a nightly Build Verification Test build). Team Foundation Build compiles your code by
using MSBuild. For more information, see Build the application.
This topic provides an overview of MSBuild. For an introductory tutorial, see Walkthrough: Using MSBuild.
In this topic
Using MSBuild at a Command Prompt
Project File
Properties
Items
Tasks
Targets
Build Logs
Using MSBuild in Visual Studio
Multitargeting

Using MSBuild at a Command Prompt


To run MSBuild at a command prompt, pass a project file to MSBuild.exe, together with the appropriate command-
line options. Command-line options let you set properties, execute specific targets, and set other options that
control the build process. For example, you would use the following command-line syntax to build the file
MyProj.proj with the Configuration property set to Debug .

MSBuild.exe MyProj.proj /property:Configuration=Debug

For more information about MSBuild command-line options, see Command-Line Reference.

IMPORTANT
Before you download a project, determine the trustworthiness of the code.

Project File
MSBuild uses an XML-based project file format that's straightforward and extensible. The MSBuild project file
format lets developers describe the items that are to be built, and also how they are to be built for different
operating systems and configurations. In addition, the project file format lets developers author reusable build
rules that can be factored into separate files so that builds can be performed consistently across different projects
in the product.
The following sections describe some of the basic elements of the MSBuild project file format. For a tutorial about
how to create a basic project file, see Walkthrough: Creating an MSBuild Project File from Scratch.
Properties
Properties represent key/value pairs that can be used to configure builds. Properties are declared by creating an
element that has the name of the property as a child of a PropertyGroup element. For example, the following code
creates a property named BuildDir that has a value of Build .

<PropertyGroup>
<BuildDir>Build</BuildDir>
</PropertyGroup>
You can define a property conditionally by placing a Condition attribute in the element. The contents of
conditional elements are ignored unless the condition evaluates to true . In the following example, the
Configuration element is defined if it hasn't yet been defined.

<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

Properties can be referenced throughout the project file by using the syntax $(PropertyName). For example, you
can reference the properties in the previous examples by using $(BuildDir) and $(Configuration) .
For more information about properties, see MSBuild Properties.
Items
Items are inputs into the build system and typically represent files. Items are grouped into item types, based on
user-defined item names. These item types can be used as parameters for tasks, which use the individual items to
perform the steps of the build process.
Items are declared in the project file by creating an element that has the name of the item type as a child of an
ItemGroup element. For example, the following code creates an item type named Compile , which includes two
files.

<ItemGroup>
<Compile Include = "file1.cs"/>
<Compile Include = "file2.cs"/>
</ItemGroup>

Item types can be referenced throughout the project file by using the syntax @(ItemType). For example, the item
type in the example would be referenced by using @(Compile) .
In MSBuild, element and attribute names are case-sensitive. However, property, item, and metadata names are not.
The following example creates the item type Compile , comPile , or any other case variation, and gives the item
type the value "one.cs;two.cs".

<ItemGroup>
<Compile Include="one.cs" />
<comPile Include="two.cs" />
</ItemGroup>

Items can be declared by using wildcard characters and may contain additional metadata for more advanced build
scenarios. For more information about items, see Items.
Tasks
Tasks are units of executable code that MSBuild projects use to perform build operations. For example, a task might
compile input files or run an external tool. Tasks can be reused, and they can be shared by different developers in
different projects.
The execution logic of a task is written in managed code and mapped to MSBuild by using the UsingTask element.
You can write your own task by authoring a managed type that implements the ITask interface. For more
information about how to write tasks, see Task Writing.
MSBuild includes common tasks that you can modify to suit your requirements. Examples are Copy, which copies
files, MakeDir, which creates directories, and Csc, which compiles Visual C# source code files. For a list of available
tasks together with usage information, see Task Reference.
A task is executed in an MSBuild project file by creating an element that has the name of the task as a child of a
Target element. Tasks typically accept parameters, which are passed as attributes of the element. Both MSBuild
properties and items can be used as parameters. For example, the following code calls the MakeDir task and passes
it the value of the BuildDir property that was declared in the earlier example.

<Target Name="MakeBuildDirectory">
<MakeDir Directories="$(BuildDir)" />
</Target>

For more information about tasks, see Tasks.


Targets
Targets group tasks together in a particular order and expose sections of the project file as entry points into the
build process. Targets are often grouped into logical sections to increase readability and to allow for expansion.
Breaking the build steps into targets lets you call one piece of the build process from other targets without copying
that section of code into every target. For example, if several entry points into the build process require references
to be built, you can create a target that builds references and then run that target from every entry point where it's
required.
Targets are declared in the project file by using the Target element. For example, the following code creates a target
named Compile , which then calls the Csc task that has the item list that was declared in the earlier example.

<Target Name="Compile">
<Csc Sources="@(Compile)" />
</Target>

In more advanced scenarios, targets can be used to describe relationships among one another and perform
dependency analysis so that whole sections of the build process can be skipped if that target is up-to-date. For
more information about targets, see Targets.

Build Logs
You can log build errors, warnings, and messages to the console or another output device. For more information,
see Obtaining Build Logs and Logging in MSBuild.

Using MSBuild in Visual Studio


Visual Studio uses the MSBuild project file format to store build information about managed projects. Project
settings that are added or changed by using the Visual Studio interface are reflected in the .*proj file that's
generated for every project. Visual Studio uses a hosted instance of MSBuild to build managed projects. This means
that a managed project can be built in Visual Studio or at a command prompt (even if Visual Studio isn't installed),
and the results will be identical.
For a tutorial about how to use MSBuild in Visual Studio, see Walkthrough: Using MSBuild.

Multitargeting
By using Visual Studio, you can compile an application to run on any one of several versions of the .NET
Framework. For example, you can compile an application to run on the .NET Framework 2.0 on a 32-bit platform,
and you can compile the same application to run on the .NET Framework 4.5 on a 64-bit platform. The ability to
compile to more than one framework is named multitargeting.
These are some of the benefits of multitargeting:
You can develop applications that target earlier versions of the .NET Framework, for example, versions 2.0,
3.0, and 3.5.
You can target frameworks other than the .NET Framework, for example, Silverlight.
You can target a framework profile, which is a predefined subset of a target framework.
If a service pack for the current version of the .NET Framework is released, you could target it.
Multitargeting guarantees that an application uses only the functionality that's available in the target
framework and platform.
For more information, see Multitargeting.

Related Topics
T IT L E DESC RIP T IO N

Walkthrough: Creating an MSBuild Project File from Scratch Shows how to create a basic project file incrementally, by using
only a text editor.

Walkthrough: Using MSBuild Introduces the building blocks of MSBuild and shows how to
write, manipulate, and debug MSBuild projects without closing
the Visual Studio IDE.

MSBuild Concepts Presents the four building blocks of MSBuild: properties,


items, targets, and tasks.

Items Describes the general concepts behind the MSBuild file format
and how the pieces fit together.

MSBuild Properties Introduces properties and property collections. Properties are


key/value pairs that can be used to configure builds.

Targets Explains how to group tasks together in a particular order and


enable sections of the build process to be called on the
command line.

Tasks Shows how to create a unit of executable code that can be


used by MSBuild to perform atomic build operations.

Conditions Discusses how to use the Condition attribute in an MSBuild


element.

Advanced Concepts Presents batching, performing transforms, multitargeting, and


other advanced techniques.

Logging in MSBuild Describes how to log build events, messages, and errors.

Additional Resources Lists community and support resources for more information
about MSBuild.

Reference
MSBuild Reference
Links to topics that contain reference information.
Glossary
Defines common MSBuild terms.
Resources for Troubleshooting Integrated
Development Environment Errors
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Not all error messages have a specific associated Help topic. If the information in the error message does not help
you resolve the problem, you can consult other resources such as Knowledge Base articles, the developer
community, or product support.

Knowledge Base Articles


You can search the Knowledge Base (KB) online for articles about product issues. Not all issues have a
corresponding KB article, but errors encountered by a significant number of customers are typically documented.
You can access KB articles on the Microsoft Support Web site.

The Developer Community


Forums let you interact with other developers, and also Microsoft employees. If you encounter an error that you
cannot find a resolution for, you can post questions about the issue on a forum. You can also search the
newsgroups to see whether others have posted about the same issue.
You can access forums, blogs, chats, and other resources on the Microsoft Technical Communities Web site.

Product Support
If you still have questions after you try the other resources, you can contact Microsoft support services by visiting
the Microsoft Support Web site. For information about product support available in your area, see Talk to Us.
Accessibility for People with Disabilities
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Microsoft is committed to making its products and services easier for everyone to use. The following topics provide
information about the features, products, and services that make Microsoft Visual Studio more accessible for
people with disabilities.
Accessibility Features of Visual Studio
Accessibility Features of the Help Viewer
Accessibility Features of Visual Studio
11/21/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

In addition to accessibility features and utilities in Windows, the following features make Visual Studio 2013 more
accessible for people with disabilities:
Toolbar button and text enlargement
Text size options in the editors
Color customization in the editors
Keyboard shortcut customization
Auto-completion for methods and parameters

IMPORTANT
The information in this section applies only to users who license Microsoft products in the United States. If you obtained this
product outside of the United States, you can use the subsidiary-information card that came with your software package, or
you can visit the Contact Us page for Microsoft Support and click the Locate Microsoft Offices Worldwide link (near
the bottom of the page). This page provides a list of telephone numbers and addresses for Microsoft support services. You
can contact your subsidiary to find out whether the types of products and services that are described in this section are
available in your area. Information about accessibility is available in other languages, including Japanese and French.

For more information, see the following topics:


How to: Set IDE Accessibility Options
How to: Use the Keyboard Exclusively
Default Keyboard Shortcuts
Accessibility Tips and Tricks
How to: Change Fonts and Colors

See Also
Accessibility Products and Services from Microsoft
How to: Set IDE Accessibility Options
10/18/2019 • 4 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Visual Studio contains features that make it easier for people who have low vision to read and for people who have
limited dexterity to write. These features include changing the size and color of text in editors, changing the size of
text and buttons on toolbars, and auto-completion for methods and parameters, to name a few.
In addition, Visual Studio supports Dvorak keyboard layouts, which make the most frequently typed characters
more accessible. You can also customize the default shortcut keys available with Visual Studio. For more
information, see Identifying and Customizing Keyboard Shortcuts.

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

Editors, Dialogs, and Tool Windows


By default, dialog boxes and tool windows in Visual Studio use the same font size and colors as the operating
system. The color settings for the frame of the IDE, dialog boxes, toolbars, and tool windows are based a color
scheme: light or dark. You can change the current color theme in the General, Environment, Options Dialog Box.
You can also display pop-up windows in the Code view of the editor. These windows can prompt you with available
members on the current object and the parameters to complete a function or statement. These windows can be
helpful if you have difficulty typing. However, they interfere with focus in the code editor, which can be problematic
for some users. You can turn off these windows by opening the Options dialog box and clearing Auto list
members and Parameter information in the Text Editor , All Languages , General page in the Options dialog
box. For more information, see How to: Set General Editor Options.
You can rearrange the windows in the integrated development environment (IDE) to best suit the way you work.
You can dock, float, hide, or automatically hide each tool window.
For more information about how to change window layouts, see Customizing window layouts.
Changing the Size of Text
You can change the settings for text-based tool windows, such as the Command window, Immediate window,
and Output window, in the Fonts and Colors pane of the Environment options in the Tools dialog box. When
[All Text Tool Windows] is selected in the Show settings for drop-down list, the default setting is listed as
Default in the Item foreground and Item background drop-down lists. You can also change the settings for
how text is displayed in the editor.
To c h a n g e t h e si z e o f t e x t i n t e x t - b a se d t o o l w i n d o w s a n d e d i t o r s

1. From the Tools menu, choose Options .


2. Choose Fonts and Colors on the Environment folder.
3. Select an option on the Show settings for drop-down menu.
To change the font size for text in an editor, choose Text Editor .
To change the font size for text in text-based tool windows, choose [All Text Tool Windows] .
To change the font size for ToolTip text in an editor, choose Editor Tooltip .
To change the font size for text in statement completion pop-ups, choose Statement Completion .
4. From Display items , select Plain Text .
5. In Font , select a new font type.
6. In Size , select a new font size.

NOTE
To reset the text size for text-based tool windows and editors, choose Use Defaults .

7. Choose OK .
Changing the Colors used in the IDE
You can also choose to change the default colors for text, margin indicators, white space, and code elements in the
editor.

NOTE
To use high contrast colors for all application windows on your operating system, press Left ALT+ Left SHIFT+PRINT
SCREEN. If Visual Studio is open, close and reopen Visual Studio to fully implement high contrast colors.

To c h a n g e t h e c o l o r o f i t e m s i n t h e e d i t o r

1. From the Tools menu, choose Options .


2. Choose Fonts and Colors from the Environment folder.
3. In Show settings for , choose Text Editor .
4. From Display items , select an item whose display you need to change, such as Plain Text , Indicator
Margin , Visible White Space , HTML Attribute Name , or XML Attribute .
5. Select display settings from the following options: Item foreground , Item background , and Bold .
6. Choose OK .

Toolbars
To improve toolbar usability and accessibility, you can add text to toolbar buttons.
To assign text to toolbar buttons
1. From the Tools menu, choose Customize .
2. In the Customize dialog box, select the Commands tab.
3. Select Toolbar and then choose the toolbar name that contains the button you intend to display text for.
4. In the list, select the command you intend to change.
5. Choose Modify Selection .
6. Choose Image and Text .
To modify the button's displayed text
1. Re-select Modify Selection .
2. Adjacent to In Name , insert provide a new caption for the selected button.

See Also
Accessibility Features of Visual Studio Resources for Designing Accessible Applications
How to: Use the Keyboard Exclusively
1/10/2020 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Visual Studio provides many default shortcut key combinations to make it easy to navigate and code within the
integrated development environment (IDE). For a full listing of shortcut keys used in Visual Studio, see Default
Keyboard Shortcuts. For information on keyboard shortcuts available for other Microsoft products, see
http://www.microsoft.com/enable/products/keyboard.aspx.

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

Toolbox Controls
You can add a control on the Toolbox to a form or designer using the keyboard.
To add controls from the Toolbox to a designer from the keyboard
1. On the menu bar, choose View , Toolbox .
2. Choose the Ctrl + Up Arrow or Ctrl + Down Arrow keys to move among the sections in the current Toolbox
tab.
3. Choose the Up Arrow or Down Arrow keys to move among the controls.
4. After the control is selected, choose the Enter key.
The control is added to the form or designer.

Dialog Box Options


You can move among the options in a dialog and change option settings using the keyboard.
To set dialog box options from the keyboard
1. Use TAB or SHIFT + TAB to move up and down through the controls in the dialog box.
2. To change option settings:
For radio buttons, use UP ARROW and DOWN ARROW to change the selection.
For check boxes, use SPACEBAR to select or unselect.
For drop-down lists, use ALT + DOWNARROW to display items and then use UPARROW and
DOWNARROW to change the selected item.
For buttons, press ENTER to invoke.
For grids, use the Arrow keys to navigate. For drop-down lists in grids, use SHIFT + ALT +
DOWNARROW to display items and then use UPARROW and DOWNARROW to change the
selected item.

Window and File Navigation


The IDE provides several ways for you to move among open tool and document windows using the keyboard. You
can also move and dock tool windows in different locations using the keyboard.
To navigate among windows and files in the IDE from the keyboard
To move among files in an editor or designer, choose CTRL + TAB keys to display the IDE Navigator with
Active Files selected. Choose the Enter key to navigate to the highlighted file.
To move among docked tool windows, choose Alt + F7 to display the IDE Navigator with Active Tool
Windows selected. Choose the Enter keyto navigate to the highlighted window.
To move and dock tool windows from the keyboard
1. Navigate to the tool window you intend to move and give it focus.
2. On the Window menu, click Dockable .
3. Press ALT + Space and then choose Move .
The docking guide diamond appears.
4. Use the ARROW keys to move the window to a new location.
The mouse pointer moves with the window as you use the ARROW keys.
5. When you have reached the new location, use the ARROW keys to move the mouse pointer over the correct
portion of the guide diamond.
An outline of the tool window appears in the new docking location.
6. Press ENTER .
The tool window snaps into place at the new docking location.

See Also
Identifying and Customizing Keyboard Shortcuts Accessibility Tips and Tricks Default Keyboard Shortcuts
Accessibility Tips and Tricks
10/18/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version
selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Visual Studio includes built-in accessibility features so you can easily work from the keyboard and use screen
readers or other assistive technology devices. The topic includes some suggestions for optimizing Visual Studio for
accessibility as well as some useful shortcut key combinations.

NOTE
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings
or edition. To change your settings, choose Impor t and Expor t Settings on the Tools menu. For more information, see
Customizing Development Settings in Visual Studio.

Save Your IDE Settings


You can customize your IDE experience by saving your window layout, keyboard mapping scheme, and other
preferences. For more information, see Customizing Development Settings in Visual Studio.

Common Windows Shortcut Key Combinations


You can use many of the standard Windows shortcut key combinations to perform tasks within Visual Studio.
Some of these shortcut key combinations include:

DESC RIP T IO N K EY C O M B IN AT IO N

Switch High Contrast on and off Left ALT + Left SHIFT + PRINT SCREEN

Select or clear the check box option in a dialog box SPACEBAR

Display the properties of the selected item. For example, puts ALT+ENTER
focus in the Properties Window if a form is selected or Opens
the Property Page dialog box if a project is selected.

Display the items in the active list, such as a drop-down list, in ALT + DOWN ARROW
a dialog box

Display items in an active drop-down list in a grid SHIFT + ALT + DOWN ARROW

Hidden Visual Studio Shortcut Key Combinations


Some features have shortcut keys available that do not appear in the Options dialog box on the
Environment\Keyboard pane. These shortcut key combinations include the following:
F EAT URE DESC RIP T IO N K EY C O M B IN AT IO N

Toolbox window Move among Toolbox tabs CTRL + UPARROW

and

CTRL + DOWNARROW

Toolbox window Add a control from the Toolbox to a ENTER


form or designer

Keyboard, Environment, Options dialog Delete a key combination entered in BACKSPACE


box the Press shor tcut keys option

All tool windows Select the first button on the toolbar of SHIFT + ALT
the window

IDE toolbars Select the first button on the Standard ALT , CTRL + TAB Note: Press CTRL +
toolbar TAB again to select the first button on
the next IDE toolbar.

See Also
Accessibility Features of Visual Studio
Accessibility Products and Services from Microsoft
1/10/2020 • 3 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Microsoft is committed to making its products and services easier for everyone to use. The following topics
provide information about the features, products, and services that make Microsoft Windows more accessible for
people with disabilities:
Accessibility Features of Windows
Documentation in Alternative Formats
Customer Service for People with Hearing Impairments
For More Information

NOTE
The information in this section may apply only to users who license Microsoft products in the United States. If you obtained
this product outside of the United States, you can use the subsidiary information card that came with your software package
or visit the Microsoft Accessibility Web site for a list of Microsoft support services telephone numbers and addresses. You can
contact your subsidiary to find out whether the type of products and services described in this section are available in your
area. Information about accessibility is available in other languages, including Japanese and French.

Accessibility Features of Windows


The Windows operating system has many built-in accessibility features that are useful for individuals who have
difficulty typing or using a mouse, are blind or have low vision, or who are deaf or hard-of-hearing. The features
are installed during Setup. For more information about these features, see Help in Windows and the Microsoft
Accessibility Web site.
Free Step-by-Step Tutorials
Microsoft offers a series of step-by-step tutorials that provide detailed procedures for adjusting the accessibility
options and settings on your computer. This information is presented in a side-by-side format so that you can learn
how to use the mouse, the keyboard, or a combination of both.
To find step-by-step tutorials for Microsoft products, see the Microsoft Accessibility Web site.
Assistive Technology Products for Windows
A wide variety of assistive technology products are available to make computers easier to use for people with
disabilities. You can search a catalog of assistive technology products that run on Windows at the Microsoft
Accessibility Web site.
If you use assistive technology, be sure to contact your assistive technology vendor before you upgrade your
software or hardware to check for possible compatibility issues.
Documentation in Alternative Formats
If you have difficulty reading or handling printed materials, you can obtain the documentation for many Microsoft
products in more accessible formats. You can view an index of accessible product documentation on the Microsoft
Accessibility Web site.
In addition, you can obtain additional Microsoft publications from Recording for the Blind & Dyslexic, Inc (RFB&D).
RFB&D distributes these documents to registered, eligible members of their distribution service. For information
about the availability of Microsoft product documentation and books from Microsoft Press, contact:

L EA RN IN G A L LY

20 Roszel Road

Princeton, NJ 08540

Learning Ally website: http://www.learningally.org.

Web addresses can change, so you might be unable to connect to the website or sites mentioned here.

Customer Service for People with Hearing Impairments


If you are deaf or hard-of-hearing, complete access to Microsoft product and customer services is available
through a text telephone (TTY/TDD) service:
For customer service, contact Microsoft Sales Information Center at (800) 892-5234 between 6:30 AM and
5:30 PM Pacific Time, Monday through Friday, excluding holidays.
For technical assistance in the United States, contact Microsoft Product Support Services at (800) 892-5234
between 6:00 AM and 6:00 PM Pacific Time, Monday through Friday, excluding holidays. In Canada, dial
(905) 568-9641 between 8:00 AM and 8:00 PM Eastern Time, Monday through Friday, excluding holidays.
Microsoft Support Services are subject to the prices, terms, and conditions in place at the time the service is
used.

For More Information


For more information about how accessible technology for computers helps to improve the lives of people with
disabilities, see the Microsoft Accessibility Web site.

See Also
Resources for Designing Accessible Applications Accessibility Features of Visual Studio
Resources for Designing Accessible Applications
11/21/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

Use the following links to find information about technologies that support accessible design as well as tips and
examples for developing accessible Windows applications and Web sites. General information on accessibility can
be found online at http://www.microsoft.com/enable/.

Technologies
Microsoft Active Accessibility A COM-based technology that improves the way accessibility aids work
with applications running on Microsoft Windows. It provides dynamic-link libraries that are incorporated
into the operating system as well as a COM interface and application programming elements that provide
reliable methods for exposing information about user interface elements. For more information, see
https://msdn.microsoft.com/library/windows/desktop/dd373592(v=vs.85).aspx.
Microsoft .NET Speech Technologies The Microsoft .NET Speech SDK is a set of Microsoft ASP.NET
controls, a Microsoft Internet Explorer Speech add-in, sample applications and documentation that allows
Web developers to create, debug and deploy speech-enabled ASP.NET applications. The tools are integrated
seamlessly into Microsoft Visual Studio, allowing developers to leverage the familiar development
environment. For more information, see https://msdn.microsoft.com/library/ms950383.aspx.
Understanding SAMI 1.0 Microsoft Synchronized Accessible Media Interchange (SAMI) technology
provides a way for developers to caption audio content for PC multimedia. For more information, see
https://msdn.microsoft.com/library/ms971327.aspx.

Windows Applications
Walkthrough: Creating an Accessible Windows-based Application This topic provides step-by-step
instructions for including the five accessibility requirements for the Certified for Windows logo in a sample
Windows application.
Guidelines for Keyboard User Interface Design This technical article describes how design a Windows
application user interface that users can navigate from the keyboard.
Console Accessibility This technical article describes the APIs and events used to expose the console in
Windows XP for accessibility aids.

Web Sites
Walkthrough: Accessibility Guidelines for Using Image Controls, Menu Controls, and AutoPostBack This
topic provides step-by-step instructions for including accessible controls in a sample Web page as well as
some accessibility design tips for the Web.
Making Web Pages More Accessible This technical article lists HTML 3.2 elements that are accessible as well
as elements that can be made accessible for use in Web site development.
Creating Accessible Web Pages with DHTML This technical article lists HTML 4.0 elements that are accessible
as well as accessible Web design tips.
Text Alternatives to Inaccessible Web Pages This technical article describes how to use XML and XSLT to
provide multiple views of the same Web page, such as text only versions.
Third-party Resources
Web Accessibility Initiative of the World Wide Web Consor tium (W3C) This Web site provides
guidelines and techniques for accessible Web site development. For more information, see
http://www.w3.org/WAI/GL/.

See Also
Accessibility Features of Visual Studio
Proxy Authorization Required
11/21/2019 • 2 minutes to read

NOTE
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector
at the top left. We recommend upgrading to Visual Studio 2019. Download it here

The Proxy authorization required error generally occurs when users are connected to Visual Studio online
resources through a proxy server, and the proxy server blocks the calls.
To correct this error, try one or more of the following steps:
Restart Visual Studio. A proxy authentication dialog box should appear. Enter your credentials in the dialog.
If the above step does not solve the problem, this may be because your proxy server does not prompt for
credentials for https://go.microsoft.com addresses but does so for *.visualStudio.com addresses. For these
servers, you need to add the following URLs to the allow list to unblock all sign-in scenarios in Visual Studio:
*.windows.net
*.microsoftonline.com
*.visualstudio.com
*.microsoft.com
*.live.com
You can remove the https://go.microsoft.com address from the allow list so that the proxy authentication
dialog shows up for both the https://go.microsoft.com address and the server endpoints when Visual Studio
is restarted.
If you want to use your default credentials with your proxy, do the following:
1. Find devenv.exe.config (the devenv.exe configuration file) in: %ProgramFiles%\Microsoft Visual
Studio 14.0\Common7\IDE (or %ProgramFiles(x86)%\Microsoft Visual Studio
14.0\Common7\IDE ).
2. In the configuration file, find the <system.net> block, and add this code:

<defaultProxy enabled="true" useDefaultCredentials="true">


<proxy bypassonlocal="True" proxyaddress=" HYPERLINK "http://<yourproxy:port#"
http://<yourproxy:port#>"/>
</defaultProxy>

Insert the correct proxy address for your network in proxyaddress="<http://<yourproxy:port#> .


Follow the instructions in this blog post to add code that allows you to use the proxy.

You might also like