Exam 70-511 : Windows Applications Development with Microsoft .NET Framework 4 Part – 4

Question: You use Microsoft .NET Framework 4 to create an application. The application contains a partially trusted client assembly and a server assembly. You create a custom sandboxed application domain. You need to ensure that the application can be executed in a partial-trust environment. What should you do?

  1. Apply the following attribute to the server assembly.
    [assembly:AllowPartiallyTrustedCallers(PartialTrustVisibilityLevel=VisibleToAllHosts)]
  2. Apply the following attribute to the server assembly.
    [assembly:AllowPartiallyTrustedCallers(PartialTrustVisibilityLevel=NotVisibleByDefault)]
  3. Apply the following attribute to the client assembly.
    [assembly:AllowPartiallyTrustedCallers(PartialTrustVisibilityLevel=VisibleToAllHosts)]
  4. Apply the following attribute to the client assembly.
    [assembly:AllowPartiallyTrustedCallers(PartialTrustVisibilityLevel=NotVisibleByDefault)]

Correct Answer: 2


Question: You upgrade a Windows Forms application to Microsoft .NET Framework 4. The application was developed by using a previous version of the .NET Framework. The application uses the Code Access Security (CAS) policy for file access. When the application is executed, you receive the following exception:
“NotSupportedException: This method uses CAS policy, which has been obsoleted by the .NET Framework.”
You need to resolve the error. What should you do?

  1. Add the following code fragment to the application’s configuration file.
    <runtime>
    <NetFx40_LegacySecurityPolicy enabled="true"/> </runtime>
  2. Add the following code fragment to the application’s configuration file.
    <runtime>
    <legacyV1CASPolicy enabled="true"/>
    </runtime>
  3. Add the following code segment to the application’s main method.
    AppDomain domain = System.AppDomain.CreateDomain("MyDomain");
    PolicyLevel polLevel = PolicyLevel.CreateAppDomainLevel();
    PermissionSet permSet = new PermissionSet(PermissionState.None);
    permSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
    domain.ExecuteAssembly("Assemblies\MyWindowsExe.exe");
    polLevel.RootCodeGroup.PolicyStatement = new PolicyStatement(permSet);
    domain.SetAppDomainPolicy(polLevel);
  4. Add the following code segment to the application’s main method.
    PermissionSet requiredSet = new PermissionSet(PermissionState.None);
    requiredSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
    PermissionSet optionalSet = new PermissionSet(PermissionState.None);
    optionalSet.AddPermission(new FileIOPermission(FileIOPermissionAccess.Read, new string[] { @"c:temp" }));
    PermissionSet deniedSet = new PermissionSet(PermissionState.None);
    deniedSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.ControlPolicy)); Console.WriteLine("nCurrent permissions granted:");
    PermissionSet permsDenied = null;
    foreach(IPermission perm in SecurityManager.ResolvePolicy(evidence, requiredSet, optionalSet, deniedSet, out permsDenied)){}

Correct Answer: 1


Question: You use Microsoft .NET Framework 4 to create a Windows Forms client application. You write the following code segment.
sealed class FormSettings : ApplicationSettingsBase {
[UserScopedSetting()]
[DefaultSettingValue("225, 200")]
public Size FormSize
{
get { return (Size)this["FormSize"]; }
set { this["FormSize"] = value; }
}
}

The application contains a form of type Form1 that contains a FormSettings object named frmSettings1. You need to maintain the user’s form size preference each time the user executes the application. Which code segment should you use?

  1. private void Form1_Load(object sender, EventArgs e) { frmSettings1.Reset(); }
    private void Form1_FormClosing(object sender, FormClosingEventArgs e) { frmSettings1.FormSize = this.Size; frmSettings1.Save(); }
  2. private void Form1_Load(object sender, EventArgs e) { frmSettings1.Reset(); }
    private void Form1_FormClosing(object sender, FormClosingEventArgs e) { frmSettings1.FormSize = this.Size; frmSettings1.Upgrade(); }
  3. private void Form1_Load(object sender, EventArgs e) { this.Size = frmSettings1.FormSize; }
    private void Form1_FormClosing(object sender, FormClosingEventArgs e) { frmSettings1.FormSize = this.Size; frmSettings1.Upgrade(); }
  4. private void Form1_Load(object sender, EventArgs e) { this.Size = frmSettings1.FormSize; }
    private void Form1_FormClosing(object sender, FormClosingEventArgs e) { frmSettings1.FormSize = this.Size; frmSettings1.Save(); }

Correct Answer: 4


Question: You use Microsoft .NET Framework 4 to create a Windows Forms application. You write the following code segment. (Line numbers are included for reference only.)
01sealed class FormSettings : ApplicationSettingsBase
02{
03
04public String Description
05{
06get { return (String)this[“Description”]; }
07set { this[“Description”] = value;}
08}
09}
You need to ensure that the first time each user opens the application, a text field displays the following message: “Please enter your setting.” Which code segment should you insert at line 03?

  1. [UserScopedSetting()] [DefaultSettingValue("Please enter your setting.")]
  2. [UserScopedSetting()] [SettingsDescription("Description: Please enter your setting.")]
  3. [ApplicationScopedSetting()] [DefaultSettingValue("Please enter your setting.")]
  4. [ApplicationScopedSetting()] [SettingsDescription("Description: Please enter your setting.")]

Correct Answer: 1


Question: You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. You need to ensure that users can view content in a book-reading format that displays two pages at a time. Which control should you use?

  1. FlowDocument
  2. FlowDocumentReader
  3. FlowDocumentPageViewer
  4. FlowDocumentScrollViewer

Correct Answer: 2

Tagged . Bookmark the permalink.

Leave a Reply