2.3. Projects and SolutionsA 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 . Figure 2-1. Visual Studio start pageVisual 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.
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.
2.3.1. Web SitesYou can create many types of projects in Visual Studio 2005, including:
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. 2.3.2. TemplatesWhen you create a new project, you get the New Project dialog box, shown in Figure 2-2. Figure 2-2. New Project dialogIn 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.
|