6.1. Solution Structure

Whenever you're working within Visual Studio, you will have a solution open. When you're editing an ad hoc file, this will be a temporary solution that you can elect to discard when you have completed your work. However, the solution enables you to manage the files that you're currently working with, so in most cases saving the solution means that you can return to what you were doing at a later date without having to locate and reopen the files on which you were working.

Solutions should be thought of as containers of related projects. The projects within a solution do not need to be of the same language or project type. For example, a single solution could contain an ASP.NET web application written in Visual Basic, a C# control library, and an IronRuby WPF application. The solution enables you to open all these projects together in the IDE and manage the build and deployment configuration for them as a whole.

The most common way to structure applications written within Visual Studio is to have a single solution containing a number of projects. Each project can then be made up of a series of both code files and folders. The main window in which you work with solutions and projects is the Solution Explorer, shown in Figure 6-1.

Figure 6.1. Figure 6-1

Within a project, folders are used to organize the source code, and have no application meaning associated with them (with the exception of web applications, which have folders whose names have specific meanings in this context). Some developers use folder names that correspond to the namespace to which a class belongs. For example, if class Person is found within a folder called DataClasses in a project called FirstProject, the fully qualified name of the class could be FirstProject.DataClasses.Person.

Solution folders are a useful means of organizing the projects in a large solution. They are visible only in the Solution Explorer — a physical folder is not created on the file system. Actions such as building or unloading can be performed easily on all projects in a solution folder. They can also be collapsed or hidden so that you can work more easily in the Solution Explorer. Hidden projects are still built when you build the solution. Because solution folders do not map to a physical folder, you can add, rename, or delete them at any time without causing invalid file references or source control issues.

Miscellaneous Files is a special solution folder that can be used to keep track of other files that have been opened in Visual Studio but are not part of any projects in the solution. The Miscellaneous Files solution folder is not visible by default. The settings to enable it can be found under Tools Options Environment Documents.

There is a common misconception that projects necessarily correspond to .NET assemblies. While this is mostly true, it is possible for multiple DLL files to represent a single .NET assembly. However, such an arrangement is not supported by Visual Studio 2008, so this book assumes that a project will correspond to an assembly.

In Visual Studio 2008, although the format for the solution file has not changed significantly, solution files are not backward-compatible with Visual Studio 2005. However, project files are fully forward- and backward-compatible between Visual Studio 2005 and Visual Studio 2008.

In addition to tracking which files are contained within an application, solution and project files can record other information, such as how a particular file should be compiled, its project settings and resources, and much more. Visual Studio 2008 includes a non-modal dialog for editing project properties, while solution properties still open in a separate window. As you might expect, the project properties are those pertaining only to the project in question, such as assembly information and references, whereas solution properties determine the overall build configurations for the application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.103.204