You need to prevent the error from occurring

You have a SharePoint site collection. The root Web of the site collection has the URL
http://intranet.You plan to create a user solution that will contain a Web Part. The Web Part will
display the title of the root Web. You write the following code segment for the Web Part. (Line
numbers are included for reference only.) 01Dim currentSite As New SPSite(“http://intranet”) 02
03Dim currentTitle As New Label() 04currentTitle.Text = currentSite.RootWeb.Title You add the
Web Part to a page in the root Web and receive the following error message: “Web Part Error:
Unhandled exception was thrown by the sandboxed code wrapper’s Execute method in the partial
trust app domain: An unexpected error has occurred.” You need to prevent the error from
occurring. What should you do?

You have a SharePoint site collection. The root Web of the site collection has the URL
http://intranet.You plan to create a user solution that will contain a Web Part. The Web Part will
display the title of the root Web. You write the following code segment for the Web Part. (Line
numbers are included for reference only.) 01Dim currentSite As New SPSite(“http://intranet”) 02
03Dim currentTitle As New Label() 04currentTitle.Text = currentSite.RootWeb.Title You add the
Web Part to a page in the root Web and receive the following error message: “Web Part Error:
Unhandled exception was thrown by the sandboxed code wrapper’s Execute method in the partial
trust app domain: An unexpected error has occurred.” You need to prevent the error from
occurring. What should you do?

A.
Add the following line of code at line 02. currentSite.OpenWeb(“http://intranet”)

B.
Change line 01 to the following code segment. Dim currentSite As SPSite =
SPContext.Current.Site

C.
Add the following line of code at line 02. currentSite.OpenWeb()

D.
Change line 04 to the following code segment. currentTitle.Text = currentSite.OpenWeb().Title



Leave a Reply 0

Your email address will not be published. Required fields are marked *