建体彩网|中彩网双色球连号|
?
快捷搜索:  as  test  1111  test aNd 8=8  test++aNd+8=8  as++aNd+8=8  as aNd 8=8

和記娛樂網上官網:Sharepoint 70573考試習題和解析(Q4Q7)

?

Question 4

You have a Web Part that contains the following code seg和記娛樂網上官網ment. (Line numbers are included for reference only.)

01 protected void Page_Load(object sender, EventArgs e)

02 {

03SPSite site = new SPSite("http://www.contoso.com/default.aspx");

04{

05SPWeb web = site.OpenWeb();

06

07}

08 }

You deploy the Web Part to a SharePoint site.

After you deploy the Web Part, users report that the site loads slowly. You need to modify the Web Part to prevent the site from loading slowly.

What should you do?

A. Add the following line of code at line 06:

web.Close();

B. Add the following line of code at line 06:

web.Dispose();

C. Add the following line of code at line 06:

site.Close();

D. Change line 03 to the following code segment:

using (SPSite site = new SPSite("http://www.contoso.com/default.aspx"))

解析:

很顯著,此題照樣考的是SPSite,SPWeb工具內存的開釋。

由前面Question2,3的闡發我們已經知道,應用Close措施與應用Dispose措施開釋內存的差別。

顯然謎底A,B,C只”分手” 開釋了SPWeb工具或SPSite工具,而且開釋的機會紕謬。

我們平日是經由過程兩種要領來處置懲罰此類代碼

1. Try….Catch….Finally代碼布局來實現內存的開釋處置懲罰,

2. 也可以經由過程using()語句來自動實現內存的開釋(事實上,系統在運行時會自動把Using代碼塊處置懲罰為Try….Catch…Finally代碼塊)。

http://msdn.microsoft.com/en-us/library/ee557362.aspx

以是本題目精確選項應該是D

Question 5

You create an event receiver.

The ItemAdded method for the event receiver contains the following code segment. (Line numbers are included for reference only.)

01 SPWeb recWeb = properties.Web;

02 using (SPSite siteCollection = new SPSite("http://site1/hr"))

03 {

04using (SPWeb web = siteCollection.OpenWeb())

05{

06PublishingWeb oWeb = PublishingWeb.GetPublishingWeb(web);

07PublishingWebCollection pubWebs = oWeb.GetPublishingWebs();

08foreach (PublishingWeb iWeb in pubWebs)

09{

10try

11{

12SPFile page = web.GetFile("/Pages/default.aspx");

13SPLimitedWebPartManager wpManager = page.GetLimitedWebPartManager(PersonalizationScope.Shared);

14}

15finally

16{

17if (iWeb != null)

18{

19iWeb.Close();

20}

21}

22}

23}

24 }

You need to prevent the event receiver from causing memory leaks.

Which object should you dispose of?

A. oWeb at line 06

B. recWeb at line 01

C. wpManager at line 13

D. wpManager.Web at line 13

解析:

對付選項A. oWeb工具是經由過程PublishingWeb.GetPublishingWeb措施獲取的,這個工具并不是SPWeb工具,它是一個包裹了SPWeb工具集的工具實例,我們可以經由過程此實例的GetPublishingWebs措施進一步獲取這包裹于其內的SPWeb工具集。并且經由過程遍歷這個工具集來分手開釋其內的SPWeb工具,如下面代碼:

using(SPWeb web = site.OpenWeb())

{PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(web);

PublishingWebCollection pubWebs = pubWe和記娛樂網上官網b.GetPublishingWebs());foreach(PublishingWeb innerPubWeb in pubWebs)

{try

{Process innerPubWeb

}finally

{innerPubWeb.Web.Dispose();

}}

}

而本題目也恰是經由過程上述要領來實現的,以是選項A不會造成內存透露。

對付選項B. recWeb是經由過程properties工具的Web屬性獲取的, properties是Evenreceiver的通報參數。如下例:

private static void ItemAdded(SPItemEventProperties properties)

{SPWeb web = properties.Web;

}

由此獲取的SPWeb工具并不會造成內存的透露,由于它是由SPSite工具創建的,而此SPSite工具會在Event事故停止后自動被開釋收受接收。

