70-573 · Question #2
You have a SharePoint site collection. You plan to create a sandboxed solution that will contain a Web Part. The Web Part will display the title of the root Web. You write the following code segment…
The correct answer is C. Change line 01 to the following code segment. MNEMONIC RULE: "sandboxed = SPContext" OpenWeb() method returns SPWeb object, so answers A and B are incorrect, since they assume OpenWeb()method doesn't return an object. Answer D is incorrect for the same reason. This constructor is allowed in sandboxed solutions. in that…
Question
You have a SharePoint site collection. You plan to create a sandboxed 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.) 02 03 Label currentTitle = new Label(); 04 currentTitle.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?
Options
- AAdd the following line of code at line 02:
- BAdd the following line of code at line 02:
- CChange line 01 to the following code segment:
- DChange line 04 to the following code segment:
How the community answered
(45 responses)- A11% (5)
- B7% (3)
- C80% (36)
- D2% (1)
Explanation
MNEMONIC RULE: "sandboxed = SPContext" OpenWeb() method returns SPWeb object, so answers A and B are incorrect, since they assume OpenWeb()method doesn't return an object. Answer D is incorrect for the same reason. This constructor is allowed in sandboxed solutions. in that case, the value of the requestUrl parameter mustresolve to the parent site collection in which the sandboxed solution is deployed. If the value of the requestUrl parameter resolves to the URL of any other site collection, the constructor throwsan exception because a sandboxed solution is not allowed to access any SharePoint objects outside its hostingsite collection. SPSite Constructor (String)
Topics
Community Discussion
No community discussion yet for this question.