You are creating a Web Part for SharePoint Server 2010.
The Web Part contains the following code segment. (Line numbers are included for reference only.)
01 protected override void CreateChildControls()
02 {
03 base.CreateChildControls();
04 SPSecurity.RunWithElevatedPrivileges(
05 delegate()
06 {
07 Label ListCount = new Label();
08 ListCount.Text = String.Format(“There are {0} Lists”, SPContext.Current.Web.Lists.Count);
09 Controls.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
Explanation:
MNEMONIC RULE: “No RunWithElevatedPrivileges for sandboxed solutions”Methods in a sandboxed solution cannot be configured to run with the elevated privileges of the user identity in which the application pool runs.
Restrictions on Sandboxed Solutions in SharePoint 2010
http://msdn.microsoft.com/en-us/library/gg615454.aspx