對付選項C,它并不是SPWeb工具,是以不存在要去開釋它。

選項D為什么為造成內存透露問題呢,由于wpManager.Web是由page.GetLimitedWebPartManager措和記娛樂網上官網施返回的SPLimitedWebPartManager工具來獲取的,這個SPLimitedWebPartManager工具實例包孕了對SPWeb工具的內部引用, 并且在引用SPWeb工具之后并不會自動開釋它,以是,wpManager.Web工具是會造成內存透露的。換句話說:當我們應用GetLimitedWebPartManager相關措施來獲取SPWeb工具時,必然要留意內存透露問題。

是以,本題應該選 D

參考 :

http://msdn.microsoft.com/zh-和記娛樂網上官網tw/library/ms497306.aspx

http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/8999f361-6e8e-452a-a42e-c8bf323c106e

Question 6

You create a console application to manage Personal Sites.

The application contains the following code segment. (Line numbers are included for reference only.)

01 SPSite siteCollection = new SPSite("http://moss");

02 UserProfileManager profileManager = new UserProfileManager(ServerContext.GetContext(siteCollection));

03 UserProfile profile = profileManager.GetUserProfile("domain\username");

04 SPSite personalSite = profile.PersonalSite;

05

06 siteCollection.Dispose();

You deploy the application to a SharePoint site.

After deploying the application, users report that the site loads slowly. You need to modify the application to prevent the site from loading slowly.

What should you do?

A. Remove line 06.

B. Add the following line of code at line 05:

personalSite.close();

C. Add the following line of code at line 05:

personalSite.Dispose();

D. Change line 06 to the following code segment:

siteCollection.close();

解析:

選項A, 顯然是錯上加錯,已經是因為SPSite造成的內存透露問題了,還在進一步擴大年夜這個問題。

選項 D. 顯示無此需要,由于代碼中已經有關于siteCollection的內存開釋了,即:siteCollection.Dispose();

選項 B與C:Close措施在這里并不是真正的完成了開釋,由于personalSite并不是你新New的一個SPSite工具實例,見Question2,3解析,以是只能經由過程 Dispose措施才能真正開釋SPSite的內存。

以是本題目精確選項應該是C

Question 7

You are creating a Web Part for SharePoin和記娛樂網上官網t Server 2010.

The Web Part contains the following code segment. (Line numbers are included for reference only.)

01 protected override void CreateChildControls()

02 {

03base.CreateChildControls();

04SPSecurity.RunWithElevatedPrivileges(

05delegate()

06{

07Label ListCount = new Label();

08ListCount.Text = String.Format("There are {0} Lists", SPContext.Current.Web.Lists.Count);

09Controls.Add(ListCount);

10});

11 }

You need to identify which line of code prevents the Web Part from being deployed as a sandboxed solution.

Which line of code should you identify?

A.03

B. 04

C. 08

D. 09

解析

本題實質是考的關于Sandbox Solution的限定問題,Sandbox之以是安然,恰是由于受限,以是它不支持經由過程RunWithElevatedPrivileges手段來提升代碼的造訪權限,由于如斯一來就破壞了它的設計初衷。

Sandboxed solutions也不支持操作諸如下面的元素:

• Application Pages

• Custom Action Group

• Farm-scoped features

• HideCustomAction element

• Web Application-scoped features

• Workflows with code

以是本題目精確選項應該是B

參考:

http://msdn.microsoft.com/en-us/library/gg615454(v=office.14).aspx

http://msdn.microsoft.com/en-us/library/gg615454.aspx

http://sharing-the-experience.blogspot.com.au/2011/06/sharepoint-2010-sandboxed-solution.html

免責聲明:以上內容源自網絡,版權歸原作者所有,如有侵犯您的原創版權請告知,我們將盡快刪除相關內容。

您可能還會對下面的文章感興趣:

建体彩网
比较好的足球指数网址 三分彩走势图 足球混合过关计算器 生肖时时彩 外贸现在还赚钱吗 股票分析微信 2002双色球基本走势图 五子棋的玩法规则 天天捕鱼最新版 福彩老快3技巧