We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

Controlling the Solution and Its Projects

One solution can be open in Visual Studio at any given time. If it is not an empty solution, it contains one or more projects. The projects can be of various types written in any of the Visual Studio languages. For example, a solution might contain a Visual Basic Windows application project and a Visual C++ ATL project. Each project, in turn, contains one or more project items, such as interfaces, classes, modules, forms, user controls, XML schema files, and so forth.

The Visual Studio automation model offers objects to programmatically create and manipulate all of these elements. The key object for controlling a solution and its contents is the Solution2 object. Using it, you can:

  • Create new solutions.

  • Add new projects to the solution, based on Visual Studio templates.

  • Add existing projects to the solution from files.

  • Remove projects from the solution.

  • Open, save, and close the solution.

  • Add new project items to projects.

  • Obtain information about the solution and the projects and project items it contains.

In addition to this set of language-agnostic project types, each Visual Studio language offers its own more specific project object model, which is specific to its host language. For example, there is a project-specific automation model for Visual Basic and Visual C#, contained in VSLangProj, VSLangProj2, VSLangProj80, VslangProj90, and VslangProj100. The project-specific automation model for Visual C++ is contained in Microsoft.VisualStudio.VCProject and Microsoft.VisualStudio.VCProjectEngine.

Generic vs. Language-Specific Project Models

Describes the differences between the generic and programming language-specific project models.

How to: Programmatically Create Projects

Describes how to create projects.

How to: Programmatically Create Project Items

Describes how to create project items.

Automation Object Model Chart

Provides a graphical roadmap to all shared components of the Automation Object Model.