Projects and Solutions

A typical .NET application is comprised of many items: source files, assembly information files, references, icons, and other files and folders. Visual Studio .NET organizes these items into a container called a project. One or more projects are contained within a solution. When you create a new project, Visual Studio .NET automatically creates the containing solution.

3.3.1 Solutions

Solutions typically contain one or more project. They may contain other independent items as well. These independent solution items are not specific to any particular project, but apply, or scope, to the entire solution. The solution items are not an integral part of the application, in that they can be removed without changing the compiled output. You can manage them with source control.

It is also possible to have a solution that does not contain any projectsjust solution or miscellaneous files that can be edited using Visual Studio .NET.

Miscellaneous files are independent of the solution or project, but they may be useful. They are not included in a build or compile, but will display in the Solution Explorer (described below) and may be edited there. Typical miscellaneous files include project notes, database schemas, or sample code files.

Solutions are defined within a file named for the solution and have the extension.sln. The .sln file contains a list of the projects that comprise the solution, the location of any solution-scoped items, and solution-scoped build configurations. Visual Studio .NET also creates a .suo file with the same name as the .sln file (e.g., mySolution.sln and mySolution.suo). The .sou file contains data used to customize the IDE on a per-user and per-solution basis.

You can open a solution by double-clicking the .sln file in Windows Explorer. If the .sln file is missing, then recreate that solution from scratch by adding projects into the solution. On the other hand, if the .suo file is missing, it will be recreated automatically the next time the solution is opened.

3.3.2 Projects

A project contains source files and other content. Typically, the build process results in the contents of a project being compiled into an assemblye.g., an executable file (EXE) or a dynamic link library (DLL).

The data describing the project is contained in a project file named after the project name with a language-specific extension. For VB.NET and C#, the extensions are .vbproj and .csproj, respectively. The project file contains version information, build settings, references to other assemblies (typically members of the CLR, but also custom developed and third-party components), and source files to include as part of the project.

3.3.2.1 Templates

When you create a new project by clicking the New Project button on the Start Page (shown in Figure 3-1), you get the New Project dialog box, shown in Figure 3-2.

Figure 3-2. New Project dialog box

figs/pnwa_0302.gif

Select the Project Type and the Template. You will find several templates for each project type. For example, the templates for Visual C# Projects, shown in Figure 3-2, are different from the templates available to Setup and Deployment Projects. By selecting a Visual Studio Solutions project type, you can create an empty solution that is ready to receive whatever items you wish to add.

The template controls what items will be automatically created and included in the project, as well as default project settings. For example, if the project is a C# Windows application, such as the Hello World programs created in Chapter 2, then language-specific .csproj, .csprojusers, and .cs files will be created as part of the project. If the project were a VB.NET project, then the corresponding .vbproj, .vbprojusers, and .vb files would be created instead. If a different template were selected, then an entirely different set of files would be created.

3.3.2.2 Project names

Project names may consist of any standard ASCII characters, except for those shown in Table 3-1.

Table 3-1. Forbidden project name characters

Project name

Ascii character

Pound

#

Percent

%

Ampersand

&

Asterisk

*

Vertical bar

|

Backslash

Colon

:

Double quotation mark

"

Less than

<

Greater than

>

Question mark

?

Forward slash

/

Leading or trailing spaces

 

Windows or DOS keywords, such as "nul", "aux", "con", "com1", and "lpt1"

 

Windows Forms and the .NET Framework

Getting Started

Visual Studio .NET

Events

Windows Forms

Dialog Boxes

Controls: The Base Class

Mouse Interaction

Text and Fonts

Drawing and GDI+

Labels and Buttons

Text Controls

Other Basic Controls

TreeView and ListView

List Controls

Date and Time Controls

Custom Controls

Menus and Bars

ADO.NET

Updating ADO.NET

Exceptions and Debugging

Configuration and Deployment



Programming. NET Windows Applications
Programming .Net Windows Applications
ISBN: 0596003218
EAN: 2147483647
Year: 2003
Pages: 148

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net