Projects and Solutions

Projects and Solutions

A C# program is built from source files, which are text files containing the code you write. Source code files are named with the .cs extension. The HelloWorld.cs file you created in Chapter 1 is an example.

A typical Visual Studio 2005 application can have a number of other files (such as assembly information files, references, icons, data connections, and more). Visual Studio 2005 organizes these files into a container called a project.

Visual Studio start page

Visual Studio 2005 provides two types of containers for your source code, folders, files, and related material: the project and the solution. A project is a set of files that work together to create an executable program (.exe) or a dynamic link library (.dll). Large, complex projects may contain multiple .dll files.

A solution is a set of related projects, although it may also have just one project. Each time you create a new project, Visual Studio 2005 either adds it to an existing solution or creates a new solution.

Solutions are defined within a file named for the solution, and have the extension .sln. The .sln file contains metadata, which is basically information about the data. The metadata describes the projects that compose the solution and information about building the solution.

Visual Studio 2005 also creates a file with the same base name as the .sln file, but with the filename extension .sou (such as mySolution.sln and mySolution.sou). The .sou file contains metadata used to customize the IDE.

There are a number of ways to open an existing solution. The simplest way is to select Open Project from the Start menu (which opens a project and its enclosing solution). Alternatively, you can open a solution in Visual Studio 2005 just by double-clicking the .sln file in Windows Explorer.

Typically, the build process results in the contents of a project being compiled into an executable (.exe) file or a dynamic link library (.dll) file. This book focuses on creating executable files.

The metadata describing the project is contained in a separate file named after the project with the extension .csproj. The project file contains version information, build settings, and references to other source files to include as part of the project.

Note that the metadata for the program you are creating is a different thing entirely, and is contained within the executable (.exe) or the DLL. What we are discussing here is metadata used by Visual Studio.

Web Sites

You can create many types of projects in Visual Studio 2005, including:

  • Console Application

  • Windows Application

  • Windows Service

  • Windows Control Libray

  • Web Control Library

  • Class Library

  • Pocket PC templates

  • SmartPhone templates

  • Windows CE templates

  • Crystal Reports Windows Application

  • SQL Server Project

  • Word and Excel Document and Template

  • Screen Saver

Web applications are notable in their absence from the list of projects you can create. Web applications do not use projects, just solutions.

A typical .NET web application is comprised of many items: content files (such as .aspx files), source files (such as .cs files), assemblies (such as .exe and .dll files) and assembly information files, data sources (such as .mdb files), references, and icons, as well as miscellaneous other files and folders. Visual Studio 2005 organizes these items into a folder that represents the web site. The web site folder is housed in a solution. When you create a new web site, Visual Studio 2005 automatically creates the solution.


When you create a new project, you get the New Project dialog box, shown in Figure.

New Project dialog

In the New Project dialog, you select the project type (in the left-hand pane) and the template (in the right). There are a variety of templates for each project type. A template is a file that Visual Studio 2005 uses to set up the initial state of your project.

For the examples in this book, you'll always choose Visual C# for the project type, and in most cases, you'll choose Console Application as the template. Specify the name of the directory in which your project will be stored in the Location Box and name your project in the Name box.

Project names can contain any standard characters, except leading or trailing spaces, Windows or DOS keywords, and any of the following special characters: # % & * | \ : " < > ? /.

 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows