饭饭TXT > 学习管理 > 《Visual Studio 2010 高级编程(英文出书版)》作者:Nick Randolph/等【完结】 > [Visual.Studio.2010.高级编程].Professional.Visual.Studio.2010.txt

第 77 页

作者:Nick Randolph/等 当前章节:15379 字 更新时间:2026-6-18 14:51

solutions.

PreParinG the deVeloPMent enVironMent

One of the common complaints about previous versions of SharePoint has been the requirement to

use Windows Server for the local development environment. This is because SharePoint 2007 and

earlier could only run on a server operating system and you needed to have SharePoint running

locally to perform any debugging and integration testing.

Fortunately, this has been addressed in SharePoint 2010. In addition to Windows Server 2008,

you can install SharePoint on either Windows 7 or Windows Vista (Service Pack 1 or later).

Unfortunately, you will need some reasonably powerful hardware for your local development

machine. SharePoint 2010 requires a 64-bit operating system and a recommended 4GB of RAM for

SharePoint Foundation and 6GB to 8GB of RAM for SharePoint Server.

sharePoint serVer Versus sharePoint foundation

SharePoint 2010 comes in two editions: SharePoint Server and SharePoint

Foundation. SharePoint Foundation was called Windows SharePoint Services

(WSS) in previous versions and is the free version that is targeted at smaller

organizations or deployments. It includes support for Web Parts and web-based

applications, document management, and web collaboration functionality such as

blogs, wikis, calendars, and discussions.

SharePoint Server, on the other hand, is aimed at large enterprises and advanced

deployment scenarios. It has a cost for the server product itself as well as requiring

a client access license (CAL) for each user. SharePoint Server includes all the features

of SharePoint Foundation as well as providing multiple SharePoint sites, enhanced

navigation, indexed search, access to backend data, personalization, and Single Sign On.

installing the Prerequisites

SharePoint 2010 was in Beta at the time of writing, and as such, some of the

instructions may have changed in the fi nal release. If any important changes are

required, you will be able to fi nd corrections and updated instructions at www

.wrox.com . Just search for this book by the ISBN number 978-0-470 - 54865-3,

and look for Chapter 24 under errata.

The installation of SharePoint is quite straightforward if you are targeting Windows Server. The

setup ships with a Prerequisite Installer tool ( PrerequisiteInstaller.exe ), which checks and

installs the required prerequisites. However, at the time of writing with SharePoint 2010 Beta 2,

this tool does not run on Windows 7 or Windows Vista. If you are installing SharePoint 2010 onto

one of these client operating systems you must install and confi gure a large number of prerequisites

manually.

Regardless of which operating system you are using, you must fi rst install the WCF Hotfi x for

Microsoft Windows. You can download it from the following links:

For Windows V . ista or Windows Server 2008:

http://go.microsoft.com/fwlink/?linkID=160770

. For Windows 7 or Windows Server 2008 R2:

http://go.microsoft.com/fwlink/?LinkID=166231

The following instructions assume that your copy of SharePoint is in the form of

a self - extracting executable called SharePoint.exe for SharePoint Foundation

or OfficeServer.exe for SharePoint Server. If instead you are installing from a

CD/DVD of SharePoint you can skip the following step, because the contents and

folder structure on the disc will be the same as the extracted fi les.

It is recommended that unless you are building a solution that requires the advanced

features of SharePoint Server, you should take advantage of the lower system

requirements and install SharePoint Foundation on your development machine.

Since SharePoint Server is built on top of SharePoint Foundation, anything that can

run under SharePoint Foundation will also run under SharePoint Server.

Preparing the Development environment . 515

516

.

chaPter 24 ShArepoinT

Begin by creating a folder for the installation files, for example c:\SharePoint, and copy the

setup executable to this folder. Next, extract the installation files by running the following from a

command prompt (for SharePoint Foundation):

c:\SharePoint\SharePoint.exe /extract:c:\SharePoint

For SharePoint Server, replace SharePoint.exe with OfficeServer.exe.

If you are installing SharePoint on Windows Server you can now run the Prerequisite Installer

tool (PrerequisiteInstaller.exe) and then proceed to the next section (“Installing SharePoint

2010”). Otherwise, if you are targeting Windows Vista or Windows 7, you must manually install the

prerequisites as described in the remainder of this section.

The following prerequisites are required for Windows Vista only:

.

.NET Framework 3.5 SP1: If you have installed Visual Studio 2010 this will already be

installed. Available via professionalvisualstudio.com/link/1024A.

.

Windows PowerShell 2.0: Available via professionalvisualstudio.com/link/1024B.

.

Windows Installer 4.5 Redistributable: Available via professionalvisualstudio

.com/link/1024C.

The following prerequisites are required for Windows 7 and Windows Vista:

.

Microsoft FilterPack 2.0: This is shipped with the SharePoint installation files. Run the

installer package at c:\SharePoint\PrerequisiteInstallerFiles\FilterPack\

FilterPack.msi.

.

Microsoft Sync Framework: If you have installed Visual Studio 2010 this will already be

installed. Available via professionalvisualstudio.com/link/1024D.

.

SQL Server 2008 Native Client: If you have installed Visual Studio 2010 this will already

be installed. Available via professionalvisualstudio.com/link/1024E.

.

Windows Identity Foundation Runtime: Formerly known as codename “Geneva”

Framework. Available via professionalvisualstudio.com/link/1024F.

.

ADO.NET Data Services: Select the run time only. Available via professionalvisualstudio

.com/link/1024G.

.

Chart Controls: This is not required for SharePoint Foundation. Available via

professionalvisualstudio.com/link/1024H.

.

Microsoft ADOMD.NET: This is not required for SharePoint Foundation. Available via

professionalvisualstudio.com/link/1024I.

The final step is to enable all of the required Windows Features. Figure 24-1 lists the features that

must be enabled using the Programs and Features Control Panel item. You can also download

a batch script that will automatically enable these features from professionalvisualstudio

.com/link/1024J.

Preparing the Development environment .

517

fiGure 24-1

installing sharePoint 2010

Now that the prerequisites have been installed you

can install either SharePoint Foundation or SharePoint

Server. If you are installing on Windows Server you can

simply launch the installer, setup.exe. However, if you

are installing to Windows 7 or Windows Vista you will

see the error shown in Figure 24-2 if you try to run the

installer.

To remove this limitation, you will need to edit the

configuration file, config.xml, which is located in

the c:\SharePoint\files\Setup folder. Add the following line to the <configuration> tag:

<Setting Id=”AllowWindowsClientInstall” Value=”True”/>

Once you have saved the configuration file, run setup.exe. Follow the instructions on the installer

and select the Standalone installation (Install single server standalone using default settings). After

the installer has completed, you will be prompted to run the SharePoint Products Configuration

Wizard. Once the wizard has completed, the default SharePoint site will open in a new browser

window, as shown in Figure 24-3.

fiGure 24-2

518 .

chaPter 24 ShArepoinT

fiGure 24-3

exPlorinG sharePoint 2010

The first time you peak under the covers at SharePoint it can be somewhat overwhelming. One

reason for this is because so much of the terminology used by SharePoint is unfamiliar to web

developers, even those who know ASP.NET inside out. Before you begin developing a SharePoint

solution it’s helpful to understand the meaning of SharePoint components such as content types,

Features, event receivers, lists, workflows, and Web Parts.

The Server Explorer in Visual Studio 2010 has been enhanced to provide the ability to explore a

SharePoint site and browse through its components. To connect to a SharePoint site, or develop and

debug a SharePoint solution, you must run Visual Studio with administrator rights. Right-click the

Visual Studio 2010 shortcut and select Run as Administrator.

To always launch Visual Studio 2010 with administrator rights, right-click the

shortcut and select Properties, and then select the Compatibility tab and check

the Run This Program as an Administrator checkbox.

Open the Server Explorer by selecting View . Server Explorer. You can only connect to SharePoint

if you have installed SharePoint locally. By default, a connection to the local SharePoint installation

is automatically listed under the SharePoint Connections node. You can add a connection to a

remote server by right-clicking the SharePoint Connections node and selecting Add Connection.

exploring sharePoint 2010 .

519

When you select a SharePoint component in the Server Explorer, the properties of that component

will be listed in the Properties window. The Server Explorer provides read-only access to SharePoint.

Figure 24-4 shows the Server Explorer and the properties for a SharePoint site.

fiGure 24-4

Now that you’ve seen how to connect to and browse a SharePoint site, it’s worth spending some

time understanding some of the main concepts used in SharePoint.

Content types provide a way to define distinct types of

SharePoint content, such as a document or an announcement.

A content type has a set of fields associated with it that define

the metadata of the content. For example, the Document

content type shown in Figure 24-5 has fields such as the title

and the date the document was last modified. A content type

has properties that define settings such as the template to

use for displaying, editing, or creating a new instance of that

content type.

Features are a collection of resources that describe a logical set

of functionality. For example, SharePoint ships with Features

such as discussion lists, document libraries, and survey lists.

Features contain templates, pages, list definitions, event

receivers, and workflows. A Feature can also include resources

such as images, JavaScript files, or CSS files.

Features also contain event receivers, which are event handlers

that are invoked when a Feature is activated, deactivated, installed,

uninstalled, or upgraded. Event receivers can also be created for other SharePoint items such as lists or

SharePoint sites.

Lists are fundamental to SharePoint and are used almost everywhere. Features such as surveys, issues,

and document libraries are all built upon lists. A list definition specifies the fields, forms, views

fiGure 24-5

520 .

chaPter 24 ShArepoinT

(.aspx pages), and content types associated with the list. A concrete implementation of a list

definition is called a list instance.

Workflows under SharePoint 2010 are used to automate business processes. SharePoint workflows

are actually built upon the same workflow engine (Windows Workflow Foundation) that ships with

.NET v3.5. Workflows can be associated with a particular SharePoint site, list, or content type.

Finally, Web Parts are web server controls that are hosted on a Web Part page in SharePoint. Users

can personalize a Web Part page and choose to display one or more Web Parts on that page. Web

Parts can display anything as simple as a static label that provides some content for a web page,

through to a complete data entry form for submitting line of business data.

creatinG a sharePoint ProJect

Now that you have some background on the main concepts behind SharePoint development, you

can create your first SharePoint solution. In Visual Studio 2010 select File . New . Project. Filter

the project types by selecting Visual C# or Visual Basic followed by SharePoint, and then 2010. The

available SharePoint project types will be displayed, as shown in Figure 24-6.

fiGure 24-6

Creating a sharePoint Project .

521

A number of SharePoint project templates

ship with Visual Studio 2010. Most of the

SharePoint components that can be created

with these project templates can also be created

as individual items in an existing SharePoint

solution. For this reason, select a new Empty

SharePoint Project.

When you click OK, Visual Studio launches the

SharePoint Customization Wizard, shown in

Figure 24 - 7. You will be prompted to specify the

site and a security level for debugging. Because it

is not possible to debug SharePoint sites running

on remote computers you will only be able

to select a local SharePoint site. You must also

select the trust level that the SharePoint solution

will be deployed with during debugging. Select Deploy as a Farm Solution and click Finish.

fiGure 24-7

Sandboxed solutions run in a partially trusted environment with access to a

limited subset of functionality. The sandbox environment monitors a range

of performance-related measures including CPU execution time, memory

consumption, and database query time. In addition, sandbox solutions cannot

be activated unless they pass a validation process. This provides SharePoint

administrators with the confidence that a rogue component won’t impact the rest

of the SharePoint environment.

When the SharePoint project is created you will notice two unique nodes listed in the Solution

Explorer. These nodes are found in every SharePoint project and cannot be deleted, moved, or

renamed.

The Features node can contain one or more SharePoint features. As mentioned in the previous

section, a Feature is a collection of resources that describe a logical set of functionality. Any time

you add a new item, such as a visual Web Part or a content type, it is added to a Feature under the

Features node. Depending on the scope of the item, it will either be added to an existing Feature or

目录
设置
设置
阅读主题
字体风格
雅黑 宋体 楷书 卡通
字体大小
适中 偏大 超大
保存设置
恢复默认
手机
手机阅读
扫码获取链接,使用浏览器打开
书架同步,随时随地,手机阅读
首 页 < 上一章 章节列表 下一章 > 尾 页