Inside Microsoft® Visual Studio® .NET 2003 [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Inside Microsoft® Visual Studio® .NET 2003 [Electronic resources] - نسخه متنی

Brian Johnson

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید










Overview of Solutions and Projects


Managing complex software projects can be a difficult and messy affair. Visual Studio .NET helps by organizing programming projects along the lines of solution (groups of projects) and projects and by handling references to assemblies and to components outside this structure. This organization and reference feature helps promote code reuse by allowing you to take advantage of related projects, existing assemblies, COM components, and source code. The easiest way to reuse .NET code is through references to assemblies in your projects and solutions.

Important

Visual Studio .NET organizes software projects on two conceptual levels. Solutions contain projects and solution items. Projects contain the source files that are compiled into executables and assemblies.

The most important tool for project management in Visual Studio .NET is Solution Explorer (Ctrl+Alt+L), shown in Figure 2-1. Solution Explorer is a tree-view window that provides access to all the projects and files that are part of the currently open solution. Visual Studio .NET can host one solution at a time, but you can run multiple instances of Visual Studio if you want to work with multiple solutions concurrently.


Figure 2-1. Solutions act as containers for projects and solution items.



Most new projects in Visual Studio .NET are created using a template developed by a language integrator. For example, Visual Studio .NET 2003 ships with support for Microsoft Visual Basic .NET, Visual C#, Visual J#, and Visual C++ .NET. Each of these languages features a number of project types that programmers can choose from when creating a new project. A new project is created as part of a new solution by default. You can also add projects to existing solutions.

For Windows Forms applications and unmanaged Windows-based applications, the solution file for a project is by default stored in the same folder as the project. For Web Forms applications, solution files are typically stored in a folder in the Visual Studio Projects folder in your My Documents folder and point to the Web server that's hosting the application.

A single project can be a member of many different solutions. Because it's so easy to reorganize your projects in Visual Studio .NET, you should feel free to create your initial projects with default solutions. Later on, you can move your projects around and add them to new solutions if you want.


Lab: Playing with Solutions


The best way to get comfortable with solutions and projects is to spend some time playing with them. Let's say you're writing a book (like this one!). You've got a bunch of samples, and you want to make it easy for the reader to see all the samples from a single chapter in a single solution.

To get started, create a new folder named Chapter02. This folder will hold the various project folders in the solution. Next, create a Visual C# Windows Application project and call the new project Sample01.csproj. Save the project, and name the solution Sample01.sln. Save the solution in the same folder as the project, Sample01.

With the solution file selected in Solution Explorer, choose Save Sample01.sln As from the File menu to save the file to the Chapter02 folder, naming it Chapter02.sln.

At this point, you've got two solutions: one in the Chapter02 folder and one in the Sample01 folder. The Chapter02.sln file is the one that's currently open. Let's add another project to the solution. Press Ctrl+Alt+A, and enter File.AddNewProject in the Command Window. This should bring up the Add New Project dialog box. Create a C# Windows application, and name it Sample02. You now have a solution file named Chapter02 and two projects. Close the Chapter02 solution file and click Yes if you're prompted to save.

If you go into the new folder created for Sample02, you'll notice that there's no solution file for that project. No problemjust open the Sample02.csproj file. You can work on that project alone and save a new solution file in the Sample02 folder if you want. You can close that project and go to the Chapter02 folder; again, you'll see the two projects. As you can see, a project can be a member of a number of different solutions. This is an important concept to understand as you plan team development projects. As you explore the solution concept further, you'll also see that it can be an integral part of code reuse in Visual Studio .NET.


/ 118