384
Microsoft .NET Framework 2.0-Application Development Foundation Question Number (ID) : 1 (536P_3.2.1_03) _________________________________________________________________________________________________________________ In the Installer class, which of the following methods is called first when installing an application? 1. OnBeforeInstall <Correct> 2. Commit 3. OnCommitting 4. Install 5. OnBeforeRollback Explanation : When installing an application, methods are called in the following order: OnBeforeInstall, Install, OnAfterInstall, OnCommiting, Commit, and finally OnCommitted. OnBeforeRollback is called only if an error occurs during setup. Objective: Embedding configuration, diagnostic, management, and installation features into a .NET Framework application Sub Objective(s): Create a custom Microsoft Windows Installer for the .NET Framework components by using the System.Configuration.Install namespace, and configure the .NET Framework applications by using configuration files, environment variables, and the .NET Framework Configuration tool (Mscorcfg.msc).). Installer class References : MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, Microsoft Chapter 9 - Lesson 2 Installer Class MSDN Library, Microsoft Link: http://msdn2.microsoft.com/en-us/library/system.configuration.install.installer(VS.80).aspx

MCTS 70-536 Questions

Embed Size (px)

Citation preview

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 1 (536P_3.2.1_03)

_________________________________________________________________________________________________________________

In the Installer class, which of the following methods is called first when installing an application?

1. OnBeforeInstall <Correct>

2. Commit

3. OnCommitting

4. Install

5. OnBeforeRollback

Explanation :When installing an application, methods are called in the following order: OnBeforeInstall, Install, OnAfterInstall, OnCommiting, Commit, and finally OnCommitted.

OnBeforeRollback is called only if an error occurs during setup.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Create a custom Microsoft Windows Installer for the .NET Framework components by using the System.Configuration.Install namespace, and configure the .NET Framework applications by using configuration files, environment variables, and the .NET Framework Configuration tool (Mscorcfg.msc).). Installer class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 2

Installer ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.configuration.install.installer(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 2 (536P_5.2.2_03)

_________________________________________________________________________________________________________________

Per instructions from your IT department, you need to configure your application's configuration file with the following security settings:

* Users must be able to read, but not modify, the configuration file.* Administrators must be able to edit the configuration file.* An event must be added to the event log each time an administrator modifies the file.

Which of the following code samples correctly creates a FileSecurity object to meet these requirements?

1. ' VBDim a As NTAccount = New NTAccount("Administrators")Dim u As NTAccount = New NTAccount("Users")

Dim ar1 As FileSystemAccessRule = New FileSystemAccessRule(a, FileSystemRights.FullControl, AccessControlType.Allow)Dim ar2 As FileSystemAccessRule = New FileSystemAccessRule(u, FileSystemRights.Read, AccessControlType.Allow)Dim ar3 As FileSystemAuditRule = New FileSystemAuditRule(a, FileSystemRights.Modify, AuditFlags.Success)

Dim fs As FileSecurity = New FileSecurityfs.AddAccessRule(ar1)fs.AddAccessRule(ar2)fs.AddAuditRule(ar3)

// C#NTAccount a = new NTAccount("Administrators");NTAccount u = new NTAccount("Users");

FileSystemAccessRule ar1 = new FileSystemAccessRule(a, FileSystemRights.FullControl, AccessControlType.Allow);FileSystemAccessRule ar2 = new FileSystemAccessRule(u, FileSystemRights.Read, AccessControlType.Allow);FileSystemAuditRule ar3 = new FileSystemAuditRule(a, FileSystemRights.Modify, AuditFlags.Success);

FileSecurity fs = new FileSecurity();fs.AddAccessRule(ar1);fs.AddAccessRule(ar2);fs.AddAuditRule(ar3);

<Correct>

2. ' VBDim a As NTAccount = New NTAccount("Administrators")Dim u As NTAccount = New NTAccount("Users")

Dim ar1 As FileSystemAuditRule = New FileSystemAuditRule(a, FileSystemRights.FullControl, AccessControlType.Allow)Dim ar2 As FileSystemAuditRule = New FileSystemAuditRule(u, FileSystemRights.Read, AccessControlType.Allow)Dim ar3 As FileSystemAuditRule = New FileSystemAuditRule(a, FileSystemRights.Modify, AuditFlags.Success)

Dim fs As FileSecurity = New FileSecurityfs.AddAuditRule(ar1)fs.AddAuditRule(ar2)fs.AddAuditRule(ar3)

// C#NTAccount a = new NTAccount("Administrators");NTAccount u = new NTAccount("Users");

FileSystemAuditRule ar1 = new FileSystemAuditRule(a, FileSystemRights.FullControl, AccessControlType.Allow);FileSystemAuditRule ar2 = new FileSystemAuditRule(u, FileSystemRights.Read, AccessControlType.Allow);FileSystemAuditRule ar3 = new FileSystemAuditRule(a, FileSystemRights.Modify, AuditFlags.Success);

FileSecurity fs = new FileSecurity();fs.AddAuditRule(ar1);

fs.AddAuditRule(ar2);fs.AddAuditRule(ar3);

3. ' VBDim a As NTAccount = New NTAccount("Administrators")Dim u As NTAccount = New NTAccount("Users")

Dim ar1 As FileSystemAccessRule = New FileSystemAccessRule(a, FileSystemRights.FullControl, AccessControlType.Allow)Dim ar2 As FileSystemAccessRule = New FileSystemAccessRule(u, FileSystemRights.Read, AccessControlType.Allow)Dim ar3 As FileSystemAccessRule = New FileSystemAccessRule(a, FileSystemRights.Modify, AuditFlags.Success)

Dim fs As FileSecurity = New FileSecurityfs.AddAccessRule(ar1)fs.AddAccessRule(ar2)fs.AddAccessRule(ar3)

// C#NTAccount a = new NTAccount("Administrators");NTAccount u = new NTAccount("Users");

FileSystemAccessRule ar1 = new FileSystemAccessRule(a, FileSystemRights.FullControl, AccessControlType.Allow);FileSystemAccessRule ar2 = new FileSystemAccessRule(u, FileSystemRights.Read, AccessControlType.Allow);FileSystemAccessRule ar3 = new FileSystemAuditRule(a, FileSystemRights.Modify, AuditFlags.Success);

FileSecurity fs = new FileSecurity();fs.AddAccessRule(ar1);fs.AddAccessRule(ar2);fs.AddAccessRule(ar3);

4. ' VBDim a As NTAccount = New NTAccount("Administrators")Dim u As NTAccount = New NTAccount("Users")

Dim ar1 As FileSystemAccessRule = New FileSystemAccessRule(a, FileSystemRights.FullControl, AccessControlType.Allow)Dim ar2 As FileSystemAccessRule = New FileSystemAccessRule(u, FileSystemRights.Read, AccessControlType.Allow)Dim ar3 As FileSystemAuditRule = New FileSystemAuditRule(a, FileSystemRights.Modify, AuditFlags.Success)

Dim fs As FileSecurity = New FileSecurityfs.AddAuditRule(ar1)fs.AddAuditRule(ar2)fs.AddAccessRule(ar3)

// C#NTAccount a = new NTAccount("Administrators");NTAccount u = new NTAccount("Users");

FileSystemAccessRule ar1 = new FileSystemAccessRule(a, FileSystemRights.FullControl, AccessControlType.Allow);FileSystemAccessRule ar2 = new FileSystemAccessRule(u, FileSystemRights.Read, AccessControlType.Allow);FileSystemAuditRule ar3 = new FileSystemAuditRule(a, FileSystemRights.Modify, AuditFlags.Success);

FileSecurity fs = new FileSecurity();fs.AddAuditRule(ar1);fs.AddAuditRule(ar2);fs.AddAccessRule(ar3);

Explanation :You need to create two instances of FileSystemAccessRule to create the Discrectionary Access Control Lists (DACLs) for Administrators and Users, and one instance of FileSystemAuditRule to create the System Access Control List (SACL) for Administrators.

You cannot create an instance of FileSystemAccessRule to enable auditing. You must use FileSystemAuditRule.

You must call FileSecurity.AddAccessRule to add instances of type FileSystemAccessRule, and FileSecurity.AddAuditRule to add instances of type FileSystemAuditRule.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement access control by using the System.Security.AccessControl classes. AccessRule class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 2

ACL Technology ScenariosMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms229925(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 3 (536P_3.3.1_01)

_________________________________________________________________________________________________________________

You are writing an application that implements a custom authentication mechanism. To which event log should you write entries related to unsuccessful authentication attempts?

1. Active Directory

2. System

3. Application <Correct>

4. Security

Explanation :You should always write events to the Application event log or a custom event log.

You cannot write events to the Security log because it is read-only. The Security log is reserved for the operating system to store auditing events.

The System event log is reserved for operating system events.

The Active Directory event log is reserved for events relating to an Active Directory domain controller.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Manage an event log by using the System.Diagnostics namespace. Write to an event log.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 1

EventLog ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 4 (536P_5.3_05)

_________________________________________________________________________________________________________________

You need to establish a Secure Sockets Layer (SSL) session with a remote server. The security policy at your organization requires both the client and the server to provide a valid certificate for authentication before communications begin. Which method can you call to check this?

1. SslStream.IsAuthenticated && SslStream.IsEncrypted

2. SslStream.IsServer

3. SslStream.IsMutuallyAuthenticated <Correct>

4. SslStream.IsSigned

Explanation :SslStream.IsMutuallyAuthenticated gets a Boolean value that indicates whether both the server and client have been authenticated.

SslStream.IsSigned gets a Boolean value that indicates whether the data sent using this stream is signed. It does not indicate whether both the client and server were authenticated.

SslStream.IsServer gets a Boolean value that indicates whether the local side of the connection used by this SslStream was authenticated as the server. It does not indicate whether both the client and server were authenticated.

SslStream.IsAuthenticated gets a Boolean value that indicates whether authentication was successful. It does not indicate whether both the client and server were authenticated.

SslStream.IsEncrypted gets a Boolean value that indicates whether this SslStream uses data encryption. It does not indicate whether both the client and server were authenticated.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement a custom authentication scheme by using the System.Security.Authentication classes. (Refer System.Security.Authentication namespace)

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 1

SslStream ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.net.security.sslstream.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 5 (536P_5.2.1_02)

_________________________________________________________________________________________________________________

You are writing an internal application. Your IT department is responsible for defining permissions that different groups have to the registry keys your application uses. IT has requested only a single change to the default registry permissions: they want the Guests local group to be explicitly denied all access.

Which of the following code samples properly sets the permissions to the HKEY_CURRENT_USER\Software\MyApp key?

1. ' VBDim g As NTAccount = New NTAccount("Guests")Dim rar As RegistryAccessRule = New RegistryAccessRule(g, RegistryRights.FullControl, AccessControlType.Deny)Dim rs As RegistrySecurity = New RegistrySecurity()rs.AddAccessRule(rar)Dim rk As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\MyApp", True)rk.SetAccessControl(rs)rk.Close()

// C#NTAccount g = new NTAccount("Guests");RegistryAccessRule rar = new RegistryAccessRule(g, RegistryRights.FullControl, AccessControlType.Deny);RegistrySecurity rs = new RegistrySecurity();rs.AddAccessRule(rar);RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\MyApp", true);rk.SetAccessControl(rs);rk.Close();

<Correct>

2. ' VBDim g As NTAccount = New NTAccount("Guests")Dim rar As RegistryAccessRule = New RegistryAccessRule(g, RegistryRights.FullControl, AccessControlType.Allow)Dim rs As RegistrySecurity = New RegistrySecurity()rs.AddAccessRule(rar)Dim rk As RegistryKey = RegistryHive.CurrentUserrk = Registry.CurrentUser.OpenSubKey("Software\MyApp", True)rk.SetAccessControl(rs)rk.Close()

// C#NTAccount g = new NTAccount("Guests");RegistryAccessRule rar = new RegistryAccessRule(g, RegistryRights.FullControl, AccessControlType.Allow);RegistrySecurity rs = new RegistrySecurity();rs.AddAccessRule(rar);RegistryKey rk = RegistryHive.CurrentUser;rk = OpenSubKey(@"Software\MyApp", true);rk.SetAccessControl(rs);rk.Close();

3. ' VBDim g As NTAccount = New NTAccount("Guests")Dim rar As RegistryAccessRule = New RegistryAccessRule(g, RegistryRights.FullControl, AccessControlType.Deny)Dim rs As RegistrySecurity = New RegistrySecurity()rs.AddAccessRule(rar)Dim rk As RegistryKey = Registry.Users.Current.OpenSubKey("Software\MyApp", True)rk.SetAccessControl(rs)rk.Close()

// C#NTAccount g = new NTAccount("Guests");RegistryAccessRule rar = new RegistryAccessRule(g, RegistryRights.FullControl, AccessControlType.Deny);RegistrySecurity rs = new RegistrySecurity();rs.AddAccessRule(rar);

RegistryKey rk = Registry.Users.Current.OpenSubKey(@"Software\MyApp", true);rk.SetAccessControl(rs);rk.Close();

4. ' VBDim g As NTAccount = New NTAccount("Guests")Dim rar As RegistryAccessRule = New RegistryAccessRule(g, RegistryRights.FullControl, AccessControlType.Deny)Dim rs As RegistrySecurity = New RegistrySecurity()rs.AddAccessRule(rar)Dim rk As RegistryKey = RegistryHive.CurrentUserrk = Registry.CurrentUser.OpenSubKey("Software\MyApp", True)rk.SetAccessControl(rs)rk.Close()

// C#NTAccount g = new NTAccount("Guests");RegistryAccessRule rar = new RegistryAccessRule(g, RegistryRights.FullControl, AccessControlType.Deny);RegistrySecurity rs = new RegistrySecurity();rs.AddAccessRule(rar);RegistryKey rk = RegistryHive.CurrentUser;rk = OpenSubKey(@"Software\MyApp", true);rk.SetAccessControl(rs);rk.Close();

Explanation :To modify registry permissions, first create a RegistryAccessRule instance with the correct permissions. Then create a RegistrySecurity instance, and add the access rule. Finally, create an instance of RegistryKey and call the RegistryKey.SetAccessControl method.

Setting the hive using Registry.Users is incorrect; the requirements specify that you should use Registry.CurrentUser for the HKEY_CURRENT_USER hive.

You cannot create an instance of RegistryKey using a RegistryHive because the runtime cannot automatically perform the conversion.

You cannot create an instance of RegistryKey using a RegistryHive because the runtime cannot automatically perform the conversion. Additionally, you need to specify AccessControlType.Deny.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement access control by using the System.Security.AccessControl classes. DirectorySecurity class, FileSecurity class, FileSystemSecurity class, and RegistrySecurity class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 2

ACL Technology ScenariosMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms229925(VS.80).aspx

RegistryAccessRule ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.accesscontrol.registryaccessrule.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 6 (536P_4.4.1_03)

_________________________________________________________________________________________________________________

Which of the following code samples writes a string to a text file? (Choose all that apply.)

1. ' VBDim s As String = "Hello, World!"Dim f as New File("Text.txt");f.writeLine(s)

// C#string s = "Hello, World!";File f = new File("Text.txt");f.writeLine(s);

2. ' VBDim s As String = "Hello, World!"File.WriteAllText("Text.txt", s)

// C#string s = "Hello, World!";File.WriteAllText("Text.txt", s);

<Correct>

3. ' VBDim s As String = "Hello, World!"Dim sw As StreamWriter = New StreamWriter("Text.txt")Try sw.WriteLine(s)Finally Sw.Close()End Try

// C#string s = "Hello, World!";using (StreamWriter sw = new StreamWriter("Text.txt")){ sw.WriteLine(s);}

<Correct>

4. ' VBDim s As String = "Hello, World!"s.WriteFile("Text.txt")

// C#string s = "Hello, World!";s.WriteFile("Text.txt");

Explanation :To write a string to a file, you can call the static File.WriteAllText method or you can create a StreamWriter object.

The String class does not have a WriteFile method.

The File class contains only static methods; you cannot create an instance of the File class.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Access files and folders by using the File System classes. (Refer System.IO namespace) File class and FileInfo class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, Microsoft

Chapter 2 - Lesson 1

File ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/library/3saad2h5.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 7 (536P_3.2.1_01)

_________________________________________________________________________________________________________________

You are creating a custom installer manually rather than using the Microsoft Visual Studio tools to automatically generate an installer.

From the list on the right, select the tasks that you should perform to correctly create an instance of the Installer class that can install your application. Place your selections in the list on the left in the order in which the tasks should be performed. Place your selections in the list on the left by clicking the items in the list on the right and clicking the arrow. You can also use the Up and Down buttons to rearrange items in the list on the left. You might not need to use all the items from the list on the right.

Explanation :The following steps need to be taken to use a class derived from the Installer class:

* Inherit the Installer class.* Override the Install, Commit, Rollback, and Uninstall methods.* Add the RunInstallerAttribute to your derived class, and set it to true.* Put your derived class in the assembly with your application to install.* Invoke the installers.

The Installer class does not have OnInstall, OnCommit, OnRollback, or OnUninstall methods.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Create a custom Microsoft Windows Installer for the .NET Framework components by using the System.Configuration.Install namespace, and configure the .NET Framework applications by using configuration files, environment variables, and the .NET Framework Configuration tool (Mscorcfg.msc).). Installer class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 2

Installer ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.configuration.install.installer.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 8 (536P_6.2.9_01)

_________________________________________________________________________________________________________________

Which of the following tools produces a COM type library from an assembly and generates a wrapper that performs marshaling during method calls?

1. Tlbexp.exe <Correct>

2. Mdbg.exe

3. Tlbimp.exe

4. Regsvcs.exe

Explanation :The Type Library Exporter (Tlbexp.exe) generates a COM type library from a common language runtime assembly.

The Type Library Importer (Tlbimp.exe) provides opposite functionality from Tlbexp.exe. Tlbimp.exe converts a COM type library to an interop assembly.

The Managed Code Debugger (Mdbg.exe) provides command-line debugging services to help application developers find and fix bugs in programs written using the .NET Framework. Use this tool to find and fix bugs in programs that target the runtime.

The .NET Services Installation Tool (Regsvcs.exe) adds managed classes to Microsoft Windows 2000 Component Services by loading and registering the assembly and generating, registering, and installing the type library into an existing COM+ 1.0 application.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Call unmanaged DLL functions in a .NET Framework application, and control the marshaling of data in a .NET Framework application. (Refer System.Runtime.InteropServices namespace) Marshal data with COM Interop

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 13 - Lesson 3

Marshaling Data with COM InteropMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/9f9f3yxf(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 9 (536P_4.7.3_03)

_________________________________________________________________________________________________________________

You have written an application that stores compressed data using the DeflateStream class. Which of the following methods can you use to open the compressed file?

1. Open the file with WinZip

2. Open the file in Notepad

3. Open the file with Compressed Folders in Windows Explorer

4. Read the file from a .NET application using the DeflateStream class <Correct>

Explanation :DeflateStream does not use the commonly used zip format, nor is it natively supported by Windows Explorer. Therefore, only other .NET applications can read the compressed data.

WinZip cannot open files compressed with DeflateStream.

Compressed Folders cannot open files compressed with DeflateStream.

Notepad cannot open files compressed with DeflateStream.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Compress or decompress stream information in a .NET Framework application (refer System.IO.Compression namespace), and improve the security of application data by using isolated storage. (Refer System.IO.IsolatedStorage namespace) DeflateStream class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 3

DeflateStream ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.io.compression.deflatestream.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 10 (536P_6.4.3_02)

_________________________________________________________________________________________________________________

Your IT department has asked you to write a simple administrative tool. This tool will be run automatically after the boot.ini file has been modified. The tool must send the boot.ini file as an e-mail attachment to the e-mail address [email protected]. To reduce security risks, you want to grant your assembly the most restrictive permissions possible. Given the following code sample, which of the following security declarations should you use? (Choose all that apply.)

' VBDim message As MailMessage = New MailMessage("[email protected]", "[email protected]", "Modified system file", "See the attached file.")Dim data As Attachment = New Attachment("C:\Boot.ini", MediaTypeNames.Application.Octet)message.Attachments.Add(data)Dim client As SmtpClient = New SmtpClient("smtp.contoso.com", 1025)client.Send(message)data.Dispose()

// C#string file = @"C:\Boot.ini";MailMessage message = new MailMessage( "[email protected]", "[email protected]", "Modified system file", "See the attached file.");Attachment data = new Attachment(@"C:\Boot.ini", MediaTypeNames.Application.Octet);message.Attachments.Add(data);SmtpClient client = new SmtpClient("smtp.contoso.com", 1025);client.Send(message);data.Dispose();

1. ' VB<Assembly: FileIOPermission(SecurityAction.RequestOptional, Read:="C:\boot.ini")>

// C#[assembly: FileIOPermission(SecurityAction.RequestOptional, Read = @"C:\boot.ini")]

<Correct>

2. ' VB<Assembly: SmtpPermission(SecurityAction.RequestOptional, Access:="ConnectToUnrestrictedPort")>

// C#[assembly: SmtpPermission(SecurityAction.RequestOptional, Access = "ConnectToUnrestrictedPort")]

<Correct>

3. ' VB<Assembly: SmtpPermission(SecurityAction.RequestOptional, Access:="Connect")>

// C#[assembly: SmtpPermission(SecurityAction.RequestOptional, Access = "Connect")]

4. ' VB<Assembly: FileIOPermission(SecurityAction.RequestOptional, Read:="C:\ ")>

// C#[assembly: FileIOPermission(SecurityAction.RequestOptional, Read = @"C:\ ")]

Explanation :This assembly requires two permissions: SmtpPermission and FileIOPermission. The most restrictive way you can specify the SmtpPermission is to declare the "ConnectToUnrestrictedPort" access, because the code sample uses a nonstandard port number. The most restrictive way you can specify the FileIOPermission is to specify read access for the specific file.

Specifying the "Connect" access level for SmtpPermission would not allow the application to run because it does not use the standard SMTP port of TCP 25.

Specifying read access to the entire C:\ drive is too general and would grant the assembly unnecessary privileges.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery from a .NET Framework application. (Refer System.Net.Mail namespace) SmtpClient class, SmtpPermission class, and SmtpPermissionAttribute class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 15 - Lesson 2

MailMessage ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/8t22a8ww(en-US,VS.80).aspx

Assemblies should declare minimum securityMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms182325.aspx

SecurityAction EnumerationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.permissions.securityaction.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 11 (536P_5.4.15_01)

_________________________________________________________________________________________________________________

You are creating an assembly that needs to store private data to the disk. To protect the private data, you are encrypting it using asymmetric encryption.

From the list on the right, select the tasks that you should perform to create and store a private encryption key. Place your selections in the list on the left in the order in which the tasks should be performed. Place your selections in the list on the left by clicking the items in the list on the right and clicking the arrow. You can also use the Up and Down buttons to rearrange items in the list on the left. You might not need to use all the items from the list on the right.

Explanation :To store private keys persistently, you must create a CspParameters object, specify the CspParameters.KeyContainerName property, use that CspParameters object to create an RSACryptoServiceProvider object, and then set the RSACryptoServiceProvider.PersistKeyInCsp property to true.

You cannot use the blank RSACryptoServiceProvider constructor and then later define the CspParameters object. You must specify the CspParameters object during the RSACryptoServiceProvider construction.

You do not need to set the RSACryptoServiceProvider.ExportParameters property to true.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace) CspParameters class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 3

How to: Store Asymmetric Keys in a Key ContainerMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/tswxhw92.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 12 (536P_2.1.1_01)

_________________________________________________________________________________________________________________

Which of the following are valid reasons to create a service?

1. All users on the computer must be able to run your application.

2. Users must be able to run your application without Administrator privileges.

3. Your application must start automatically when a user logs on.

4. You need to monitor an aspect of the operating system without a user logging on. <Correct>

Explanation :Services run in the background without requiring a user to log on. Therefore, they are perfect for monitoring the operating system or responding to events.

Services are not run directly by users.

Services can start automatically when the computer starts. To have an assembly start automatically when a user logs on, simply add a shortcut to the application to the user's Startup group.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Implement, install, and control a service. (Refer System.ServiceProcess namespace) Inherit from ServiceBase class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 8 - Lesson 3

ServiceController ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.aspx

Introduction to Windows Service ApplicationsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/d56de412.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 13 (536P_5.5.11_01)

_________________________________________________________________________________________________________________

Which of the following identifies the username of the security context in which the current assembly is running? (Choose all that apply.)

1. System.Environment.GetEnvironmentVariable("userdomain")

2. System.Environment.UserDomainName

3. WindowsIdentity.GetCurrent()

4. System.Environment.GetEnvironmentVariable("username") <Correct>

5. System.Environment.UserName <Correct>

Explanation :You can retrieve the current username with System.Environment.UserName or System.Environment.GetEnvironmentVariable("username"). Of those two, you should choose System.Environment.UserName whenever possible.

System.Environment.UserDomainName retrieves the domain name.

WindowsIdentity.GetCurrent() retrieves both the domain and login name.

System.Environment.GetEnvironmentVariable("userdomain") retrieves the domain name.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Control permissions for resources by using the System.Security.Permission classes. (Refer System.Security.Permission namespace) EnvironmentPermission class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 3

Environment ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.environment.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 14 (536P_4.5.1_02)

_________________________________________________________________________________________________________________

Which of the following data types does the FileStream.Write method support?

1. Byte array <Correct>

2. String

3. Integer

4. Boolean

Explanation :FileStream.Write only supports byte arrays. To write other types, create a Writer class based on the FileStream object, such as StreamWriter, BinaryWriter, or TextWriter.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Manage byte streams by using Stream classes. (Refer System.IO namespace) FileStream class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 2

FileStream.Write MethodMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/system.io.filestream.write.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 15 (536P_1.1.4_01)

_________________________________________________________________________________________________________________

Which of the following is an accurate description of generics?

1. A type from one assembly that is moved into another assembly so that it is not necessary to recompile clients that consume the first assembly.

2. A class that uses placeholders for one or more of the types it uses. <Correct>

3. An error condition or unexpected behavior encountered by an executing program that causes normal execution to be halted.

4. A type that stores a pointer to the data, rather than the actual data.

Explanation :Generics use placeholders for their types, which allow multiple types of objects to be used as a parameter.

Exceptions are error conditions that cause normal execution to be halted.

Type forwarding enables moving a type from one assembly into another assembly without requiring recompiling.

Reference types store a pointer to the data, rather than the actual data.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Generic types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

Overview of Reflection and GenericsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms172334.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 16 (536P_3.2.8_04)

_________________________________________________________________________________________________________________

You recently accepted a new job as an internal application developer, replacing a developer who recently moved on. Your manager has asked you to troubleshoot a problem with one of the internally developed applications that the support desk was unable to resolve. According to the support desk notes, the internal application no longer works for the user. During the troubleshooting process, the support desk determined that the application lacked sufficient privileges to run, but the support desk could not identify which permission sets applied to the assembly.

The application is based on the .NET Framework 2.0. After opening the .NET Framework 2.0 Configuration tool, where would you click to identify the permission sets that apply to the assembly?

In the illustration, click on the node you should use to view permission sets.

Explanation :You should use the Runtime Security Policy node. The .NET Framework 2.0 Configuration tool gives you the ability to evaluate code groups and permission sets that apply to an assembly. This is especially critical in Active Directory environments, where policy can be applied at the enterprise, machine, and user levels.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Create a custom Microsoft Windows Installer for the .NET Framework components by using the System.Configuration.Install namespace, and configure the .NET Framework applications by using configuration files, environment variables, and the .NET Framework Configuration tool (Mscorcfg.msc).). Configure a .NET Framework application by using the .NET Framework Configuration tool (Mscorcfg.msc).

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 2

.NET Framework Configuration Tool (Mscorcfg.msc)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/2bc0cxhc.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 17 (536P_7.3.1_01)

_________________________________________________________________________________________________________________

Which of the following code samples is the most efficient and compiles correctly?

1. ' VBDim s As String = Nothings = "Hello"s += ", "s += "World"s += "!"

// C#string s = null;s = "Hello";s += ", ";s += "World";s += "!";

2. ' VBDim s As String = Nothings = "Hello"s = s + ", "s = s + "World"s = s + "!"

// C#string s = null;s = "Hello";s += ", ";s += "World";s += "!";

3. ' VBDim s As String = NothingDim sb As StringBuilder = Nothingsb.Append("Hello")sb.Append(", ")sb.Append("World")sb.Append("!")s = sb.ToString

// C#string s = null;StringBuilder sb = null;sb.Append("Hello");sb.Append(", ");sb.Append("World");sb.Append("!");s = sb.ToString();

<Correct>

4. ' VBDim s As String = NothingDim sb As StringBuilder = Nothingsb = "Hello"sb += ", "sb += "World"sb += "!"s = sb.ToString

// C#string s = null;StringBuilder sb = null;sb = "Hello";sb += ", ";sb += "World";sb += "!";s = sb.ToString();

Explanation :StringBuilder is more efficient than String when you need to append the string multiple times.

StringBuilder does not accept the = or += operators.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.RegularExpressions namespace) StringBuilder class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

Using the StringBuilder ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/2839d5h5.aspx

StringBuilder ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.text.stringbuilder.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 18 (536P_5.1.3_03)

_________________________________________________________________________________________________________________

Choose the .NET Framework tool appropriate for each task.

From the list on the right, select the tool and associate it with the appropriate task. Place your selections in the list on the left under the appropriate node by clicking the node, clicking the item from the list on the right, and then clicking the arrow button. You will not use items more than once, and you do not have to use each item from the list.

Explanation :The .NET Framework includes dozens of tools to peform different configuration, analysis, and security tasks. Most of these tools are command-line tools, so it is important to know the names of the tools and how they can be used.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement code access security to improve the security of a .NET Framework application. (Refer System.Security namespace) Modify the Code Access security policy at the computer, user, and enterprise policy level by using the Code Access Security Policy tool (Caspol.exe).

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 1

.NET Framework ToolsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms299153(en-us,vs.80).aspx

Code Access Security Policy Tool (Caspol.exe)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/cb6t8dtz(en-US,VS.80).aspx

Permissions View Tool (Permview.exe)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/06251f13(en-US,VS.80).aspx

Strong Name Tool (Sn.exe)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/k5b5tt23(en-US,VS.80).aspx

Isolated Storage Tool (Storeadm.exe)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ezabwsbk(en-US,VS.80).aspx

XML Schema Definition Tool (Xsd.exe)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/x6c1kb0s(en-US,VS.80).aspx

File Signing Tool (Signcode.exe)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/9sh96ycy(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 19 (536P_1.1.1_06)

_________________________________________________________________________________________________________________

Which of the following values could be stored in an instance of the ushort type? (Choose all that apply.)

1. -76,234

2. -48,000

3. 34,210 <Correct>

4. 127,236

5. -12

6. 16,633 <Correct>

Explanation :The ushort type can only store values between 0 and 65,535.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Value types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 1

.NET Framework Class Library OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/hfa3fa08.aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 20 (536P_5.4.17_02)

_________________________________________________________________________________________________________________

You are writing an assembly that implements custom authentication. You need to store user authentication information in a database. How should you store this information to enable you to validate passwords later, while minimizing the risk that an attacker who gains access to the database can use that information to determine a user's original unencrypted password?

1. Store hashes of the passwords. <Correct>

2. Store the passwords with digital signatures.

3. Encrypt the passwords using symmetric encryption.

4. Encrypt the passwords using asymmetric encryption.

Explanation :You should store hashes of the passwords. A keyed hashing algorithm would be more secure than a nonkeyed algorithm.

Storing passwords with digital signatures would allow you to determine whether a password had been tampered with. However, it would not prevent an attacker from determining the original password.

Encrypting passwords with symmetric encryption would provide strong security. However, because the original passwords could be derived if the attacker gained access to the encryption key, it is less secure than storing hashes of the passwords.

Encrypting passwords with asymmetric encryption would provide strong security. However, because the original passwords could be derived if the attacker gained access to the private key, it is less secure than storing hashes of the passwords.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace) Hash-based Message Authentication Code (HMAC)

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 3

Cryptography OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/92f9ye3s.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 21 (536P_5.6.6_02)

_________________________________________________________________________________________________________________

Place the security policy levels in order from highest to lowest.

From the list on the right, select valid policy levels. Place your selections in the list on the left in order from highest to lowest. Place your selections in the list on the left by clicking the items in the list on the right and clicking the arrow. You can also use the Up and Down buttons to rearrange items in the list on the left. You might not need to use all the items from the list on the right.

Explanation :The highest level of security policy is enterprise-wide. Successive lower levels of hierarchy represent further policy restrictions, but they can never grant more permissions than allowed by higher levels. The following policy levels are implemented:

1. Enterprise: security policy for all managed code in an enterprise.2. Machine: security policy for all managed code that is run on the computer.3. User: security policy for all managed code that is run by the user.4. Application domain: security policy for all managed code in an application.

There is no Application policy level.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Control code privileges by using System.Security.Policy classes. (Refer System.Security.Policy namespace) PolicyLevel class and PolicyStatement class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 1

PolicyLevel ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-US/library/system.security.policy.policylevel.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 22 (536P_5.7.2_02)

_________________________________________________________________________________________________________________

You are creating a system service, and you are very concerned about security. You have created an install project that installs your service as a user with limited privileges; however, it is possible for an administrator to modify the service configuration to cause it to run as System. You would like to test whether the service is running as System and add an event to the event log if necessary.

How can you determine whether the service is running as System?

1. WindowsIdentity.GetCurrent().IsService

2. WindowsIdentity.GetCurrent().IsSystem <Correct>

3. WindowsIdentity.GetCurrent().IsGuest

4. WindowsIdentity.GetCurrent().IsAuthenticated

Explanation :WindowsIdentity.GetCurrent().IsSystem is a Boolean value that will be true if the service is running as System.

WindowsIdentity.GetCurrent().IsService does not exist.

You cannot use WindowsIdentity.GetCurrent().IsGuest to determine whether the current security context is part of the system.

You cannot use WindowsIdentity.GetCurrent().IsAuthenticated to determine whether the current security context is part of the system.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Access and modify identity information by using the System.Security.Principal classes. (Refer System.Security.Principal namespace) WindowsIdentity class and WindowsPrincipal class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 1

WindowsIdentity ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.principal.windowsidentity.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 23 (536P_6.4.1_01)

_________________________________________________________________________________________________________________

Which of the following code samples correctly creates an SMTP message addressed to both [email protected] and [email protected]? (Choose all that apply.)

1. ' VBPrivate m As MailMessage = New MailMessage("[email protected]", "[email protected]; [email protected]", "Alert", "Server has failed")

// C#MailMessage m = new MailMessage("[email protected]", "[email protected]; [email protected]", "Alert", "Server has failed");

<Correct>

2. ' VBPrivate m As MailMessage = New MailMessage("[email protected]", "[email protected], [email protected]", "Alert", "Server has failed")

// C#MailMessage m = new MailMessage("[email protected]", "[email protected], [email protected]", "Alert", "Server has failed");

<Correct>

3. ' VBPrivate m As MailMessage = New MailMessage("[email protected]", "[email protected]", "[email protected]", "Alert", "Server has failed")

// C#MailMessage m = new MailMessage("[email protected]", "[email protected]", "[email protected]", "Alert", "Server has failed");

4. ' VBPrivate m As MailMessage = New MailMessage("[email protected]", "[email protected]", "[email protected]", "Alert", "Server has failed")

// C#MailMessage m = new MailMessage("[email protected]", "[email protected]", "[email protected]", "Alert", "Server has failed");

Explanation :The MailMessage constructor accepts the To addresses as the second string. To supply multiple addresses, include them in a single string and separate the addresses by commas.

Though other development environments use semi-colons to separate e-mail addresses, the .NET Framework requires commas.

You cannot provide To e-mail addresses as separate parameters.

The From e-mail address must be the first parameter. Additionally, you cannot provide To e-mail addresses as separate parameters.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery from a .NET Framework application. (Refer System.Net.Mail namespace) MailMessage class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 15 - Lesson 1

MailMessage ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/8t22a8ww(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 24 (536P_3.4.4_02)

_________________________________________________________________________________________________________________

You are writing a single-threaded application that performs custom performance logging to enable users to use the Performance console to track the current number of users who have connected to your application. Which method should you call when a user connects?

1. PerformanceCounter.RawValue <Correct>

2. PerformanceCounter.Increment

3. PerformanceCounter.Decrement

4. PerformanceCounter.IncrementBy

Explanation :PerformanceCounter.RawValue offers the best performance in single-threaded applications.

PerformanceCounter.Decrement works well in multi-threaded environments. However, PerformanceCounter.RawValue offers the best performance in single-threaded applications.

You could call PerformanceCounter.Increment; however, PerformanceCounter.RawValue offers much better performance in single-threaded applications. If the application were multithreaded, you would use PerformanceCounter.Increment instead.

You could call PerformanceCounter.IncrementBy; however, PerformanceCounter.RawValue offers much better performance in single-threaded applications. Additionally, because you are only adding a single user, you could use PerformanceCounter.Increment.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Manage system processes and monitor the performance of a .NET Framework application by using the diagnostics functionality of the .NET Framework 2.0. (Refer System.Diagnostics namespace) PerformanceCounter class, PerformanceCounterCategory, and CounterCreationData class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 3

PerformanceCounter ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.performancecounter.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 25 (536P_3.6.1_02)

_________________________________________________________________________________________________________________

As a favor to your IT department, you are writing a console application that outputs information related to the security of the current computer. Which of the following code samples correctly displays running services?

1. ' VBDim oq As New ObjectQuery("SELECT Caption FROM Win32_Service WHERE Started = FALSE")

Dim mos As New ManagementObjectSearcher(oq)Dim moc As ManagementObjectCollection = mos.Query

For Each mo As ManagementObject In moc Console.WriteLine(mo("Caption").ToString())Next

// C#ObjectQuery oq = new ObjectQuery("SELECT Caption FROM Win32_Service WHERE Started = FALSE");

ManagementObjectSearcher mos = new ManagementObjectSearcher(oq);ManagementObjectCollection moc = mos.Query();

foreach (ManagementObject mo in moc) Console.WriteLine(mo["Caption"]);

2. ' VBDim oq As New ObjectQuery("SELECT Caption FROM Win32_Service WHERE Started = TRUE")

Dim mos As New ManagementObjectSearcher(oq)Dim moc As ManagementObjectCollection = mos.Get

For Each mo As ManagementObject In moc Console.WriteLine(mo("Caption").ToString())Next

// C#ObjectQuery oq = new ObjectQuery("SELECT Caption FROM Win32_Service WHERE Started = TRUE");

ManagementObjectSearcher mos = new ManagementObjectSearcher(oq);ManagementObjectCollection moc = mos.Get();

foreach (ManagementObject mo in moc) Console.WriteLine(mo["Caption"]);

<Correct>

3. ' VBDim oq As New ObjectQuery("SELECT Caption FROM Win32_Service WHERE Started = FALSE")

Dim mos As New ManagementObjectSearcher(oq)Dim moc As ManagementObjectCollection = mos.Get

For Each mo As ManagementObject In moc Console.WriteLine(mo("Caption").ToString())Next

// C#ObjectQuery oq = new ObjectQuery("SELECT Caption FROM Win32_Service WHERE Started = FALSE");

ManagementObjectSearcher mos = new ManagementObjectSearcher(oq);ManagementObjectCollection moc = mos.Get();

foreach (ManagementObject mo in moc) Console.WriteLine(mo["Caption"]);

4. ' VBDim oq As New ObjectQuery("SELECT Caption FROM Win32_Service WHERE Started = TRUE")

Dim mos As New ManagementObjectSearcher(oq)

Dim moc As ManagementObjectCollection = mos.Query

For Each mo As ManagementObject In moc Console.WriteLine(mo("Caption").ToString())Next

// C#ObjectQuery oq = new ObjectQuery("SELECT Caption FROM Win32_Service WHERE Started = TRUE");

ManagementObjectSearcher mos = new ManagementObjectSearcher(oq);ManagementObjectCollection moc = mos.Query();

foreach (ManagementObject mo in moc) Console.WriteLine(mo["Caption"]);

Explanation :To query running services:

1. Create an instance of ObjectQuery using a Windows Management Instrumentation (WMI) query. The WMI query must be in the form "SELECT fields FROM Win32_Service WHERE criteria". In this case, the criteria must be "WHERE Started = True" to return services that have started.2. Create an instance of ManagementObjectSearcher based on the query.3. Next, create an instance of ManagementObjectCollection by calling the ManagementObjectSearcher.Get method.

You can then iterate through the ManagementObjects in the ManagementObjectCollection to examine individual services.

ManagementObjectSearcher.Query is a property used to define the query; it is not a method. You must use ManagementObjectSearcher.Get to run a query.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Embed management information and events into a NET Framework application. (Refer System.Management namespace) Retrieve a collection of Management objects by using the ManagementObjectSearcher class and its derived classes.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 4

ManagementObjectSearcher ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.management.managementobjectsearcher.aspx

ObjectQuery ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.management.objectquery(VS.80).aspx

ManagementObjectCollection ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.management.managementobjectcollection.aspx

WMI .NET OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms257340(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 26 (536P_3.2.1_05)

_________________________________________________________________________________________________________________

You are creating a custom uninstaller manually rather than using the Microsoft Visual Studio tools to automatically generate an installer and uninstaller.

From the list on the right, select the tasks that you should perform to correctly uninstall an application. Place your selections in the list on the left in the order in which the tasks should be performed. Place your selections in the list on the left by clicking the items in the list on the right and clicking the arrow. You can also use the Up and Down buttons to rearrange items in the list on the left. You might not need to use all the items from the list on the right.

Explanation :To uninstall the installation, only the following tasks need to be done:

1. Create a new AssemblyInstaller or ComponentInstaller object.2. Specify the name of the assembly or application.3. Call the Uninstall method.

The Rollback method is used to cancel an installation that is in progress before it is committed. The Commit method finalizes an installation.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Create a custom Microsoft Windows Installer for the .NET Framework components by using the System.Configuration.Install namespace, and configure the .NET Framework applications by using configuration files, environment variables, and the .NET Framework Configuration tool (Mscorcfg.msc).). Installer class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 2

Installer ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.configuration.install.installer.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 27 (536P_4.1.1_06)

_________________________________________________________________________________________________________________

You are writing an application that uses serialization, and you need complete control over how the serialized data is formatted. Which of the following interfaces should you implement?

1. ISerializable

2. IDeserializationCallback

3. IFormatter <Correct>

4. IFormatterConverter

Explanation :You should implement the IFormatter interface, which is the same interface that BinaryFormatter and SoapFormatter implement.

IFormatterConverter includes methods for converting values between core types, such as converting a Decimal to a Double or a signed integer to an unsigned integer. You typically do not need to implement the IFormatterConverter interface when using serialization.

You should implement ISerializable when you need to control the serialization process, but not when you need to control the formatting of the actual serialized data.

You should implement IDeserializationCallback when you need to calculate the value of a member after deserialization. You cannot control formatting with IDeserializationCallback.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) Serialization interfaces

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 1

IFormatter InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.iformatter.aspx

Basic SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/4abbf6k0.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 28 (536P_4.7.2_03)

_________________________________________________________________________________________________________________

You are working with your IT department to deploy an application that you wrote. The IT department asks if your application needs access to any folders on the local hard disk. Your application only uses isolated storage. Your application will be deployed only to Microsoft Windows XP computers that had been upgraded from Windows 2000. Your IT department does use roaming profiles.

To which folder does your application require access?

1. <systemdrive>\Documents and Settings\<user>\ Local Settings\Application Data

2. <systemroot>\Profiles\<user>\Application Data

3. <systemroot>\Application Data

4. <systemroot>\Documents and Settings\<user>\Application Data <Correct>

Explanation :The <systemroot>\Documents and Settings\<user>\Application Data folder is used by Windows XP when upgraded from Windows 2000 in environments that use roaming profiles.

On Windows XP computers that were not upgraded and do not use roaming profiles, isolated storage is physically located in the <systemdrive>\Documents and Settings\<user>\ Local Settings\Application Data folder.

The <systemroot>\Profiles\<user>\Application Data folder is used by Windows 2000, Windows XP, and Windows Server 2003 when upgraded from Windows NT 4.0 in environments that use roaming profiles.

The <systemroot>\Application Data folder is used by Microsoft Windows 98 and Windows ME without user profiles.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Compress or decompress stream information in a .NET Framework application (refer System.IO.Compression namespace), and improve the security of application data by using isolated storage. (Refer System.IO.IsolatedStorage namespace) IsolatedStorageFileStream class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 4

Introduction to Isolated StorageMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/3ak841sy.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 29 (536P_2.3.5_02)

_________________________________________________________________________________________________________________

Which of the following launches an assembly with minimal privileges?

1. ' VBDim z As Object() = {New Zone (SecurityZone.Internet)}Dim e As Evidence = New Evidence (z, Nothing)Dim d As AppDomain = AppDomain.CreateDomain("MyDomain")d.ExecuteAssembly("Assembly.exe", e)

// C#object [] z = {new Zone(SecurityZone.Internet)};Evidence e = new Evidence(z, null);AppDomain d = AppDomain.CreateDomain("MyDomain");d.ExecuteAssembly("Assembly.exe", e);

<Correct>

2. ' VBDim z As Object() = {New Zone (SecurityZone.Trusted)}Dim e As Evidence = New Evidence (z, Nothing)Dim d As AppDomain = AppDomain.CreateDomain("MyDomain")d.ExecuteAssembly("Assembly.exe", e)

// C#object [] z = {new Zone(SecurityZone.Trusted)};Evidence e = new Evidence(z, null);AppDomain d = AppDomain.CreateDomain("MyDomain");d.ExecuteAssembly("Assembly.exe", e);

3. ' VBDim z As Object() = {New Zone (SecurityZone.MyComputer)}Dim e As Evidence = New Evidence (z, Nothing)Dim d As AppDomain = AppDomain.CreateDomain("MyDomain")d.ExecuteAssembly("Assembly.exe", e)

// C#object [] z = {new Zone(SecurityZone.MyComputer)};Evidence e = new Evidence(z, null);AppDomain d = AppDomain.CreateDomain("MyDomain");d.ExecuteAssembly("Assembly.exe", e);

4. ' VBDim z As Object() = {New Zone (SecurityZone.Intranet)}Dim e As Evidence = New Evidence (z, Nothing)Dim d As AppDomain = AppDomain.CreateDomain("MyDomain")d.ExecuteAssembly("Assembly.exe", e)

// C#object [] z = {new Zone(SecurityZone.Intranet)};Evidence e = new Evidence(z, null);AppDomain d = AppDomain.CreateDomain("MyDomain");d.ExecuteAssembly("Assembly.exe", e);

Explanation :When launching an assembly within an application domain, you can provide evidence to affect the privileges the runtime provides to the assembly. The Internet zone provides only minimal privileges.

The MyComputer, Intranet, and Trusted security zones provide more privileges than the other zones. Therefore, the security risks would be higher.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Create a unit of isolation for common language runtime in a .NET Framework application by using application domains. (Refer System namespace) Load assemblies into an application domain.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 8 - Lesson 1

EvidenceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/7y5x1hcd.aspx

AppDomain ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.appdomain.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 30 (536P_4.2.2_01)

_________________________________________________________________________________________________________________

Given the following class, which of the following files represents how an instance of that class would be serialized using the XmlSerializer class?

' VBPublic Class ShoppingCartItem Public productId As Int32 Public price As Decimal Public quantity As Int32 Public total As Decimal

Public Sub New() MyBase.New End SubEnd Class

// C#public class ShoppingCartItem { public Int32 productId; public decimal price; public Int32 quantity; public decimal total;

public ShoppingCartItem() { }}

1. <?xml version="1.0" ?> <ShoppingCartItem productId="100" price="10.25" quantity="2" total="20.50"></ShoppingCartItem>

2. <?xml version="1.0" ?> <ShoppingCartItem> <productId>100</productId> <price>10.25</price> <quantity>2</quantity> </ShoppingCartItem>

3. <?xml version="1.0" ?> <ShoppingCartItem> <productId>100</productId> <price>10.25</price> <quantity>2</quantity> <total>20.50</total> </ShoppingCartItem>

<Correct>

4. <?xml version="1.0" ?> <productId>100</productId> <price>10.25</price> <quantity>2</quantity> <total>20.50</total>

Explanation :By default, XmlSerializer serializes all members as XML elements.

XmlSerializer serializes members as attributes only if each member has the XmlAttribute attribute.

XmlSerializer would ignore the total member only if it had the XmlIgnore attribute.

XmlSerializer creates an element for the class and makes each member a subelement within the class element.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Control the serialization of an object into XML format by using the System.Xml.Serialization namespace. Control serialization by using serialization attributes.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 2

Basic SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/4abbf6k0.aspx

XmlSerializer ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx

Introducing XML SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/182eeyhh.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 31 (536P_7.2.1_03)

_________________________________________________________________________________________________________________

Which of the following code samples draws this graphic?

1. ' VBDim i As Image = Image.FromFile("C:\Windows\Rhododendron.bmp")Dim b As New HatchBrush(i)Dim bm As Bitmap = New Bitmap(400, 400)Dim g As Graphics = Graphics.FromImage(bm)g.FillEllipse(b, 0, 0, 400, 400)

// C#Image i = Image.FromFile(@"C:\Windows\Rhododendron.bmp");TextureBrush b = new HatchBrush(i);Bitmap bm = new Bitmap(400, 400);Graphics g = Graphics.FromImage(bm);g.FillEllipse(b, 0, 0, 400, 400);

2. ' VBDim i As Image = Image.FromFile("C:\Windows\Rhododendron.bmp")Dim b As New TextureBrush(i)Dim bm As Bitmap = New Bitmap(400, 400)Dim g As Graphics = Graphics.FromImage(bm)g.FillEllipse(b, 0, 0, 400, 400)

// C#Image i = Image.FromFile(@"C:\Windows\Rhododendron.bmp");TextureBrush b = new TextureBrush(i);Bitmap bm = new Bitmap(400, 400);Graphics g = Graphics.FromImage(bm);g.FillEllipse(b, 0, 0, 400, 400);

<Correct>

3. ' VBDim i As Image = Image.FromFile("C:\Windows\Rhododendron.bmp")Dim b As New HatchBrush(i)Dim bm As Bitmap = New Bitmap(400, 400)Dim g As Graphics = Graphics.FromImage(bm)g.FillCircle(b, 0, 400)

// C#Image i = Image.FromFile(@"C:\Windows\Rhododendron.bmp");TextureBrush b = new HatchBrush(i);Bitmap bm = new Bitmap(400, 400);Graphics g = Graphics.FromImage(bm);g.FillCircle(b, 0, 400);

4. ' VBDim i As Image = Image.FromFile("C:\Windows\Rhododendron.bmp")Dim b As New TextureBrush(i)Dim bm As Bitmap = New Bitmap(400, 400)Dim g As Graphics = Graphics.FromImage(bm)g.FillCircle(b, 0, 400)

// C#Image i = Image.FromFile(@"C:\Windows\Rhododendron.bmp");TextureBrush b = new TextureBrush(i);Bitmap bm = new Bitmap(400, 400);Graphics g = Graphics.FromImage(bm);g.FillCircle(b, 0, 400);

Explanation :To create the graphic, you must use a TextureBrush and call the Graphics.FillEllipse method.

The Graphics class does not have a FillCircle method. Instead, you must call Graphics.FillEllipse.

The HatchBrush creates a fill pattern with a hatch shape; it does not use the pattern shown in the

sample image. Because of this, you cannot create a HatchBrush object using an Image instance.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the user interface of a .NET Framework application by using the System.Drawing namespace. Enhance the user interface of a .NET Framework application by using brushes, pens, colors, and fonts.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 6 - Lesson 1

How to: Fill a Shape with an Image TextureMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/sssaxczh.aspx

TextureBrush Constructor (Image)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/1a11ydhc.aspx

Graphics.FillEllipse Method (Brush, Int32, Int32, Int32, Int32)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/2t63kk0t.aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 6 - Lesson 3

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 32 (536P_5.4.5_01)

_________________________________________________________________________________________________________________

Which of the following classes provide symmetric encryption? (Choose all that apply.)

1. TripleDES <Correct>

2. RSACryptoServiceProvider

3. DSACryptoServiceProvider

4. RijndaelManaged <Correct>

5. DES<Correct>

6. RC2<Correct>

Explanation :RijndaelManaged, DES, RC2, and TripleDES are all symmetric encryption classes.

DSACryptoServiceProvider provides asymmetric digital signatures.

RSACryptoServiceProvider provides asymmetric encryption.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace) TripleDES and TripleDESCryptoServiceProvider class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 3

Cryptography OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/92f9ye3s.aspx

SymmetricAlgorithm ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.cryptography.symmetricalgorithm.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 33 (536P_1.2.9_01)

_________________________________________________________________________________________________________________

Which of the following collections can be accessed by a key? (Choose all that apply.)

1. An implementation of IDictionary <Correct>

2. SortedList <Correct>

3. An implementation of IList

4. Queue

5. BitArray

Explanation :Both SortedList and an implemention of IDictionary can be accessed by using a key.

An implementation of IList cannot be accessed by a key. Lists are accessed by an index.

Elements of a BitArray collection are accessed by using an integer index.

Elements of a Queue collection are accessed in first-in, first-out order.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage a group of associated data in a .NET Framework application by using collections. (Refer System.Collections namespace) SortedList class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 4 - Lesson 3

SortedList ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.collections.sortedlist.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 34 (536P_7.3.5_03)

_________________________________________________________________________________________________________________

Which of the following code samples correctly displays all supported code pages?

1. ' VBDim ei As Encoding() = Encoding.GetEncodingsFor Each e As Encoding In ei Console.WriteLine("{0}: {1}, {2}", e.CodePage, e.Name, e.DisplayName)Next

// C#Encoding[] ei = Encoding.GetEncodings();foreach (Encoding e in ei) Console.WriteLine("{0}: {1}, {2}", e.CodePage, e.Name, e.DisplayName);

2. ' VBDim ei As Encoding() = EncodingInfo.GetEncodingsFor Each e As Encoding In ei Console.WriteLine("{0}: {1}, {2}", e.CodePage, e.Name, e.DisplayName)Next

// C#Encoding[] ei = EncodingInfo.GetEncodings();foreach (Encoding e in ei) Console.WriteLine("{0}: {1}, {2}", e.CodePage, e.Name, e.DisplayName);

3. ' VBDim ei As EncodingInfo() = Encoding.GetEncodingsFor Each e As EncodingInfo In ei Console.WriteLine("{0}: {1}, {2}", e.CodePage, e.Name, e.DisplayName)Next

// C#EncodingInfo[] ei = Encoding.GetEncodings();foreach (EncodingInfo e in ei) Console.WriteLine("{0}: {1}, {2}", e.CodePage, e.Name, e.DisplayName);

<Correct>

4. ' VBDim ei As EncodingInfo() = Encoding.GetEncodingFor Each e As EncodingInfo In ei Console.WriteLine("{0}: {1}, {2}", e.CodePage, e.Name, e.DisplayName)Next

// C#EncodingInfo[] ei = Encoding.GetEncoding();foreach (EncodingInfo e in ei) Console.WriteLine("{0}: {1}, {2}", e.CodePage, e.Name, e.DisplayName);

Explanation :To retrieve a list of supported code types, call the Encoding.GetEncodings method. This method returns an array of EncodingInfo objects.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.RegularExpressions namespace) Encode text by using Encoding classes.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, Microsoft

Chapter 3 - Lesson 2

Encoding.GetEncodings MethodMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-US/library/system.text.encoding.getencodings.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 35 (536P_2.1.2_02)

_________________________________________________________________________________________________________________

Which of the following commands would pause a service named Server?

1. SERVICECONTROLLER PAUSE SERVER

2. NET STOP SERVER

3. NET PAUSE SERVER <Correct>

4. SERVICECONTROLLER STOP SERVER

Explanation :You can use the Net command-line tool to start, stop, pause, or continue a service.

ServiceController is a .NET Framework class. It is not a command-line tool.

Stopping and pausing a service are different tasks. Typically, stopping a service disconnects all connections and terminates all processes, while pausing a service simply stops new activity from starting while allowing existing actions to continue.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Implement, install, and control a service. (Refer System.ServiceProcess namespace) ServiceController class and ServiceControllerPermission class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 8 - Lesson 3

Start, stop, pause, resume, or restart a serviceMicrosoft TechNet, MicrosoftLink: http://www.microsoft.com/technet/prodtechnol/windowsserver2003/library/ServerHelp/03928250-2796-4253-8fb1-b25329ddf35f.mspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 36 (536P_4.2.1_01)

_________________________________________________________________________________________________________________

Which classes can you use when serializing data to be consumed by applications running on a UNIX-based operating system? (Choose all that apply.)

1. XmlSerializer <Correct>

2. BinaryFormatter

3. SoapFormatter <Correct>

4. ISerializable

5. SerializationBinder

Explanation :Both SoapFormatter and XmlSerializer serialize data using open standards that other platforms can consume.

BinaryFormatter provides very efficient serialization, but it is not open-standards based.

ISerializable is an interface that you can use to implement custom serialization. You cannot use it directly to perform serialization.

SerializationBinder allows users to control class loading and mandate what class to load. You cannot use it to perform serialization.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Control the serialization of an object into XML format by using the System.Xml.Serialization namespace. Serialize and deserialize objects into XML format by using the XmlSerializer class.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 2

Basic SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/4abbf6k0.aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 3

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 37 (536P_1.1.5_05)

_________________________________________________________________________________________________________________

You need to validate a phone number passed to your class as a parameter. What is the most effective way to verify that the format of the data matches a phone number?

1. Nested If statements

2. A Try/Catch block

3. Test the String.Length value

4. Regular expressions<Correct>

Explanation :Regular expressions are the most effective way to verify that the format of a string parameter meets your requirements.

Although you can use nested If statements to perform the same checks as a regular expression, it would be less efficient and more error-prone.

You should throw an exception if you determine that a parameter contains an invalid value. However, you cannot use a Try/Catch block to test a parameter.

You should check the String.Length value to test strings; however, the length of a phone number can vary. Therefore, regular expressions are a more effective way to validate phone numbers.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Exception classes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

Validating User InputMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms172105.aspx

Regular Expression ClassesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/30wbz966.aspx

Regex ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 38 (536P_4.4.5_03)

_________________________________________________________________________________________________________________

You are developing version 2.0 of your application. One of the changes you are making is to change the file extension of a configuration settings file from .txt to .dat. The contents of the file do not need to change--just the file extension itself. In the following code samples, the current path and filename are stored in the String named "sn". Which of the following is the most reliable way to change the file extension?

1. ' VBFile.Move(sn, Path.ChangeExtension(sn, "dat"))

// C#File.Move(sn, Path.ChangeExtension(sn, "dat"));

<Correct>

2. ' VBFile.Move(sn, sn.Replace("txt", "dat"))

// C#File.Move(sn, sn.Replace("txt", "dat"));

3. ' VBPath.ChangeExtension(sn, "dat")

// C#Path.ChangeExtension(sn, "dat");

4. ' VBFile.Move(sn, "*.dat")

// C#File.Move(sn, "*.dat");

Explanation :Combining the static File.Move method with the static Path.ChangeExtension method is the most efficient and reliable way to change the extension of a file.

Path.ChangeExtension does not directly make changes to the file system.

Providing a wildcard to the File.Move method results in an exception because the destination path includes an illegal character.

Using String.Replace to change the extension would work in most circumstances. However, if the filename included another occurrence of "txt" (for example, if the file were named "mytxt.txt"), both occurrences of "txt" would be changed.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Access files and folders by using the File System classes. (Refer System.IO namespace) Path class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 1

Path ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/3bdzys9w(en-US,VS.80).aspx

File.Move MethodMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.io.file.move.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 39 (536P_1.2.8_01)

_________________________________________________________________________________________________________________

Which of the following is a first-in, first-out collection?

1. Queue <Correct>

2. List

3. Stack

4. Hashtable

Explanation :The Queue class is a first-in, first-out collection.

The Stack collection is a last-in, first-out collection.

The List class does not support ordered retrieval.

The Hashtable class does not support ordered retrieval.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage a group of associated data in a .NET Framework application by using collections. (Refer System.Collections namespace) Queue class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 4 - Lesson 2

Queue Generic ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/7977ey2c.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 40 (536P_6.3.3_04)

_________________________________________________________________________________________________________________

You are using reflection to load and run an assembly. You need to respond to an event initiated within the loaded assembly.

From the list on the right, select the tasks that you should perform to respond to an event by using reflection. Place your selections in the list on the left in the order in which the tasks should be performed. Place your selections in the list on the left by clicking the items in the list on the right and clicking the arrow. You can also use the Up and Down buttons to rearrange items in the list on the left. You might not need to use all the items from the list on the right.

Explanation :When you use reflection to load and run assemblies, you cannot use language features such as the C# += operator or the Visual Basic AddHandler keyword to hook up events. Instead, you must get all the necessary types through reflection.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Implement reflection functionality in a .NET Framework application (refer System.Reflection namespace), and create metadata, Microsoft intermediate language (MSIL), and a PE file by using the System.Reflection.Emit namespace. Info classes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 14 - Lesson 3

How to: Hook Up a Delegate Using ReflectionMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms228976(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 41 (536P_1.1.1_04)

_________________________________________________________________________________________________________________

Which of the following types could store the numeric value 1.23? (Choose all that apply.)

1. ulong

2. int

3. double <Correct>

4. uint

5. long

6. decimal <Correct>

7. float <Correct>

Explanation :The types decimal, double, and float can each store fractional numbers.

The types int, long, uint, and ulong can only store integers.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Value types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 1

.NET Framework Class Library OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/hfa3fa08.aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 42 (536P_5.5.2_01)

_________________________________________________________________________________________________________________

Which of the following code samples imperatively demands that the current user is a member of the local Users group? (Choose all that apply.)

1. ' VBDim myPerm As PrincipalPermission = New PrincipalPermission(Nothing, "BUILTIN\Users", True)myPerm.Demand()

// C#PrincipalPermission myPerm = new PrincipalPermission(null, @"BUILTIN\Users", true);myPerm.Demand();

2. ' VBDim myPerm As PrincipalPermission = New PrincipalPermission(Nothing, "Users", True)myPerm.Demand()

// C#PrincipalPermission myPerm = new PrincipalPermission(null, @"Users", true);myPerm.Demand();

3. ' VBSystem.AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal)Dim myPerm As PrincipalPermission = New PrincipalPermission(Nothing, "Users", True)myPerm.Demand()

// C#System.AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);PrincipalPermission myPerm = new PrincipalPermission(null, @"Users", true);myPerm.Demand();

<Correct>

4. ' VBSystem.AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal)Dim myPerm As PrincipalPermission = New PrincipalPermission(Nothing, "BUILTIN\Users", True)myPerm.Demand()

// C#System.AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);PrincipalPermission myPerm = new PrincipalPermission(null, @"BUILTIN\Users", true);myPerm.Demand();

<Correct>

Explanation :To perform an imperative security demand for membership in a built-in Microsoft Windows group, you must first set the default principal policy to the Windows principal by calling SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal). Then construct a PrincipalPermission object specifying the group name. To specify the group name, you can provide just the group name, or you can preface the group name with either "BUILTIN\" or the computer name and a backslash. Finally, call the PrincipalPermission.Demand method.

If you do not set the principal policy to the Windows principal by calling SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal), imperative security checks will fail.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Control permissions for resources by using the System.Security.Permission classes. (Refer System.Security.Permission namespace) PrincipalPermission class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 3

PrincipalPermission ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.permissions.principalpermission.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 43 (536P_7.1.3_03)

_________________________________________________________________________________________________________________

You are creating a Windows Service. Which of the following security contexts should you specify for the Account property to authenticate using an Active Directory username and password?

1. LocalSystem

2. NetworkService

3. User<Correct>

4. LocalService

Explanation :User causes the system to prompt for a valid user name and password when the service is installed, and it runs in the context of an account specified by a single user on the network.

LocalService runs in the context of an account that acts as a nonprivileged user on the local computer, and it presents anonymous credentials to any remote server.

LocalSystem runs in the context of an account that provides extensive local privileges, and it presents the computer's credentials to any remote server.

NetworkService runs in the context of an account that acts as a nonprivileged user on the local computer, and it presents the computer's credentials (not a specific user's credentials) to any remote server.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Format data based on culture information. (Refer System.Globalization namespace) Format number values based on the culture.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 16 - Lesson 1

How to: Specify the Security Context for ServicesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/0x72fzyf(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 44 (536P_1.2.2_02)

_________________________________________________________________________________________________________________

You are creating a new collection type that must be sorted by using Array.Sort. Which of the following interfaces should you implement?

1. IComparer <Correct>

2. IEqualityComparer

3. ICollection

4. IDictionary

Explanation :Use the IComparer interface for collections that must be sorted.

The ICollection interface is the base interface for classes in the System.Collections namespace. It does not support sorting.

The IDictionary interface is the base interface for nongeneric collections of key/value pairs. It does not support sorting.

The IEqualityComparer interface supports only equality comparisons.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage a group of associated data in a .NET Framework application by using collections. (Refer System.Collections namespace) Collection interfaces

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 4 - Lesson 3

Array.Sort MethodMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.array.sort.aspx

IComparer InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/twxabsb7(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 45 (536P_1.1.2_02)

_________________________________________________________________________________________________________________

Which of the following is a valid interface declaration?

1. ' VBInterface IAsset Function SampleMethod() as IntegerEnd Interface

// C#interface ISampleInterface{ int SampleMethod();} <Correct>

2. ' VBInterface IAsset(j as Integer) Function SampleMethod() as IntegerEnd Interface

// C#interface ISampleInterface(int j){ int SampleMethod();}

3. ' VBInterface IAsset Private j As Integer = 5 Function SampleMethod() as IntegerEnd Interface

// C#interface ISampleInterface{ private int j = 5; int SampleMethod();}

4. ' VBInterface IAsset Function SampleMethod() As Integer Dim i As Integer = 5 Return i End FunctionEnd Interface

// C#interface ISampleInterface{ int SampleMethod() { int i = 5; return i; }}

Explanation :Interfaces describe the properties, methods, and events of a class without providing any implementation.

Interfaces cannot provide any code within a method or define any property values.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Reference types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

Interfaces OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/s3et34z3.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 46 (536P_2.3.1_01)

_________________________________________________________________________________________________________________

Which of the following creates an application domain and launches a process within it?

1. ' VBDim d As AppDomain = AppDomain.CreateDomain("Domain", "Assembly")

// C#AppDomain d = AppDomain.CreateDomain("Domain", "Assembly");

2. ' VBDim d As AppDomain = AppDomain.CreateDomain("Domain")d.ExecuteAssemblyByName("Assembly")

// C#AppDomain d = AppDomain.CreateDomain("Domain");d.ExecuteAssemblyByName("Assembly");

<Correct>

3. ' VBAppDomain.ExecuteAssemblyByName("Assembly")

// C#AppDomain.ExecuteAssemblyByName("Assembly");

4. ' VBDim d As AppDomain = AppDomain.ExecuteAssemblyByName("Domain", "Assembly")

// C#AppDomain d = AppDomain.ExecuteAssemblyByName("Domain", "Assembly");

Explanation :To launch an assembly within a new application domain, you must first create an instance of the AppDomain class, and then call that object's ExecuteAssembly or ExecuteAssemblyByName method to launch the assembly.

The AppDomain.CreateDomain method does not have an overload that accepts an assembly name.

The AppDomain class does not have a static ExecuteAssemblyByName method--you must first create an instance of the class to call this method.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Create a unit of isolation for common language runtime in a .NET Framework application by using application domains. (Refer System namespace) Create an application domain.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 8 - Lesson 1

Creating and Configuring Application DomainsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/wxtzfyw3.aspx

Programming with Application DomainsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/yk22e11a.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 47 (536P_7.3.5_01)

_________________________________________________________________________________________________________________

At a minimum, how many of the following characters do all code pages have in common?

1. 256

2. 65536

3. 0

4. 128 <Correct>

Explanation :All codepages have the first 128 characters, 0 through 127, the same. These characters were originally defined as part of American Standard Code for Information Interchange (ASCII).

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.RegularExpressions namespace) Encode text by using Encoding classes.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 3 - Lesson 2

Locales and Code PagesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/8w60z792(vs.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 48 (536P_5.6.5_02)

_________________________________________________________________________________________________________________

Which class would you use to test whether an assembly was located on the intranet?

1. ZoneMembershipCondition <Correct>

2. GacMembershipCondition

3. SiteMembershipCondition

4. UrlMembershipCondition

Explanation :The ZoneMembershipCondition class determines whether an assembly belongs to a code group by testing its zone. To test for the intranet zone, create an instance of ZoneMembershipCondition using the SecurityZone.Intranet enumeration.

The GacMembershipCondition class determines whether an assembly belongs to a code group by testing its global assembly cache membership.

The SiteMembershipCondition class determines whether an assembly belongs to a code group by testing the site from which it originated.

The UrlMembershipCondition class determines whether an assembly belongs to a code group by testing its URL. While the function is very similar, use UrlMembershipCondition for assemblies retrieved using HTTP.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Control code privileges by using System.Security.Policy classes. (Refer System.Security.Policy namespace) Condition classes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 1

ZoneMembershipCondition ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.policy.zonemembershipcondition(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 49 (536P_6.1.1_01)

_________________________________________________________________________________________________________________

As part of your assembly, you need to call a COM DLL file. Using Microsoft Visual Studio 2005, what is the easiest way to generate an interop assembly and enable your assembly to access the dynamic-link library (DLL)?

1. 1. Using Win32 development tools, create a command-line wrapper for the COM DLL file.2. In your .NET Framework assembly, call the command-line wrapper.

2. 1. Using Win32 development tools, create a command-line wrapper for the COM DLL file.2. In your .NET Framework assembly, call the command-line wrapper.

3. 1. Using Win32 development tools, create a command-line wrapper for the COM DLL file.2. In your .NET Framework assembly, call the command-line wrapper.

4. 1. Click the Project menu, and then click Add Reference.2. Click the .NET tab.3. Select the library from the Available References list, and then click OK.

5. 1. Using Win32 development tools, create a command-line wrapper for the COM DLL file.2. In your .NET Framework assembly, call the command-line wrapper.

6. 1. Click the Project menu, and then click Add Reference.2. Click the COM tab.3. Select the library from the Available References list, and then click OK.

<Correct>

7. 1. Click the Project menu, and then click Add Component.2. Click Browse and select your DLL.3. Click OK.

8. 1. Using Win32 development tools, create a command-line wrapper for the COM DLL file.2. In your .NET Framework assembly, call the command-line wrapper.

9. 1. Using Win32 development tools, create a command-line wrapper for the COM DLL file.2. In your .NET Framework assembly, call the command-line wrapper.

10. 1. Using Win32 development tools, create a command-line wrapper for the COM DLL file.2. In your .NET Framework assembly, call the command-line wrapper.

Explanation :Visual Studio 2005 will automatically generate an interop library to enable you to call a COM DLL file if you add the reference using the COM tab of the Add Reference dialog box.

You cannot add a reference to a COM DLL by using the Add Component menu item.

While you could develop a command-line wrapper for a COM DLL, it would be more error prone and time consuming than adding the reference to your project.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Expose COM components to the .NET Framework and the .NET Framework components to COM. (Refer System.Runtime.InteropServices namespace) Import a type library as an assembly.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, Microsoft

Chapter 13 - Lesson 1

How to: Add References to Type LibrariesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/fwawt96c.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 50 (536P_5.3_04)

_________________________________________________________________________________________________________________

You need to establish a Secure Sockets Layer (SSL) session with a remote server. The security policy at your organization requires you to validate the server's SSL certificate. Which of the following code samples most efficiently validates the certificate?

1. ' VBSub Main() Dim client As TcpClient = New TcpClient("www.contoso.com", 443) Dim sslStream As SslStream = New SslStream(client.GetStream, False, _ AddressOf ValidateServerCertificate, Nothing)

' TODO: Communicate with server sslStream.Close()End Sub

Public Function ValidateServerCertificate() If sslPolicyErrors <> sslPolicyErrors.None Then Throw New AuthenticationException("Invalid certificate")End Function

// C#public static void Main(string[] args){ TcpClient client = new TcpClient("www.contoso.com", 443); SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);

// TODO: Communicate with server sslStream.Close();}

public static void ValidateServerCertificate(){ if (sslPolicyErrors != SslPolicyErrors.None) throw new AuthenticationException("Invalid certificate");}

2. ' VB Sub Main() Dim client As TcpClient = New TcpClient("www.contoso.com",443) Dim sslStream As SslStream = New SslStream(client.GetStream,False, _ AddressOf ValidateServerCertificate, Nothing)

' TODO: Communicate with server sslStream.Close() End Sub

Public Function ValidateServerCertificate() As Boolean If sslPolicyErrors = sslPolicyErrors.None Then Return True End If Return False End Function

// C#public static void Main(string[] args){ TcpClient client = new TcpClient("www.contoso.com", 443); SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);

// TODO: Communicate with server sslStream.Close();}

public static bool ValidateServerCertificate(){

if (sslPolicyErrors == SslPolicyErrors.None) return true; return false;}

3. ' VBSub Main() Dim client As TcpClient = New TcpClient("www.contoso.com", 443) Dim sslStream As SslStream = New SslStream(client.GetStream, False, _ AddressOf ValidateServerCertificate, Nothing)

' TODO: Communicate with server sslStream.Close()End Sub

Public Function ValidateServerCertificate(ByVal sender As Object, _ByVal certificate As X509Certificate, ByVal chain As X509Chain, _ByVal sslPolicyErrors As SslPolicyErrors) If sslPolicyErrors <> sslPolicyErrors.None Then Throw New AuthenticationException("Invalid certificate")End Function

// C#public static void Main(string[] args){ TcpClient client = new TcpClient("www.contoso.com", 443); SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);

// TODO: Communicate with server sslStream.Close();}

public static void ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors){ if (sslPolicyErrors != SslPolicyErrors.None) throw new AuthenticationException("Invalid certificate");}

4. ' VB Sub Main() Dim client As TcpClient = New TcpClient("www.contoso.com", 443) Dim sslStream As SslStream = New SslStream(client.GetStream, False, _ AddressOf ValidateServerCertificate, Nothing)

' TODO: Communicate with server sslStream.Close() End Sub

Public Function ValidateServerCertificate(ByVal sender As Object, ByVal _ certificate As X509Certificate, ByVal chain As X509Chain, ByVal _ sslPolicyErrors As SslPolicyErrors) As Boolean If sslPolicyErrors = sslPolicyErrors.None Then Return True End If Return False End Function

// C#public static void Main(string[] args){ TcpClient client = new TcpClient("www.contoso.com", 443); SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);

// TODO: Communicate with server sslStream.Close();}

public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors){ if (sslPolicyErrors == SslPolicyErrors.None) return true; return false;} <Correct>

Explanation :To validate a certificate, use the overloaded SslStream constructor that allows you to provide a RemoteCertificateValidationCallback delegate. In the delegate, which must accept several parameters

to match the delegate signature, return true if the certificate is valid or false if the certificate is not valid.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement a custom authentication scheme by using the System.Security.Authentication classes. (Refer System.Security.Authentication namespace)

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 1

SslStream ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.net.security.sslstream.aspx

RemoteCertificateValidationCallback DelegateMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.net.security.remotecertificatevalidationcallback.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 51 (536P_6.2.8_02)

_________________________________________________________________________________________________________________

Which of the following managed classes corresponds to the unmanaged HANDLE class?

1. Int32

2. String

3. IntPtr <Correct>

4. UInt16

5. Double

Explanation :The IntPtr managed class corresponds to the HANDLE unmanaged type.

LPSTR corresponds to the String managed class.

The UInt16 managed class corresponds to the WORD unmanaged type.

The Int32 managed class corresponds to the INT, LONG, or BOOL unmanaged types.

The Double managed class corresponds to the DOUBLE unmanaged type.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Call unmanaged DLL functions in a .NET Framework application, and control the marshaling of data in a .NET Framework application. (Refer System.Runtime.InteropServices namespace) Marshal data with Platform Invoke

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 13 - Lesson 3

Platform Invoke Data TypesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ac7ay120(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 52 (536P_5.2.1_01)

_________________________________________________________________________________________________________________

You are writing an application that stores security log information in a text file. This log file contains confidential information that only members of the local Administrators group should be able to view or modify.

Which of the following code samples creates a text file with the proper permissions?

1. ' VBDim user As NTAccount = New NTAccount("Administrator")Dim ar As FileSystemAccessRule = New FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow)Dim fs As FileSecurity = New FileSecurityfs.AddAccessRule(ar)System.IO.File.Create("log.txt", 1000, FileOptions.None, fs)

// C#NTAccount user = new NTAccount("Administrator");FileSystemAccessRule ar = new FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow);FileSecurity fs = new FileSecurity();fs.AddAccessRule(ar);System.IO.File.Create("log.txt", 1000, FileOptions.None, fs);

2. ' VBDim user As NTAccount = New NTAccount("Administrators")Dim ar As FileSystemAccessRule = New FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow)Dim fs As FileSecurity = New FileSecurityfs.AddAccessRule(ar)System.IO.File.Create("log.txt", 1000, FileOptions.None, fs)

// C#NTAccount user = new NTAccount("Administrators");FileSystemAccessRule ar = new FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow);FileSecurity fs = new FileSecurity();fs.AddAccessRule(ar);System.IO.File.Create("log.txt", 1000, FileOptions.None, fs);

<Correct>

3. ' VBWindowsIdentity user = WindowsIdentity.GetCurrent()Dim ar As FileSystemAccessRule = New FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow)Dim fs As FileSecurity = New FileSecurityfs.AddAccessRule(ar)System.IO.File.Create("log.txt", 1000, FileOptions.None, fs)

// C#WindowsIdentity user = WindowsIdentity.GetCurrent();FileSystemAccessRule ar = new FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow);FileSecurity fs = new FileSecurity();fs.AddAccessRule(ar);System.IO.File.Create("log.txt", 1000, FileOptions.None, fs);

4. ' VBWindowsIdentity user = WindowsIdentity.GetCurrent()Dim ar As FileSystemAccessRule = New FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Deny)Dim fs As FileSecurity = New FileSecurityfs.AddAccessRule(ar)System.IO.File.Create("log.txt", 1000, FileOptions.None, fs)

// C#WindowsIdentity user = WindowsIdentity.GetCurrent();FileSystemAccessRule ar = new FileSystemAccessRule(user, FileSystemRights.FullControl,

AccessControlType.Deny);FileSecurity fs = new FileSecurity();fs.AddAccessRule(ar);System.IO.File.Create("log.txt", 1000, FileOptions.None, fs);

Explanation :First you should create an instance of NTAccount for the user or group that you need to add an access control entry for. Then create an instance of FileSystemAccessRule with the account, the file system rights, and the access control type. Next create a FileSecurity instance and add the access rule to it. Finally, create your file using one of the overloaded constructors that allows specifying file security.

Specifying "Administrator" as the user account would specify the user named Administrator, rather than the group named "Administrators".

You cannot create a FileSystemAccessRule instance using a WindowsIdentity object.

You cannot create a FileSystemAccessRule instance using a WindowsIdentity object. Additionally, this specifies AccessControlType.Deny instead of AccessControlType.Allow.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement access control by using the System.Security.AccessControl classes. DirectorySecurity class, FileSecurity class, FileSystemSecurity class, and RegistrySecurity class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 2

ACL Technology ScenariosMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms229925(VS.80).aspx

FileSystemAccessRule ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.accesscontrol.filesystemaccessrule.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 53 (536P_4.7.1_02)

_________________________________________________________________________________________________________________

Which of the following ways can isolated storage be separated? (Choose all that apply.)

1. By Active Directory domain

2. By assembly<Correct>

3. By user <Correct>

4. By application domain <Correct>

Explanation :Isolated storage is always separated by user and assembly. It can also be separated by application domain.

You cannot separate isolated storage by Active Directory domain.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Compress or decompress stream information in a .NET Framework application (refer System.IO.Compression namespace), and improve the security of application data by using isolated storage. (Refer System.IO.IsolatedStorage namespace) IsolatedStorageFile class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 4

Introduction to Isolated StorageMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/3ak841sy.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 54 (536P_5.2.2_01)

_________________________________________________________________________________________________________________

You are writing an application that analyzes database information and creates an XML summary. All users in the Contoso domain should be able to view the report. Additionally, members of the Domain Admins group should be able to modify or delete the file.

Which of the following code samples creates a text file with the proper permissions?

1. ' VBDim admins As NTAccount = New NTAccount("CONTOSO", "Domain Admins")Dim users As NTAccount = New NTAccount("CONTOSO", "Domain Users")Dim adminsRule As FileSystemAccessRule = New FileSystemAccessRule(admins, FileSystemRights.FullControl, AccessControlType.Allow)Dim usersRule As FileSystemAccessRule = New FileSystemAccessRule(users, FileSystemRights.ReadPermissions, AccessControlType.Allow)Dim fs As FileSecurity = New FileSecurityfs.AddAccessRule(adminsRule)fs.AddAccessRule(usersRule)System.IO.File.Create("summary.xml", 1000, FileOptions.None, fs)

// C#NTAccount admins = new NTAccount("CONTOSO", "Domain Admins");NTAccount users = new NTAccount("CONTOSO", "Domain Users");FileSystemAccessRule adminsRule = new FileSystemAccessRule(admins, FileSystemRights.FullControl, AccessControlType.Allow);FileSystemAccessRule usersRule = new FileSystemAccessRule(users, FileSystemRights.ReadPermissions, AccessControlType.Allow);FileSecurity fs = new FileSecurity();fs.AddAccessRule(adminsRule);fs.AddAccessRule(usersRule);System.IO.File.Create("summary.xml", 1000, FileOptions.None, fs);

2. ' VBDim admins As NTAccount = New NTAccount("CONTOSO", "Domain Admins")Dim users As NTAccount = New NTAccount("CONTOSO", "Domain Users")Dim adminsRule As FileSystemAccessRule = New FileSystemAccessRule(admins, FileSystemRights.Read, AccessControlType.Allow)Dim usersRule As FileSystemAccessRule = New FileSystemAccessRule(users, FileSystemRights.FullControl, AccessControlType.Allow)Dim fs As FileSecurity = New FileSecurityfs.AddAccessRule(adminsRule)fs.AddAccessRule(usersRule)System.IO.File.Create("summary.xml", 1000, FileOptions.None, fs)

// C#NTAccount admins = new NTAccount("CONTOSO", "Domain Admins");NTAccount users = new NTAccount("CONTOSO", "Domain Users");FileSystemAccessRule adminsRule = new FileSystemAccessRule(admins, FileSystemRights.Read, AccessControlType.Allow);FileSystemAccessRule usersRule = new FileSystemAccessRule(users, FileSystemRights.FullControl, AccessControlType.Allow);FileSecurity fs = new FileSecurity();fs.AddAccessRule(adminsRule);fs.AddAccessRule(usersRule);System.IO.File.Create("summary.xml", 1000, FileOptions.None, fs);

3. ' VBDim admins As NTAccount = New NTAccount("CONTOSO", "Domain Admins")Dim users As NTAccount = New NTAccount("CONTOSO", "Domain Users")Dim adminsRule As FileSystemAccessRule = New FileSystemAccessRule(admins, FileSystemRights.FullControl, AccessControlType.Allow)Dim usersRule As FileSystemAccessRule = New FileSystemAccessRule(users, FileSystemRights.Read, AccessControlType.Allow)Dim fs As FileSecurity = New FileSecurity(adminsRule, usersRule)System.IO.File.Create("summary.xml", 1000, FileOptions.None, fs)

// C#NTAccount admins = new NTAccount("CONTOSO", "Domain Admins");

NTAccount users = new NTAccount("CONTOSO", "Domain Users");FileSystemAccessRule adminsRule = new FileSystemAccessRule(admins, FileSystemRights.FullControl, AccessControlType.Allow);FileSystemAccessRule usersRule = new FileSystemAccessRule(users, FileSystemRights.Read, AccessControlType.Allow);FileSecurity fs = new FileSecurity(adminsRule, usersRule);System.IO.File.Create("summary.xml", 1000, FileOptions.None, fs);

4. ' VBDim admins As NTAccount = New NTAccount("CONTOSO", "Domain Admins")Dim users As NTAccount = New NTAccount("CONTOSO", "Domain Users")Dim adminsRule As FileSystemAccessRule = New FileSystemAccessRule(admins, FileSystemRights.FullControl, AccessControlType.Allow)Dim usersRule As FileSystemAccessRule = New FileSystemAccessRule(users, FileSystemRights.Read, AccessControlType.Allow)Dim fs As FileSecurity = New FileSecurityfs.AddAccessRule(adminsRule)fs.AddAccessRule(usersRule)System.IO.File.Create("summary.xml", 1000, FileOptions.None, fs)

// C#NTAccount admins = new NTAccount("CONTOSO", "Domain Admins");NTAccount users = new NTAccount("CONTOSO", "Domain Users");FileSystemAccessRule adminsRule = new FileSystemAccessRule(admins, FileSystemRights.FullControl, AccessControlType.Allow);FileSystemAccessRule usersRule = new FileSystemAccessRule(users, FileSystemRights.Read, AccessControlType.Allow);FileSecurity fs = new FileSecurity();fs.AddAccessRule(adminsRule);fs.AddAccessRule(usersRule);System.IO.File.Create("summary.xml", 1000, FileOptions.None, fs);

<Correct>

Explanation :First you should create an instance of NTAccount for the user or group that you need to add an access control entry for. Then create an instance of FileSystemAccessRule with the account, the file system rights, and the access control type. Next create a FileSecurity instances and add the access rule to the FileSecurity instance. Finally, create your file using one of the overloaded constructors that allows specifying file security.

You cannot add rules to an instance of FileSecurity using the FileSecurity constructor.

This code sample incorrectly grants Read access to Domain Admins, and grants Full Control access to Domain Users.

This code sample grants the Domain Users group the ReadPermissions access level, which allows them to view the permissions assigned to a file but not to open the file as the requirements demand.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement access control by using the System.Security.AccessControl classes. AccessRule class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 2

ACL Technology ScenariosMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms229925(VS.80).aspx

FileSystemAccessRule ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.accesscontrol.filesystemaccessrule.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 55 (536P_1.6.1_01)

_________________________________________________________________________________________________________________

What is the purpose of a delegate?

1. To provide identical member methods and properties from multiple related classes

2. To spawn an additional thread to provide parallel processing

3. To enable an assembly to respond to an event that occurs within a class <Correct>

4. To copy member methods and properties from an existing class

Explanation :An assembly declares a delegate when it needs to respond to an event that occurs within a class.

Delegates are not related to threading.

Inheritance copies members from an existing class, not a delegate.

Interfaces provide identical members from multiple related classes, not delegates.

Objective:Developing applications that use system types and collections

Sub Objective(s):Control interactions between .NET Framework application components by using events and delegates. (Refer System namespace) Delegate class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

Events and DelegatesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/17sde2xt.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 56 (536P_4.4.2_01)

_________________________________________________________________________________________________________________

Which of the following code samples does not result in an exception being thrown if the directory "C:\Dir\" does not exist? (Choose all that apply.)

1. ' VBDim d As String = "C:\dir\"Dim di As DirectoryInfo = New DirectoryInfo(d)If Not di.Exists Then Dim sw As StreamWriter = New StreamWriter(d + "Text.txt") sw.WriteLine("Hello, World!")End If

// C#String d = @"C:\dir\";DirectoryInfo di = new DirectoryInfo(d);if (!di.Exists){ StreamWriter sw = new StreamWriter(d+"Text.txt"); sw.WriteLine("Hello, World!");}

2. ' VBDim d As String = "C:\dir\"Dim sw As StreamWriter = New StreamWriter(d + "Text.txt")sw.WriteLine("Hello, World!")

// C#String d = @"C:\dir\";StreamWriter sw = new StreamWriter(d+"Text.txt");sw.WriteLine("Hello, World!");

3. ' VBDim d As String = "C:\dir\"If Directory.Exists(d) Then Dim sw As StreamWriter = New StreamWriter(d + "Text.txt") sw.WriteLine("Hello, World!")End If

// C#String d = @"C:\dir\";if (Directory.Exists(d)){ StreamWriter sw = new StreamWriter(d+"Text.txt"); sw.WriteLine("Hello, World!");} <Correct>

4. ' VBDim d As String = "C:\dir\"Dim di As DirectoryInfo = New DirectoryInfo(d)If di.Exists Then Dim sw As StreamWriter = New StreamWriter(d + "Text.txt") sw.WriteLine("Hello, World!")End If

// C#String d = @"C:\dir\";DirectoryInfo di = new DirectoryInfo(d);if (di.Exists){ StreamWriter sw = new StreamWriter(d+"Text.txt"); sw.WriteLine("Hello, World!");} <Correct>

Explanation :To check whether a directory exists, you can call the static Directory.Exists method, or you can create a DirectoryInfo object and call DirectoryInfo.Exists.

The StreamWriter constructor cannot automatically create a directory if the specified directory does

not exist. Therefore, the runtime throws an exception.

This code sample tests attempts to create a file only if the directory does not exist. Therefore, it will always throw an exception.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Access files and folders by using the File System classes. (Refer System.IO namespace) Directory class and DirectoryInfo class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 1

Directory ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.io.directory.aspx

DirectoryInfo ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/8s2fzb02(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 57 (536P_3.4.3_01)

_________________________________________________________________________________________________________________

Which of the following code samples correctly displays the modules loaded by Application.exe?

1. ' VBDim p As Process = New Processp.StartInfo.FileName = "Application.exe"p.StartFor Each m As ProcessModuleCollection In p.Modules Console.WriteLine(m.FileName)Next

// C#Process p = new Process();p.StartInfo.FileName = "Application.exe";p.Start();foreach (ProcessModuleCollection m in p.Modules){ Console.WriteLine(m.FileName);}

2. ' VBDim p As Process = New Processp.StartInfo.FileName = " Application.exe"p.StartFor Each m As ProcessModuleCollection In Process.Modules(p.Id) Console.WriteLine(m.FileName)Next

// C#Process p = new Process();p.StartInfo.FileName = " Application.exe";p.Start();foreach (ProcessModuleCollection m in Process.Modules(p.Id)){ Console.WriteLine(m.FileName);}

3. ' VBDim p As Process = New Processp.StartInfo.FileName = "Application.exe"p.StartFor Each m As ProcessModule In p.Modules Console.WriteLine(m.FileName)Next

// C#Process p = new Process();p.StartInfo.FileName = "Application.exe";p.Start();foreach (ProcessModule m in p.Modules){ Console.WriteLine(m.FileName);} <Correct>

4. ' VBDim p As Process = New Processp.StartInfo.FileName = "Application.exe"p.StartFor Each m As ProcessModule In Process.Modules(p.Id) Console.WriteLine(m.FileName)Next

// C#Process p = new Process();p.StartInfo.FileName = " Application.exe";p.Start();foreach (ProcessModule m in Process.Modules(p.Id)){ Console.WriteLine(m.FileName);

}

Explanation :To retrieve a list of modules loaded by a process, access the ProcessModule array in Process.Modules.

Process.Modules is an array of ProcessModule objects, not ProcessModuleCollection, and Process.Modules is not a static method.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Manage system processes and monitor the performance of a .NET Framework application by using the diagnostics functionality of the .NET Framework 2.0. (Refer System.Diagnostics namespace) Get a list of all modules that are loaded by a process.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 3

Process.Modules PropertyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.process.modules.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 58 (536P_3.5.1_02)

_________________________________________________________________________________________________________________

You are in the process of isolating a complicated bug in a console application that occurs only in rare circumstances. You need to write information to the debugging console, but you do not want to waste processing cycles when users run release versions of the application. Which method should you call?

1. Console.Write

2. Debugger.Log <Correct>

3. Debug.Assert

4. Console.WriteLine

Explanation :Debugger.Log posts information to the attached Debugger if one is present. If no Debugger is present, the result is effectively nothing.

Console.Write and Console.WriteLine are processed in both debug and release versions of code. The output is written to the console, not to the debugger.

Debug.Assert validates a value and does not output information to the debugger.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Debug and trace a .NET Framework application by using the System.Diagnostics namespace. Debug class and Debugger class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 2

Debugger.Log MethodMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.debugger.log(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 59 (536P_5.6.7_02)

_________________________________________________________________________________________________________________

You need to override the standard logic used to determine whether an assembly is a member of a code group. Which interface would you implement?

1. IMembershipCondition <Correct>

2. IIdentity

3. IIdentityPermissionFactory

4. IApplicationTrustManager

Explanation :IMembershipCondition defines the test to determine whether a code assembly is a member of a code group.

Trust managers must implement the IApplicationTrustManager interface. The host calls the DetermineApplicationTrust method in the trust manager to determine whether an application should be executed and which permissions should be granted to the application. You cannot use IApplicationTrustManager to alter the logic used to determine whether an assembly is a member of a code group.

IIdentityPermissionFactory is used to provide custom identity permission logic. You cannot use IIdentityPermissionFactory to alter the logic used to determine whether an assembly is a member of a code group.

IIdentity is an identity object that represents the user. It might be used as evidence; however, you cannot use IIdentity to alter the logic used to determine whether an assembly is a member of a code group.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Control code privileges by using System.Security.Policy classes. (Refer System.Security.Policy namespace) IApplicationTrustManager interface, IMembershipCondition interface, and IIdentityPermissionFactory interface

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 1

IMembershipCondition InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.policy.imembershipcondition.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 60 (536P_6.1.6_01)

_________________________________________________________________________________________________________________

Which of the following interop attributes indicates that a coclass or interface definition was imported from a COM type library?

1. OutAttribute

2. ComSourceInterfacesAttribute

3. ComImportAttribute <Correct>

4. CoClassAttribute

Explanation :ComImportAttribute indicates that a coclass or interface definition was imported from a COM type library. The runtime uses this flag to know how to activate and marshal the type. This attribute prohibits the type from being exported back to a type library. COM interop tools typically apply this attribute.

ComSourceInterfacesAttribute identifies interfaces that are sources of events for the class.

CoClassAttribute identifies the CLSID of the original coclass imported from a type library.

OutAttribute indicates that the data in a field or parameter must be marshaled from a called object back to its caller.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Expose COM components to the .NET Framework and the .NET Framework components to COM. (Refer System.Runtime.InteropServices namespace) Apply Interop attributes, such as the ComVisibleAttribute class.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 13 - Lesson 2

How to: Implement Events in Your ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/5z57dxz2(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 61 (536P_3.1.1_08)

_________________________________________________________________________________________________________________

Which of the following configuration files shows the best way to define a database connection string in an application configuration file?

1. <?xml version="1.0" encoding="utf-8" ?><configuration> <connectionStrings> <add name="AdventureWorksString" providerName="System.Data.SqlClient" connectionString="Data Source=localhost;Initial Catalog=AdventureWorks; Integrated Security=true"/> </connectionStrings></configuration>

<Correct>

2. <?xml version="1.0" encoding="utf-8" ?><configuration> <appSettings> <add name="AdventureWorksString" providerName="System.Data.SqlClient" connectionString="Data Source=localhost;Initial Catalog=AdventureWorks; Integrated Security=true"/> </appSettings></configuration>

3. <?xml version="1.0" encoding="utf-8" ?><configuration> <connectionStrings> <add key="System.Data.SqlClient" value="Data Source=localhost;Initial Catalog=AdventureWorks; Integrated Security=true"/> </connectionStrings></configuration>

4. <?xml version="1.0" encoding="utf-8" ?><configuration> <appSettings> <add key="System.Data.SqlClient" value="Data Source=localhost;Initial Catalog=AdventureWorks; Integrated Security=true"/> </appSettings></configuration>

5. <?xml version="1.0" encoding="utf-8" ?><configuration> <add name="AdventureWorksString" providerName="System.Data.SqlClient" connectionString="Data Source=localhost;Initial Catalog=AdventureWorks; Integrated Security=true"/></configuration>

6. <?xml version="1.0" encoding="utf-8" ?><appSettings> <add key="System.Data.SqlClient" value="Data Source=localhost;Initial Catalog=AdventureWorks; Integrated Security=true"/></appSettings>

Explanation :The .NET Framework 2.0 adds support for the <connectionStrings> configuration section for defining database connection information. Define this section within the <configuration> section using the <add> element with properties of name, providerName, and connectionString.

While you can define database connection information in the appSettings section (and you had no choice in earlier versions of the .NET Framework), your best choice is to use the strongly-typed <connectionStrings> section.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):

Embed configuration management functionality into a .NET Framework application. (Refer System.Configuration namespace) Configuration class and ConfigurationManager class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 1

ConfigurationManager.ConnectionStrings PropertyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.configuration.configurationmanager.connectionstrings.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 62 (536P_1.5.4_01)

_________________________________________________________________________________________________________________

Which of the following methods is inherited from the ICloneable interface?

1. Clone() <Correct>

2. Dispose()

3. CompareTo()

4. ToString()

5. GetType()

6. Equals()

Explanation :The Clone() method is a member of the ICloneable interface.

The Dispose() method is a member of the IDisposable interface.

The CompareTo() method is a member of the IComparable interface.

All classes inherit the ToString(), Equals(), and GetType() methods from the base Object class.

Objective:Developing applications that use system types and collections

Sub Objective(s):Implement .NET Framework interfaces to cause components to comply with standard contracts. (Refer System namespace) ICloneable interface

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

ICloneable InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.icloneable.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 63 (536P_4.7.1_03)

_________________________________________________________________________________________________________________

Which of the following scenarios is appropriate for isolated storage?

1. Per-user storage <Correct>

2. Storing source code

3. Storing configuration and deployment settings

4. Storing confidential files

Explanation :Isolated storage is perfect for storing data that should be kept separate for different users.

Isolated storage should not be used to store high-value secrets, such as unencrypted keys or passwords, because isolated storage is not protected from highly trusted code, from unmanaged code, or from trusted users of the computer.

Isolated storage should not be used to store code because it is only accessible from within .NET Framework applications.

Isolated storage should not be used to store configuration and deployment settings, which administrators control. (User preferences are not considered to be configuration settings because administrators do not control them.)

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Compress or decompress stream information in a .NET Framework application (refer System.IO.Compression namespace), and improve the security of application data by using isolated storage. (Refer System.IO.IsolatedStorage namespace) IsolatedStorageFile class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 4

Scenarios for Isolated StorageMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/kbcw921f(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 64 (536P_1.1.4_02)

_________________________________________________________________________________________________________________

Which of the following types of constraints can you apply to a generic? (Choose all that apply.)

1. Base classes <Correct>

2. Interfaces <Correct>

3. Properties

4. Method

5. Name pattern matching

Explanation :There are four types of constraints you can apply to generics: interfaces, base classes, constructors, and making them a reference or value type.

You cannot require types to have a specific method or property in a generic class.

You canot use name pattern matching in a generic constraint.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Generic types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

Overview of Reflection and GenericsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms172334.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 65 (536P_5.1.5_01)

_________________________________________________________________________________________________________________

You have created a set of custom classes that provide important business logic. You want to ensure that calling code has permission to access specific methods within your custom classes. Which interface can you implement to create a class that can be used to identify callers with the necessary privileges?

1. IEvidenceFactory

2. IPermission <Correct>

3. ISecurityEncodable

4. ISecurityPolicyEncodable

Explanation :Use IPermission to implement custom permissions.

The IEvidenceFactory interface can be implemented if you need to override the process for retrieving an object's evidence.

The ISecurityEncodable interface defines the methods that convert permission object state to and from XML element representation.

The ISecurityPolicyEncodable interface supports the methods that convert permission object state to and from an XML element representation.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement code access security to improve the security of a .NET Framework application. (Refer System.Security namespace) Standard Security interfaces

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 1

IPermission InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.ipermission(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 66 (536P_3.1.2_01)

_________________________________________________________________________________________________________________

You are writing an application that communicates with a database. You need to be able to communicate with any type of database configured by the system administrator. Systems administrators can choose either a Microsoft SQL Server, Oracle, OleDB, or ODBC connection. Which of the following code samples would establish a database connection named db to any of those database types?

1. ' VBDim css As ConnectionStringSettings = ConfigurationManager.ConnectionStrings(0)Dim db As IDBConnection = NothingSelect css.ConnectionString Case "System.Data.SqlClient" db = New SqlConnection(css.ConnectionString) ' break Case "System.Data.OracleClient" db = New OracleConnection(css.ConnectionString) ' break Case "System.Data.OleDb" db = New OleDbConnection(css.ConnectionString) ' break Case "System.Data.Odbc" db = New OdbcConnection(css.ConnectionString) ' breakEnd Select

// C#ConnectionStringSettings css = ConfigurationManager.ConnectionStrings[0];IDBConnection db = null;switch (css.ConnectionString){ case "System.Data.SqlClient": db = new SqlConnection(css.ConnectionString); break; case "System.Data.OracleClient": db = new OracleConnection(css.ConnectionString); break; case "System.Data.OleDb": db = new OleDbConnection(css.ConnectionString); break; case "System.Data.Odbc": db = new OdbcConnection(css.ConnectionString); break;}

2. ' VBDim css As ConnectionStringSettings = ConfigurationManager.ConnectionStrings(0)Dim db As IDBConnection = NothingSelect css.ElementInformation.Type Case "System.Data.SqlClient" db = New SqlConnection(css.ConnectionString) ' break Case "System.Data.OracleClient" db = New OracleConnection(css.ConnectionString) ' break Case "System.Data.OleDb" db = New OleDbConnection(css.ConnectionString) ' break Case "System.Data.Odbc" db = New OdbcConnection(css.ConnectionString) ' breakEnd Select

// C#ConnectionStringSettings css = ConfigurationManager.ConnectionStrings[0];IDBConnection db = null;switch (css.ElementInformation.Type){ case "System.Data.SqlClient": db = new SqlConnection(css.ConnectionString); break;

case "System.Data.OracleClient": db = new OracleConnection(css.ConnectionString); break; case "System.Data.OleDb": db = new OleDbConnection(css.ConnectionString); break; case "System.Data.Odbc": db = new OdbcConnection(css.ConnectionString); break;}

3. ' VBDim css As ConnectionStringSettings = ConfigurationManager.ConnectionStrings(0)Dim db As IDBConnection = NothingSelect css.ProviderName Case "System.Data.SqlClient" db = New SqlConnection(css.ConnectionString) ' break Case "System.Data.OracleClient" db = New OracleConnection(css.ConnectionString) ' break Case "System.Data.OleDb" db = New OleDbConnection(css.ConnectionString) ' break Case "System.Data.Odbc" db = New OdbcConnection(css.ConnectionString) ' breakEnd Select

// C#ConnectionStringSettings css = ConfigurationManager.ConnectionStrings[0];IDBConnection db = null;switch (css.ProviderName){ case "System.Data.SqlClient": db = new SqlConnection(css.ConnectionString); break; case "System.Data.OracleClient": db = new OracleConnection(css.ConnectionString); break; case "System.Data.OleDb": db = new OleDbConnection(css.ConnectionString); break; case "System.Data.Odbc": db = new OdbcConnection(css.ConnectionString); break;} <Correct>

4. ' VBDim css As ConnectionStringSettings = ConfigurationManager.ConnectionStrings(0)Dim db As IDBConnection = NothingSelect css.Name Case "System.Data.SqlClient" db = New SqlConnection(css.ConnectionString) ' break Case "System.Data.OracleClient" db = New OracleConnection(css.ConnectionString) ' break Case "System.Data.OleDb" db = New OleDbConnection(css.ConnectionString) ' break Case "System.Data.Odbc" db = New OdbcConnection(css.ConnectionString) ' breakEnd Select

// C#ConnectionStringSettings css = ConfigurationManager.ConnectionStrings[0];IDBConnection db = null;switch (css.Name){ case "System.Data.SqlClient": db = new SqlConnection(css.ConnectionString); break; case "System.Data.OracleClient": db = new OracleConnection(css.ConnectionString); break; case "System.Data.OleDb": db = new OleDbConnection(css.ConnectionString); break; case "System.Data.Odbc": db = new OdbcConnection(css.ConnectionString); break;

}

Explanation :To determine the database type based on a ConnectionStringSettings object, examine ConnectionStringSettings.ProviderName.

ConnectionStringSettings.Name stores the server name, not the database type.

ConnectionStringSettings.ConnectionString stores the entire connection string, which does not include the database type.

ConnectionStringSettings.ElementInformation.Type describes the type of element, which will always be System.Configuration.ConnectionStringSettings.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Embed configuration management functionality into a .NET Framework application. (Refer System.Configuration namespace) ConfigurationElement class, ConfigurationElementCollection class, and ConfigurationElementProperty class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 4

ConnectionStringSettings PropertiesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.configuration.connectionstringsettings_properties.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 67 (536P_3.3.3_02)

_________________________________________________________________________________________________________________

You are writing an application that adds events to an event log. Based on the EventLogEntryType enumeration, which of the following are valid entry types? (Choose all that apply.)

1. Success

2. Error <Correct>

3. FailureAudit <Correct>

4. Information <Correct>

5. Failure

6. SuccessAudit <Correct>

7. Fault

8. Warning <Correct>

Explanation :The EventLogEntryType enumeration contains Error, FailureAudit, Information, SuccessAudit, and Warning.

The EventLogEntryType enumeration does not contain Success, Fault, or Failure.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Manage an event log by using the System.Diagnostics namespace. Create a new event log.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 1

EventLogEntryType EnumerationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.eventlogentrytype.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 68 (536P_4.1.2_06)

_________________________________________________________________________________________________________________

You are creating a class that implements the ISerializable interface. Which serialization event should you respond to if you need to initialize a variable after deserialization occurs?

1. Serialized

2. Deserialized <Correct>

3. Serializing

4. Deserializing

Explanation :The Deserialized event occurs immediately after serialization.

The Serializing event occurs prior to serialization.

The Serialized event occurs immediately after serialization.

The Deserializing event occurs prior to deserialization.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) Serilization attributes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 1

Custom SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ty01x675.aspx

Basics of .NET Framework SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms233836.aspx

ISerializable InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.iserializable.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 69 (536P_1.4.1_01)

_________________________________________________________________________________________________________________

In C#, which of the following code samples compiles correctly?

1. // C#StringDictionary dict = new StringDictionary();dict[2] = "2";

2. // C#StringDictionary dict = new StringDictionary();dict["3"] = 3;

3. // C#StringDictionary dict = new StringDictionary();dict[4] = 4;

4. // C#StringDictionary dict = new StringDictionary();dict["First"] = "1st";

<Correct>

Explanation :When you create an instance of the specialized StringDictionary class, you can only set values that are strings, and you can only use string indexes. Visual Basic will automatically convert values to strings; however, you should still only use the StringDictionary class when both the index and the value are strings.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using specialized collections. (Refer System.Collections.Specialized namespace) Specialized String classes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 4 - Lesson 4

StringDictionary ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-US/library/system.collections.specialized.stringdictionary.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 70 (536P_3.5.1_04)

_________________________________________________________________________________________________________________

To assist with debugging, you want to write an output message if a configuration setting has not been defined. You do not want to waste processing time in released code. Which method should you use?

1. Debug.Assert <Correct>

2. Debug.Flush

3. Debug.Fail

4. Debug.Indent

Explanation :Debug.Assert evaluates a condition and displays a message to the debugging output window. Debug methods do not run in release code.

Debug.Fail causes the debugger to break at the line of code and output a failure message.

Debug.Flush flushes the debug output buffer.

Debug.Indent controls the output formatting.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Debug and trace a .NET Framework application by using the System.Diagnostics namespace. Debug class and Debugger class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 2

Debug ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.debug(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 71 (536P_2.2.7_01)

_________________________________________________________________________________________________________________

You are writing a multithreaded application, and multiple threads need to read and write the same file. At times, a thread will need to read from the file, and then immediately write to the file. What is the most efficient way to handle this in the thread?

1. 1. Create a ReaderWriterLock object, and call ReaderWriterLock.AcquireReadLock.2. Perform the reads.3. Call ReaderWriterLock.ReleaseLock.4. Call ReaderWriterLock.AcquireWriteLock, and perform both the writes.

2. 1. Create a ReaderWriterLock object, and call ReaderWriterLock.AcquireWriteLock.2. Perform both the reads and the writes.

3. 1. Create a ReaderWriterLock object, and call ReaderWriterLock.AcquireReadLock.2. Perform the reads.3. Call ReaderWriterLock.UpgradeToWriterLock, and perform the writes.

<Correct>

4. 1. Create a ReaderWriterLock object, and call ReaderWriterLock.AcquireReadLock.2. Perform the reads.3. Call ReaderWriterLock.ReleaseReaderLock.4. Call ReaderWriterLock.AcquireWriteLock, and perform both the writes.

Explanation :The most efficient way to switch from a read lock to a write lock is to call ReaderWriterLock.UpgradeToWriterLock.

You cannot read when you have a write lock.

Although you can release a read lock and acquire a write lock, it is not as efficient as using UpgradeToWriterLock.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Develop multithreaded .NET Framework applications. (Refer System.Threading namespace) ReaderWriterLock class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 7 - Lesson 2

ReaderWriterLock ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.threading.readerwriterlock.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 72 (536P_1.6.3_06)

_________________________________________________________________________________________________________________

Which of the following are events for the System.Windows.Forms.Button class? (Choose three.)

1. Click <Correct>

2. Resize

3. Enter <Correct>

4. MouseHover <Correct>

5. Serializing

6. MouseOver

Explanation :Click, Enter, and MouseHover are all valid events for the System.Windows.Forms.Button class.

MouseOver, Resize, and Serializing are not events for the Button class.

Objective:Developing applications that use system types and collections

Sub Objective(s):Control interactions between .NET Framework application components by using events and delegates. (Refer System namespace) EventHandler delegates

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

Button ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.windows.forms.button.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 73 (536P_5.2.5_03)

_________________________________________________________________________________________________________________

You are performing a security review of a coworker's application. You discover the following section of code. What does this code do?

' VBDim e As NTAccount = New NTAccount("Everyone")Dim rar As RegistryAuditRule = New RegistryAuditRule(e, RegistryRights.SetValue, InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AuditFlags.Failure)Dim rs As RegistrySecurity = New RegistrySecurityrs.AddAuditRule(rar)

Dim rk As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE", True)rk.SetAccessControl(rs)rk.Close

// C#NTAccount e = new NTAccount("Everyone");RegistryAuditRule rar = new RegistryAuditRule(e, RegistryRights.SetValue, InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AuditFlags.Failure);RegistrySecurity rs = new RegistrySecurity();rs.AddAuditRule(rar);

RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE", true);rk.SetAccessControl(rs);rk.Close();

1. Prevents all users from editing the HKEY_LOCAL_MACHINE\SOFTWARE registry key.

2. Enables auditing so that an event is added to the Security event log if any user attempts to modify a registry value in HKEY_LOCAL_MACHINE\SOFTWARE. <Correct>

3. Nothing; the changes are not properly finalized.

4. Enables auditing so that an event is added to the Security event log if any user successfully modifies a registry value in HKEY_LOCAL_MACHINE\SOFTWARE.

Explanation :The RegistryAuditRule class specifies System Access Control Lists (SACLs), which enable auditing. The RegistryAuditRule constructor parameters reveal that auditing will be enabled for failed attempts to modify the HKEY_LOCAL_MACHINE\SOFTWARE key.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement access control by using the System.Security.AccessControl classes. AuditRule class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 2

RegistryAuditRule ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.accesscontrol.registryauditrule(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 74 (536P_6.2.7_01)

_________________________________________________________________________________________________________________

Which of the following types CANNOT be marshaled between managed and unmanaged processes?

1. Strings

2. Structures

3. Delegates

4. Arrays

5. Generic types <Correct>

6. Boolean types

Explanation :Generic types cannot be marshaled between managed and unmanaged memory.

Arrays, Boolean types, char types, delegates, classes, objects, strings, and structures can be marshaled.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Call unmanaged DLL functions in a .NET Framework application, and control the marshaling of data in a .NET Framework application. (Refer System.Runtime.InteropServices namespace) Default marshaling behavior

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 13 - Lesson 3

Default Marshaling BehaviorMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/zah6xy75(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 75 (536P_7.3.4_01)

_________________________________________________________________________________________________________________

You are writing an application that processes phone numbers users have typed as strings. Which of the following code samples would reformat any of the following inputs?

555-555-1111(555) 555-11115555551111555 555-1111

In the following code samples, the string input is passed to the method as s.

1. ' VBFunction ReformatPhone(ByVal s As String) As String Dim m As Match = Regex.Match(s, "^(?(\d{3}))?[\s\-]?(\d{3})\-?(\d{4})$") Return String.Format("({0}) {1}-{2}", m.Groups(1), m.Groups(2), m.Groups(3))End Function

// C#static string ReformatPhone(string s){ Match m = Regex.Match(s, @"^(?(\d{3}))?[\s\-]?(\d{3})\-?(\d{4})$"); return String.Format("({0}) {1}-{2}", m.Groups[1], m.Groups[2], m.Groups[3]);}

2. ' VBFunction ReformatPhone(ByVal s As String) As String Dim m As Match = Regex.Match(s, "^\(?(\d{3})\)?[\s\-]?(\d{3})\-?(\d{4})$") Return String.Format("({0}) {1}-{2}", m.Groups(0), m.Groups(1), m.Groups(2))End Function

// C#static string ReformatPhone(string s){ Match m = Regex.Match(s, @"^\(?(\d{3})\)?[\s\-]?(\d{3})\-?(\d{4})$"); return String.Format("({0}) {1}-{2}", m.Groups[0], m.Groups[1], m.Groups[2]);}

3. ' VBFunction ReformatPhone(ByVal s As String) As String Dim m As Match = Regex.Match(s, "^\(?\d{3}\)?[\s\-]?(\d{3})\-?(\d{4})$") Return String.Format("({0}) {1}-{2}", m.Groups(1), m.Groups(2), m.Groups(3))End Function

// C#static string ReformatPhone(string s){ Match m = Regex.Match(s, @"^\(?(\d{3})\)?[\s\-]?(\d{3})\-?(\d{4})$"); return String.Format("({0}) {1}-{2}", m.Groups[1], m.Groups[2], m.Groups[3]);}

4. ' VBFunction ReformatPhone(ByVal s As String) As String Dim m As Match = Regex.Match(s, "^\(?(\d{3})\)?[\s\-]?(\d{3})\-?(\d{4})$") Return String.Format("({0}) {1}-{2}", m.Groups(1), m.Groups(2), m.Groups(3))End Function

// C#static string ReformatPhone(string s){ Match m = Regex.Match(s, @"^\(?(\d{3})\)?[\s\-]?(\d{3})\-?(\d{4})$"); return String.Format("({0}) {1}-{2}", m.Groups[1], m.Groups[2], m.Groups[3]);} <Correct>

Explanation :To extract information from a string, create a regular expression and surround the matched text with parentheses. In the case of a phone number, you must match one group of three numbers, a second group of three numbers, and a final group of four numbers. Therefore, you need three separate groups. Then compare the string to the regular expression using Regex.Match. The first matched group is placed into the 1 element of the Match.Groups collection, the second matched group is placed into

the 2 element, and the third group is placed into the 3 element.

Parentheses that are preceded with a backslash are treated as literal parentheses by the regular expression matching engine.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.RegularExpressions namespace) Group class and GroupCollection class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 3 - Lesson 1

Regular Expression ClassesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/30wbz966.aspx

Regex ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 76 (536P_2.2.6_01)

_________________________________________________________________________________________________________________

What output does the following code sample produce?

' VBDim myThreadDelegate As New ThreadStart(AddressOf ThreadWork.DoWork)Dim myThread As New Thread(myThreadDelegate)Console.WriteLine(myThread.ThreadState.ToString())myThread.Start()Console.WriteLine(myThread.ThreadState.ToString())

// C#ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork);Thread myThread = new Thread(myThreadDelegate);Console.WriteLine(myThread.ThreadState.ToString());myThread.Start();Console.WriteLine(myThread.ThreadState.ToString());

1. WaitSleepJoinRunning

2. UnchangedRunning

3. UnstartedRunning <Correct>

4. SuspendedRunning

Explanation :When you create a managed thread it is in the Unstarted state. After you call Thread.Start, it changes to the Running state.

The Unchanged state occurs only when a second thread calls System.Threading.Thread.Start.

The Suspended state occurs when you call System.Threading.Thread.Suspend.

The WaitSleepJoin state occurs when you call System.Threading.Thread.Sleep, System.Threading.Thread.Wait, or System.Threading.Thread.Join.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Develop multithreaded .NET Framework applications. (Refer System.Threading namespace) ThreadState enumeration and ThreadPriority enumeration

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 7 - Lesson 1

Managed Thread StatesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/d6122999.aspx

Thread.ThreadState PropertyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.threading.thread.threadstate.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 77 (536P_6.2.8_03)

_________________________________________________________________________________________________________________

How does platform invoke marshal strings from managed to unmanaged code?

1. Passes the pointer to the string

2. Copies the string from ANSI to Unicode

3. Converts the string from Unicode to ANSI, and passes the pointer to the string

4. Converts the string from ANSI to Unicode, and passes the pointer to the string

5. Copies the string from Unicode to ANSI <Correct>

Explanation :Platform invoke copies strings and converts them from Unicode (used by the .NET Framework) to ANSI (used by unmanaged code).

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Call unmanaged DLL functions in a .NET Framework application, and control the marshaling of data in a .NET Framework application. (Refer System.Runtime.InteropServices namespace) Marshal data with Platform Invoke

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 13 - Lesson 3

Marshaling StringsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/e8w969hb(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 78 (536P_5.4.5_02)

_________________________________________________________________________________________________________________

Which of the following is a valid key length for the TripleDES symmetric cryptography class?

1. 64 bits

2. 1024 bits

3. 256 bits

4. 512 bits

5. 128 bits <Correct>

Explanation :TripleDES supports key lengths from 128 bits to 192 bits in increments of 64 bits.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace) TripleDES and TripleDESCryptoServiceProvider class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 3

Cryptography OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/92f9ye3s.aspx

TripleDES.Key PropertyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.cryptography.tripledes.key.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 79 (536P_5.4.3_01)

_________________________________________________________________________________________________________________

Which of the following classes provide asymmetric digital signatures?

1. RSACryptoServiceProvider

2. DES

3. TripleDES

4. DSACryptoServiceProvider <Correct>

5. RijndaelManaged

6. RC2

Explanation :DSACryptoServiceProvider provides asymmetric digital signatures.

RSACryptoServiceProvider provides asymmetric encryption; it does not provide digital signatures.

RijndaelManaged, DES, RC2, and TripleDES are all symmetric encryption classes.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace) DSA class and DSACryptoServiceProvider class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 3

DSACryptoServiceProvider ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.cryptography.dsacryptoserviceprovider.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 80 (536P_6.1.2_02)

_________________________________________________________________________________________________________________

A .NET Framework assembly can access which aspects of a COM object? (Choose all that apply.)

1. Methods <Correct>

2. Properties <Correct>

3. Events <Correct>

Explanation :A .NET client can call methods on an active COM object, adjust its properties, and catch events originating on the server.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Expose COM components to the .NET Framework and the .NET Framework components to COM. (Refer System.Runtime.InteropServices namespace) Create COM types in managed code.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 13 - Lesson 1

Calling Methods, Properties, and EventsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/63x1203s(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 81 (536P_5.1.3_01)

_________________________________________________________________________________________________________________

Which of the following tools would you use to examine and modify code access security policies from a batch file?

1. GacUtil.exe

2. Sn.exe

3. Caspol.exe <Correct>

4. StoreAdm.exe

Explanation :You can use the Code Access Security Policy tool (Caspol.exe) to examine and modify Machine-, User-, and Enterprise-level code access security policies. Although the .NET Framework Configuration tool is the most convenient tool to use for manual configuration, Caspol provides similar functionality at the command line or within a batch file.

Use StoreAdm.exe to manage isolated storage.

Use Sn.exe to manage strong names.

Use GacUtil.exe to manage the global assembly cache.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement code access security to improve the security of a .NET Framework application. (Refer System.Security namespace) Modify the Code Access security policy at the computer, user, and enterprise policy level by using the Code Access Security Policy tool (Caspol.exe).

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 1

Code Access Security Policy Tool (Caspol.exe)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/cb6t8dtz.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 82 (536P_5.3_06)

_________________________________________________________________________________________________________________

The HashAlgorithmType enumeration specifies the algorithm used for generating message authentication codes (MACs) in Secure Sockets Layer (SSL) communications. Which of the following are valid values for HashAlgorithmType? (Choose all that apply.)

1. Md5 <Correct>

2. Des

3. Sha1 <Correct>

4. Rsa

5. TripleDes

6. None <Correct>

Explanation :Md5, Sha1, and None are valid values for HashAlgorithmType. MD5 and SHA1 are hash algorithms.

RSA, DES, and TripleDES are encryption algorithms, and therefore are not valid values for HashAlgorithmType.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement a custom authentication scheme by using the System.Security.Authentication classes. (Refer System.Security.Authentication namespace)

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 1

HashAlgorithmType EnumerationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.authentication.hashalgorithmtype(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 83 (536P_1.1.2_07)

_________________________________________________________________________________________________________________

You are part of a development team that is creating a complex application for internal use within your organization. You are responsible for creating a set of classes. Per the design specification created by your team, you need to create a base class with multiple child classes. Developers can then choose whether to work with the base class (which you have named BaseClass) or a child class (such as ChildClassA and ChildClassB).

In some circumstances, developers will need to convert between classes. Which of the following conversions will the runtime perform without throwing an exception? (Choose all that apply.)

1. ' VBDim c As ChildClassA = CType(New BaseClass, ChildClassA)Dim b As BaseClass = CType(c, BaseClass)

// C#ChildClassA c = (ChildClassA)new BaseClass();BaseClass b = (BaseClass)c;

2. ' VBDim c As ChildClassA = New ChildClassADim b As BaseClass = CType(c, BaseClass)

// C#ChildClassA c = new ChildClassA();BaseClass b = (BaseClass)c;

<Correct>

3. ' VBDim b As BaseClass = New ChildClassADim c As ChildClassA = CType(b, ChildClassA)

// C#BaseClass b = new ChildClassA();ChildClassA c = (ChildClassA)b;

<Correct>

4. ' VBDim b As BaseClass = New BaseClassDim c As ChildClassA = CType(b, ChildClassA)

// C#BaseClass b = new BaseClass();ChildClassA c = (ChildClassA)b;

Explanation :The .NET Framework allows an instance of a base class to be cast to a child class if that variable contains a reference to a child object at runtime. Additionally, child classes can be cast to a base class.

Base classes cannot be cast to a child class if that variable does not contain a reference to a child object.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Reference types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

Casting (C# Programming Guide)

MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms173105.aspx

CType FunctionMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/4x2877xb.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 84 (536P_7.3.2_07)

_________________________________________________________________________________________________________________

You are creating an application that processes large text log files using regular expressions. Which of the following regular expression options is required to match individual rows of the text file?

1. RegexOptions.Multiline <Correct>

2. RegexOptions.Singleline

3. RegexOptions.CultureInvariant

4. RegexOptions.None

Explanation :RegexOptions.Multiline specifies multiline mode, which changes the meaning of ^ and $ so that they match at the beginning and end, respectively, of any line, not just the beginning and end of the whole string. This enables you to process each line of a multiline file.

RegexOptions.None specifies no options. By default, regular expressions would treat the entire text file as a single string.

RegexOptions.Singleline specifies single-line mode, which is the default.

RegexOptions.CultureInvariant specifies that cultural differences in language are ignored, and it does not affect multiline processing.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.RegularExpressions namespace) Regex class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 3 - Lesson 1

Regular Expression ClassesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/30wbz966.aspx

Regex ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx

RegexOptions EnumerationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.text.regularexpressions.regexoptions.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 85 (536P_4.1.1_04)

_________________________________________________________________________________________________________________

Which of the following is a valid reason to implement the ISerializable interface and respond to the Deserialized event?

1. You need to define a value prior to serialization.

2. The serialized data contains custom formatting.

3. You are using XML serialization.

4. You need to define a value that is not available in the serialized data.<Correct>

Explanation :You should respond to the Deserialized event when you need to define a value that was not contained in the serialized data. Typically, summary values such as totals are not serialized and must be defined by responding to the Deserialized event.

The Deserialized event occurs after deserialization and cannot be used to read custom formatting in serialized data.

XML serialization does not support serialization events.

To define a value prior to serialization, you should respond to the Serializing event, not the Deserialized event.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) Serialization interfaces

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 1

Custom SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ty01x675.aspx

Basics of .NET Framework SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms233836.aspx

ISerializable InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.iserializable.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 86 (536P_7.3.3_01)

_________________________________________________________________________________________________________________

Which of the following code samples stores "Contoso, Inc." in the companyName string?

1. ' VBDim input As String = "Company Name: Contoso, Inc."Dim m As Match = Regex.Match(input, "Company Name:.*$")Dim companyName as String = m.Groups(1).ToString()

// C#string input = "Company Name: Contoso, Inc.";Match m = Regex.Match(input, @"Company Name: .*$");string companyName = m.Groups[1].ToString();

2. ' VBDim input As String = "Company Name: Contoso, Inc."Dim m As Match = Regex.Match(input, "Company Name: (.*$)")Dim companyName as String = m.Value(0).ToString()

// C#string input = "Company Name: Contoso, Inc.";Match m = Regex.Match(input, @"Company Name: (.*$)");string companyName = m.Value[0].ToString();

3. ' VBDim input As String = "Company Name: Contoso, Inc."Dim m As Match = Regex.Match(input, "Company Name: (.*$)")Dim companyName as String = m.Groups(1).ToString()

// C#string input = "Company Name: Contoso, Inc.";Match m = Regex.Match(input, @"Company Name: (.*$)");string companyName = m.Groups[1].ToString();

<Correct>

4. ' VBDim input As String = "Company Name: Contoso, Inc."Dim m As Match = Regex.Match(input, "Company Name: (.*$)")Dim companyName as String = m.Groups(0).ToString()

// C#string input = "Company Name: Contoso, Inc.";Match m = Regex.Match(input, @"Company Name: (.*$)");string companyName = m.Groups[0].ToString();

Explanation :To extract information from a string, create a regular expression and surround the matched text with parentheses. Then compare the string to the regular expression using Regex.Match. The first matched group is placed into the 1 element of the Match.Groups collection.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.RegularExpressions namespace) Match class and MatchCollection class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 3 - Lesson 1

Regular Expression Classes

MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/30wbz966.aspx

Regex ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 87 (536P_6.1.4_01)

_________________________________________________________________________________________________________________

You have created an interop assembly that will be accessed by multiple .NET Framework applications on each computer. You want to make a single version of the interop assembly available to all applications. What is the best way to do this?

1. Place the interop assembly in a shared folder on the network, and reference the assembly using a universal naming convention (UNC) path.

2. Place the interop assembly in the system directory.

3. Install the interop assembly in the global assembly cache. <Correct>

4. Place the interop assembly in the root of the C:\ drive.

Explanation :Assemblies shared by multiple applications should be installed in a centralized repository called the global assembly cache (GAC). .NET clients can access the same copy of the interop assembly, which is signed and installed in the global assembly cache.

While you can reference assemblies located in a specific directory, installing an assembly in the GAC provides greater reliability and ease of maintanence.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Expose COM components to the .NET Framework and the .NET Framework components to COM. (Refer System.Runtime.InteropServices namespace) Deploy an interop application.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 13 - Lesson 1

Deploying an Interop ApplicationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/tc0204w0(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 88 (536P_3.5.1_01)

_________________________________________________________________________________________________________________

You are in the process of isolating a complicated bug in a console application that occurs only in rare circumstances. You would like to pause execution to examine the values of variables during debugging, but you do not want to pause execution when users run release versions of the application. Which method should you call?

1. Console.Read

2. Debug.Assert

3. Debugger.Break <Correct>

4. Console.ReadLine

Explanation :Debugger.Break acts just like a hard-coded breakpoint, except you can call it programmatically.

Console.Read and Console.ReadLine interrupt processing in both debug and release versions of code.

Debug.Assert validates a value and does not stop execution during debugging.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Debug and trace a .NET Framework application by using the System.Diagnostics namespace. Debug class and Debugger class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 2

Debugger.Break MethodMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.debugger.break.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 89 (536P_7.2.2_03)

_________________________________________________________________________________________________________________

Which class would it be most efficient for you use to draw a question mark in a dialog box?

1. Icon

2. SystemIcons <Correct>

3. Bitmap

4. Image

Explanation :The SystemIcons class includes a variety of icon properties, including a question mark.

The Icon class is used to define new icons. You could use this to manually create a question mark, but it is not as efficient as using the SystemIcons class.

The Bitmap and Image classes can be used to draw any type of shape, but neither is as efficient as using the SystemIcons class.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the user interface of a .NET Framework application by using the System.Drawing namespace. Enhance the user interface of a .NET Framework application by using graphics, images, bitmaps, and icons.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 6 - Lesson 2

SystemIcons ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.drawing.systemicons.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 90 (536P_5.1.1_01)

_________________________________________________________________________________________________________________

Which of the following If statements correctly identifies whether the current assembly has permission to read the C:\Boot.ini file?

1. ' VBIf SecurityManager.CheckExecutionRights _(New FileIOPermission(FileIOPermissionAccess.Read, "C:\Boot.ini")) Then

// C#if (SecurityManager.CheckExecutionRights(new FileIOPermission(FileIOPermissionAccess.Read, @"C:\boot.ini")))

2. ' VBIf SecurityManager.IsGranted(FileIOPermissionAccess.Read, "C:\Boot.ini") Then

// C#if (SecurityManager.IsGranted(FileIOPermissionAccess.Read, @"C:\boot.ini"))

3. ' VBIf SecurityManager.CheckExecutionRights _(FileIOPermissionAccess.Read, "C:\Boot.ini") Then

// C#if (SecurityManager.CheckExecutionRights(FileIOPermissionAccess.Read, @"C:\boot.ini"))

4. ' VBIf SecurityManager.IsGranted _(New FileIOPermission(FileIOPermissionAccess.Read, "C:\Boot.ini")) Then

// C#if (SecurityManager.IsGranted(new FileIOPermission(FileIOPermissionAccess.Read, @"C:\boot.ini")))

<Correct>

Explanation :Use SecurityManager.IsGranted to imperatively determine whether the current process has a specific permission.

You must provide a Permission object to SecurityManager.IsGranted. You cannot provide a FileIOPermissionAccess enumeration.

SecurityManager.CheckExecutionRights only determines whether the process must have System.Security.Permissions.SecurityPermissionFlag.Execution to execute.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement code access security to improve the security of a .NET Framework application. (Refer System.Security namespace) SecurityManager class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 3

SecurityManager ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.securitymanager(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 91 (536P_4.7.1_01)

_________________________________________________________________________________________________________________

Which of the following commands would you use to view isolated storage stores?

1. Storeadm <Correct>

2. ls

3. Dir

4. Net View

Explanation :The Storeadm tool is a command-line tool for listing and deleting isolated storage stores. Use the command storeadm /list to view stores, and storeadm /remove to delete stores.

Dir is a command for viewing a list of convential files and folders, and it cannot be used for isolated storage.

Use Net View to view network shares. It cannot connect to isolated storage.

The UNIX command ls is used for viewing a list of conventional files and folders, and it cannot be used for isolated storage.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Compress or decompress stream information in a .NET Framework application (refer System.IO.Compression namespace), and improve the security of application data by using isolated storage. (Refer System.IO.IsolatedStorage namespace) IsolatedStorageFile class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 4

Isolated Storage Tool (Storeadm.exe)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ezabwsbk.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 92 (536P_6.2.8_01)

_________________________________________________________________________________________________________________

Which of the following managed classes corresponds to the unmanaged LPSTR class?

1. Double

2. IntPtr

3. UInt16

4. Int32

5. String <Correct>

Explanation :LPSTR corresponds to the String managed class.

The UInt16 managed class corresponds to the WORD unmanaged type.

The Int32 managed class corresponds to the INT, LONG, or BOOL unmanaged types.

The Double managed class corresponds to the DOUBLE unmanaged type.

The IntPtr managed class corresponds to the HANDLE unmanaged type.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Call unmanaged DLL functions in a .NET Framework application, and control the marshaling of data in a .NET Framework application. (Refer System.Runtime.InteropServices namespace) Marshal data with Platform Invoke

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 13 - Lesson 3

Platform Invoke Data TypesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ac7ay120(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 93 (536P_1.2.4_01)

_________________________________________________________________________________________________________________

The Hashtable collection stores entries in which of the following types of objects?

1. Stack

2. Object

3. DictionaryBase

4. DictionaryEntry <Correct>

Explanation :The Hashtable collection stores entries in DictionaryEntry objects.

The Hashtable collection does not store entries in instances of the Object class.

The Hashtable collection does not store entries in instances of the DictionaryBase class.

The Hashtable collection does not store entries in instances of the Stack class.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage a group of associated data in a .NET Framework application by using collections. (Refer System.Collections namespace) Hashtable class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 4 - Lesson 3

Hashtable ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/system.collections.hashtable.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 94 (536P_1.6.3_03)

_________________________________________________________________________________________________________________

Which of the following code samples would cause the Respond method to be called if the e.Event event occurred?

1. ' VBAddHandler Respond(e.Event)

// C#Respond(e.EventHandler);

2. ' VBAddHandler e.Event, AddressOf Respond

// C#e.Event += new E.EventHandler(Respond);

<Correct>

3. ' VBe.Event += new E.EventHandler(Respond);

// C#AddHandler e.Event, AddressOf Respond

4. ' VBAddHandler e.Event(Respond)

// C#E.EventHandler(Respond);

Explanation :In Microsoft Visual Basic, use the AddHandler keyword and provide the event and the address of the event handler. In Microsoft Visual C#, add the event handler to the event.

Objective:Developing applications that use system types and collections

Sub Objective(s):Control interactions between .NET Framework application components by using events and delegates. (Refer System namespace) EventHandler delegates

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

How to: Connect Event Handler Methods to EventsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/xwbwks95(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 95 (536P_4.1.1_05)

_________________________________________________________________________________________________________________

You are creating a class that responds to serialization events. Which of the following classes will trigger the serialization events?

1. BinaryFormatter <Correct>

2. XmlSerializer

3. SoapFormatter

4. IFormatter

Explanation :Only the BinaryFormatter class supports serialization events.

The SoapFormatter class does not support serialization events.

XMLSerializer does not support serialization events.

IFormatter is an interface and cannot be directly used to perform serialization.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) Serialization interfaces

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 1

BinaryFormatter ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.formatters.binary.binaryformatter.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 96 (536P_1.2.3_02)

_________________________________________________________________________________________________________________

What is the purpose of using an iterator in C#?

1. It enables an array to be sorted.

2. It improves the performance of value types.

3. It is the only way for a class to be compatible with a for-each loop.

4. It simplifies the implementation of the IEnumerable interface.<Correct>

Explanation :Iterators in C# simplify the implementation of the IEnumerable interface. When the compiler detects your iterator, it will automatically generate the Current, MoveNext, and Dispose methods of the IEnumerable or IEnumerable interface.

Iterators do make a class compatible with a for-each loop. However, it is not the only way; you can also implement the IEnumerable interface.

Iterators do not enable an array to be sorted.

Iterators do not improve performance.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage a group of associated data in a .NET Framework application by using collections. (Refer System.Collections namespace) Iterators

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 4 - Lesson 3

Iterators (C# Programming Guide)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/dscyy5s0(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 97 (536P_3.1.1_03)

_________________________________________________________________________________________________________________

Which class would you use to programmatically access the connection strings stored in the following configuration file?

<?xml version="1.0" encoding="utf-8" ?><configuration> <connectionStrings> <clear/> <add name="AdventureWorksString" providerName="System.Data.SqlClient" connectionString="Data Source=localhost;Initial Catalog=AdventureWorks; Integrated Security=true"/> <add name="MarsEnabledSqlServer2005String" providerName="System.Data.SqlClient" connectionString="Server=Aron1;Database=pubs;Trusted_Connection=True;MultipleActiveResultSets=true" /> <add name="OdbcConnectionString" providerName="System.Data.Odbc" connectionString="Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\adatabase.mdb;Uid=Admin;Pwd=R3m3emberToUseStrongPasswords;"/> </connectionStrings></configuration>

1. ConfigurationSection.ConnectionStrings

2. ConfigurationSettings.ConnectionStrings

3. ConfigurationManager.ConnectionStrings <Correct>

4. ConfigurationProperty.ConnectionStrings

Explanation :Use ConfigurationManager.ConnectionStrings to access database connection strings.

ConfigurationSettings is obsolete.

ConfigurationSection does not have a ConnectionStrings property.

ConfigurationProperty does not have a ConnectionStrings property.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Embed configuration management functionality into a .NET Framework application. (Refer System.Configuration namespace) Configuration class and ConfigurationManager class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 1

ConfigurationManager.ConnectionStrings PropertyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.configuration.configurationmanager.connectionstrings.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 98 (536P_7.1.5_01)

_________________________________________________________________________________________________________________

You are writing an application for a business with very specific regional requirements. Unfortunately, the .NET Framework does not currently include a culture that matches your requirements. How can you define and create a custom culture?

From the list on the right, select the tasks that you should perform to define and create a custom culture. Place your selections in the list on the left in the order in which the tasks should be performed. Place your selections in the list on the left by clicking the items in the list on the right and clicking the arrow. You can also use the Up and Down buttons to rearrange items in the list on the left. You might not need to use all the items from the list on the right.

Explanation :To define and create a custom culture:

1. Define and name your culture using an instance of CultureAndRegionInfoBuilder.2. Define the unique aspects of your culture by updating your CultureAndRegionInfoBuilder object.3. Register your culture by calling the Register method.4. Create a CultureInfo object by specifying the name of your customer culture.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Format data based on culture information. (Refer System.Globalization namespace) Build a custom culture class based on existing culture and region classes.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 16 - Lesson 2

How to: Create Custom CulturesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms172469.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 99 (536P_2.2.1_02)

_________________________________________________________________________________________________________________

What happens when you call Thread.Suspend() on a thread?

1. The runtime performs garbage collection on the thread, and then terminates the thread.

2. The runtime immediately pauses execution of the thread.

3. The runtime notes that a thread suspension has been requested and allows the thread to execute until it has reached a safe point before actually suspending the thread. <Correct>

4. The runtime immediately terminates the thread.

Explanation :When you call Thread.Suspend on a thread, the system notes that a thread suspension has been requested and allows the thread to execute until it has reached a safe point before actually suspending the thread. A safe point for a thread is a point in its execution at which garbage collection can be performed. Once a safe point is reached, the runtime guarantees that the suspended thread will not make any further progress in managed code. A thread executing outside managed code is always safe for garbage collection, and its execution continues until it attempts to resume execution of managed code.

Suspend does eventually pause execution of a thread, but only when it has reached a safe point.

Suspend does not cause a thread to be terminated. Instead, you would call Thread.Abort() to begin the process of terminating a thread.

Thread.Suspend does not initiate garbage collection.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Develop multithreaded .NET Framework applications. (Refer System.Threading namespace) Thread class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 7 - Lesson 1

Thread.Suspend, Garbage Collection, and Safe PointsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/678ysw69.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 100 (536P_4.1.3_01)

_________________________________________________________________________________________________________________

You are creating a custom class that implements the ISerializable interface. The following code shows the deserialization constructor in its current state:

' VB' The following constructor is for deserializationProtected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext) MyBase.New() ' TODO: Copy deserialized data

End Sub

// C#// The following constructor is for deserializationprotected ShoppingCartItem(SerializationInfo info, StreamingContext context){ // TODO: Copy deserialized data}

How will you retrieve the deserialized data?

1. Copy the data from the context.Data collection.

2. Copy the data from the info.Data collection.

3. Copy the data from the context.GetValue method.

4. Copy the data from the info.GetValue method. <Correct>

Explanation :Deserialized data is stored in the SerializationInfo object, and it can be retrieved using the GetValue method or one of the other Get methods.

The StreamingContext object describes the source that provided the serialized data and does not contain the data itself.

There is no Data collection in either the SerializationInfo or StreamingContext classes.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) SerializationEntry structure and SerializationInfo class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 3

SerializationInfo ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.serializationinfo.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 101 (536P_5.4.14_02)

_________________________________________________________________________________________________________________

Which of the following are valid key lengths for the RijndaelManaged symmetric cryptography class? (Choose all that apply.)

1. 512 bits

2. 1024 bits

3. 128 bits <Correct>

4. 256 bits <Correct>

5. 64 bits

Explanation :The RijndaelManaged class can use key lengths of 128 through 256 bits, in 32-bit increments.

512 and 1024 bits are too large for the RijndaelManaged class.

64 bits is too small for the RijndaelManaged class.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace) RijndaelManaged class and RijndaelManagedTransform class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 3

Cryptography OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/92f9ye3s.aspx

RijndaelManaged ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 102 (536P_5.3_01)

_________________________________________________________________________________________________________________

You are writing an application that connects to a network resource using SslStream. Which of the following types of exceptions should you catch so that you can retry authentication with a different set of credentials if authentication fails?

1. InvalidCredentialException

2. FatalAuthenticationException

3. Exception

4. AuthenticationException <Correct>

Explanation :The NegotiateStream and SslStream classes throw an AuthenticationException when the client or server cannot be authenticated. When this exception is thrown, you can retry the authentication with different credentials.

If a FatalAuthenticationException is thrown, you cannot retry authentication.

If an InvalidCredentialException is thrown, the underlying stream is not in a valid state and you cannot retry the authentication using the NegotiateStream or SslStream instance.

While catching an Exception would catch any authentication exception, it would not allow you to distinguish between authentication errors that allow retrying different credentials.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement a custom authentication scheme by using the System.Security.Authentication classes. (Refer System.Security.Authentication namespace)

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 1

AuthenticationException ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.authentication.authenticationexception.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 103 (536P_3.1.2_02)

_________________________________________________________________________________________________________________

You need to establish a database connection to a server based on configuration information stored in the application's configuration file. Which of the following properties would you examine to determine the server name?

1. ' VBConnectionStringSettings.ElementInformation.Properties("Name")

// C#ConnectionStringSettings.ElementInformation.Properties["Name"]

2. ConnectionStringSettings.ConnectionString

3. ConnectionStringSettings.ProviderName

4. ConnectionStringSettings.Name <Correct>

Explanation :ConnectionStringSettings.Name stores the server name.

The ConnectionStringSettings.ProviderName describes the database type and allows you to distinguish between Oracle, SQL Server, and other databases.

ConnectionStringSettings.ConnectionString stores the entire connection string, which does not include the server name.

ConnectionStringSettings.ElementInformation.Properties contains all the attributes that apply to the element. It does not normally include a Name element.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Embed configuration management functionality into a .NET Framework application. (Refer System.Configuration namespace) ConfigurationElement class, ConfigurationElementCollection class, and ConfigurationElementProperty class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 4

ConnectionStringSettings PropertiesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.configuration.connectionstringsettings_properties.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 104 (536P_1.1.6_01)

_________________________________________________________________________________________________________________

Which of the following samples demonstrates boxing?

1. ' VBDim d As Double = 123 Dim i As Integer = CType(d, Integer)

// C#double d = 123;int i = (int)d;

2. ' VBDim i As Integer = 123 Dim d As Double = i

// C#int i = 123;double d = i;

3. ' VBDim o As Object = 123 Dim i As Integer = CType(o, Integer)

// C#object o = 123;int i = (int) o;

4. ' VBDim i As Integer = 123 Dim o As Object = CType(i, Object)

// C#int i = 123;object o = (object) i;

<Correct>

Explanation :Boxing converts a value type to a reference type. In this example, the Integer object is a value type, and the instance of the Object class is a reference type. Converting from the value type to the reference type requires boxing.

Converting from a reference type to a value type is unboxing.

Converting between two value types requires neither boxing nor unboxing.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Boxing and UnBoxing

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 4

Boxing and Unboxing (C# Programming Guide)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/yz2be5wk.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 105 (536P_7.3.2_03)

_________________________________________________________________________________________________________________

Which of the following regular expressions would you use to validate a phone number?

1. http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?

2. ((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4} <Correct>

3. \d{5}

4. ([^@]+)@(.+)

Explanation :((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4} validates a well-formed phone number.

([^@]+)@(.+) validates a well-formed e-mail address.

http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)? validates a well-formed URL.

\d{5} validates a postal code.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.RegularExpressions namespace) Regex class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 3 - Lesson 1

Validating User InputMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms172105.aspx

Regular Expression ClassesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/30wbz966.aspx

Regex ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 106 (536P_6.3.1_01)

_________________________________________________________________________________________________________________

Within your .NET Framework version 2.0 assembly, you need to load a .NET Framework version 1.1 assembly to examine its metadata given its filename. Which method would you use?

1. Assembly.ReflectionOnlyLoadFrom <Correct>

2. Assembly.ReflectionOnlyLoad

3. Assembly.LoadModule

4. Assembly.LoadFile

Explanation :Assembly.ReflectionOnlyLoadFrom loads an assembly into the reflection-only context, given its filename.

Assembly.ReflectionOnlyLoad loads an assembly into the reflection-only context, given its display name.

Assembly.LoadModule loads a module internal to the assembly.

Assembly.LoadFile loads the entire contents of an assembly, not just the metadata.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Implement reflection functionality in a .NET Framework application (refer System.Reflection namespace), and create metadata, Microsoft intermediate language (MSIL), and a PE file by using the System.Reflection.Emit namespace. Assembly class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 14 - Lesson 1

How to: Load Assemblies into the Reflection-Only ContextMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms172331(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 107 (536P_5.4.14_01)

_________________________________________________________________________________________________________________

You are creating an assembly and need to encrypt data. Nobody has provided encryption requirements for you. Which symmetric cryptography class should you use?

1. RijndaelManaged <Correct>

2. RC2

3. DES

4. TripleDES

Explanation :RijndaelManaged, an implementation of Advanced Encryption Standard (AES), is a strong government encryption standard and is the only .NET Framework symmetric encryption class that is fully managed. All other encryption classes call unmanaged code. Because of this, RijndaelManaged is the preferred choice when your application will be running in a partially trusted environment.

The Data Encryption Standard (DES) is a symmetric encryption algorithm that uses relatively short key lengths that are vulnerable to cracking attacks. For that reason, it should be avoided.

RC2 is an encryption standard designed to replace DES that uses variable key sizes. It is more secure than DES.

TripleDES is the .NET Framework implementation of the Triple DES (3DES) symmetric encryption algorithm. It essentially applies the DES algorithm three times. It is approximately twice as strong as standard DES.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace) RijndaelManaged class and RijndaelManagedTransform class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 3

Cryptography OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/92f9ye3s.aspx

SymmetricAlgorithm ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.cryptography.symmetricalgorithm.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 108 (536P_2.2.2_01)

_________________________________________________________________________________________________________________

You are writing a multithreaded application. In which circumstances should you use thread pools?

1. You require a thread to have a particular priority.

2. You require a background thread. <Correct>

3. You have tasks that cause the thread to block for long periods of time.

4. You require a foreground thread.

Explanation :Thread pools are perfect if you require a background thread, because it is an easier way to take advantage of multiple threads.

If you have tasks that cause the thread to block for long periods of time, you should not use thread pools. The thread pool has a maximum number of threads, so a large number of blocked thread pool threads might prevent tasks from starting.

You cannot specify the priority of a thread pool.

Thread pools cannot operate as foreground threads.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Develop multithreaded .NET Framework applications. (Refer System.Threading namespace) ThreadPool class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 7 - Lesson 3

The Managed Thread PoolMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/0ka9477y.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 109 (536P_1.1.5_07)

_________________________________________________________________________________________________________________

What type of exception does the runtime throw for the following code sample?

' VBDim b As BaseClass = New BaseClassDim c As ChildClassA = CType(b, ChildClassA)

// C#BaseClass b = new BaseClass();ChildClassA c = (ChildClassA)b;

1. ArgumentException

2. InvalidCastException <Correct>

3. NotSupportedException

4. InvalidConvertException

Explanation :Base classes cannot be cast to a child class if that variable does not contain a reference to a child object. Therefore, this conversion causes the runtime to throw an InvalidCastException.

The runtime throws an ArgumentException when you pass an invalid value to a method.

The .NET Framework does not include an InvalidConvertException.

The runtime throws a NotSupportedException when there is an attempt to read, seek, or write to a stream that does not support the invoked functionality.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Exception classes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

Casting (C# Programming Guide)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms173105.aspx

CType FunctionMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/4x2877xb.aspx

InvalidCastException ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.invalidcastexception(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 110 (536P_1.2.3_01)

_________________________________________________________________________________________________________________

Which of the following C# code samples would enable a class to implement the IEnumerator interface? (Choose all that apply.)

1. // C#public void GetEnumerator(){ for (int i = 0; i < max; i++) { yield return i; }}

2. // C#public System.Collections.IEnumerator GetEnumerator(){ yield return "a"; yield return "b"; yield return "c"; yield return "d";} <Correct>

3. // C#public void GetEnumerator(){ yield return "a"; yield return "b"; yield return "c"; yield return "d";}

4. // C#public System.Collections.IEnumerator GetEnumerator(){ for (int i = 0; i < max; i++) { yield return i; }} <Correct>

Explanation :To create an iterator in C#, create a GetEnumerator method that returns an IEnumerator object. Then use the yield keyword when you return a value. Iterators can have multiple return values.

Iterators cannot return void.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage a group of associated data in a .NET Framework application by using collections. (Refer System.Collections namespace) Iterators

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 4 - Lesson 3

Iterators (C# Programming Guide)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/dscyy5s0(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 111 (536P_7.1.4_01)

_________________________________________________________________________________________________________________

Which of the following code samples correctly performs a culture-insensitive string comparison?

1. ' VBDim s1 As String = "Apple"Dim s2 As String = "髖le"Dim r As Integer = String.Compare(s1, s2, False, CultureInfo.CreateSpecificCulture("da-DK"))

// C#string s1 = "Apple";string s2 = "髖le"; int r = String.Compare(s1, s2, false, CultureInfo.CreateSpecificCulture("da-DK"));

2. ' VBDim s1 As String = "Apple"Dim s2 As String = "髖le"Dim r As Integer = String.Compare(s1, s2, False, CultureInfo.InvariantCulture)

// C#string s1 = "Apple";string s2 = "髖le"; int r = String.Compare(s1, s2, false, CultureInfo.InvariantCulture);

<Correct>

3. ' VBDim s1 As String = "Apple"Dim s2 As String = "髖le"Dim r As Integer = String.Compare(s1, s2, False)

// C#string s1 = "Apple";string s2 = "髖le"; int r = String.Compare(s1, s2, false);

4. ' VBDim s1 As String = "Apple"Dim s2 As String = "髖le"Dim r As Integer = String.Compare(s1, s2, False, CultureInfo.CurrentUICulture)

// C#string s1 = "Apple";string s2 = "髖le"; int r = String.Compare(s1, s2, false, CultureInfo.CurrentUICulture);

Explanation :By default, string comparisons are culture sensitive. To perform culture-insensitive comparisons, pass the CultureInfo.InvariantCulture parameter.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Format data based on culture information. (Refer System.Globalization namespace) Perform culture-sensitive string comparison.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 16 - Lesson 1

How to: Use Finally BlocksMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ke0zf0f5.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 112 (536P_4.1.6_01)

_________________________________________________________________________________________________________________

What type of object would you use during custom serialization to determine how the serialized data will be transferred and used?

1. StreamingContext <Correct>

2. SerializationEntry

3. SerializationInfo

4. ObjectManager

Explanation :The StreamingContext structure describes the source and destination of a given serialized stream, and provides an additional caller-defined context. However, the method performing the serialization must define the StreamingContext structure; it does not happen automatically.

The SerializationEntry structure holds the value, type, and name of a serialized object. It does not describe the context of serialization.

The SerializationInfo class stores all the data needed to serialize or deserialize an object. It does contain a StreamingContext structure as a member, but you would need to directly access the StreamingContext object to determine how serialization data will be transferred.

The ObjectManager class keeps track of objects as they are deserialized and does not describe the serialization context.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) StreamingContext structure

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 3

StreamingContext StructureMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.streamingcontext.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 113 (536P_4.1.3_02)

_________________________________________________________________________________________________________________

You are creating a class that implements the ISerializable interface to perform custom serialization. Which of the following code samples correctly overrides the GetObjectData method and serializes the firstName, lastName, and age values?

1. ' VBPublic Overridable Sub GetObjectData() Implements System.Runtime.Serialization.ISerializable.GetObjectData Me.SerializationInfo.AddValue("First Name", firstName) Me.SerializationInfo.AddValue("Last Name", lastName) Me.SerializationInfo.AddValue("Age", age)End Sub

// C#public virtual void GetObjectData(){ this.SerializationInfo.AddValue("First Name", firstName); this.SerializationInfo.AddValue("Last Name", lastName); this.SerializationInfo.AddValue("Age", age);}

2. ' VBPublic Overridable Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext) Implements System.Runtime.Serialization.ISerializable.GetObjectData info.AddValue("First Name", firstName) info.AddValue("Last Name", lastName) info.AddValue("Age", age)End Sub

// C#public virtual void GetObjectData(SerializationInfo info, StreamingContext context){ info.AddValue("First Name", firstName); info.AddValue("Last Name", lastName); info.AddValue("Age", age);}

<Correct>

3. ' VBPublic Overridable Sub GetObjectData(ByVal info As SerializationInfo) Implements System.Runtime.Serialization.ISerializable.GetObjectData info.AddValue("First Name", firstName) info.AddValue("Last Name", lastName) info.AddValue("Age", age)End Sub

// C#public virtual void GetObjectData(SerializationInfo info){ info.AddValue("First Name", firstName); info.AddValue("Last Name", lastName); info.AddValue("Age", age);}

4. ' VBPublic Overridable Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext) Implements System.Runtime.Serialization.ISerializable.GetObjectData context.AddValue("First Name", firstName) context.AddValue("Last Name", lastName) context.AddValue("Age", age)End Sub

// C#public virtual void GetObjectData(SerializationInfo info, StreamingContext context){ context.AddValue("First Name", firstName); context.AddValue("Last Name", lastName);

context.AddValue("Age", age);}

Explanation :Methods that override GetObjectData must accept a SerializationInfo object and a SerializationContext structure as parameters. To add values to be serialized, call the SerializationInfo.AddValue method.

You cannot add data to be serialized to a StreamingContext object.

You cannot add data to be serialized to a SerializationInfo member. Additionally, the GetObjectData method must accept a SerializationInfo object and a SerializationContext structure as parameters.

The GetObjectData method must accept a SerializationInfo object and a SerializationContext structure as parameters.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) SerializationEntry structure and SerializationInfo class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 3

ISerializable.GetObjectData MethodMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.iserializable.getobjectdata.aspx

Custom SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ty01x675.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 114 (536P_4.1.2_05)

_________________________________________________________________________________________________________________

You are creating a class that implements the ISerializable interface. Which serialization event should you respond to if you need to initialize a variable before deserialization occurs?

1. Deserialized

2. Serialized

3. Serializing

4. Deserializing <Correct>

Explanation :The Deserializing event occurs prior to deserialization.

The Serializing event occurs prior to serialization.

The Serialized event occurs immediately after serialization.

The Deserialized event occurs immediately after serialization.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) Serilization attributes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 1

Custom SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ty01x675.aspx

Basics of .NET Framework SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms233836.aspx

ISerializable InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.iserializable.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 115 (536P_1.6.2_02)

_________________________________________________________________________________________________________________

Which of the following elements are NOT required if you want a custom class to raise an event?

1. A class that raises the event.

2. A delegate for the event.

3. A method to add an event handler. <Correct>

4. A class that holds event data, derived from System.EventArgs.

Explanation :You do not need a method to add an event handler; that functionality is provided by the .NET Framework.

If you want to raise an event in a custom class, you need a class that holds the event data (either EventArgs or a class that inherits from EventArgs), a delegate for the event, and a class that raises the event.

Objective:Developing applications that use system types and collections

Sub Objective(s):Control interactions between .NET Framework application components by using events and delegates. (Refer System namespace) EventArgs class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

How to: Implement Events in Your ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/5z57dxz2(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 116 (536P_7.3.6_01)

_________________________________________________________________________________________________________________

Which encoding format does the following code sample NOT read correctly?

' VBDim sr As StreamReader = New StreamReader("file.txt")Console.WriteLine(sr.ReadToEnd)sr.Close

// C#StreamReader sr = new StreamReader("file.txt");Console.WriteLine(sr.ReadToEnd());sr.Close();

1. UTF-16

2. UTF-8

3. UTF-7 <Correct>

4. ASCII

5. UTF-32

Explanation :The code sample does not specify an encoding type. By default, the .NET Framework will automatically decode ASCII or any Unicode format except UTF-7.

To decode UTF-7 files, you must explicitly specify the Encoding.UTF7 decoding format.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.RegularExpressions namespace) Decode text by using Decoding classes.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 3 - Lesson 2

Decoder ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-US/library/system.text.decoder(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 117 (536P_5.3_02)

_________________________________________________________________________________________________________________

You are creating an SslStream object to transfer data encrypted across a network. You want to use the most secure encryption protocol available. Of the types available in the CipherAlgorithmType enumeration, which should you choose?

1. MD5

2. DES

3. TripleDES

4. AES <Correct>

Explanation :Of the options given, AES is the most secure encryption algorithm.

MD5 is a hashing algorithm, and is not part of the CipherAlgorithmType enumeration.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement a custom authentication scheme by using the System.Security.Authentication classes. (Refer System.Security.Authentication namespace)

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 1

SslStream ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.net.security.sslstream.aspx

CipherAlgorithmType EnumerationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.authentication.cipheralgorithmtype(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 118 (536P_6.3.3_03)

_________________________________________________________________________________________________________________

You have created an instance of the Type class for the custom type MyType. Which method can you call to run the MyType.MyMethod method?

1. Type.GetMember

2. Type.InvokeMember <Correct>

3. Type.MyMethod

4. Type.GetMethod

Explanation :The Type.InvokeMember method allows you to call methods in a class by name.

Type classes do not have the same methods available as the class they represent.

Type.GetMember retrieves a single member, but it does not run it.

Type.GetMethod retrieves a single method, but it does not run it.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Implement reflection functionality in a .NET Framework application (refer System.Reflection namespace), and create metadata, Microsoft intermediate language (MSIL), and a PE file by using the System.Reflection.Emit namespace. Info classes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 14 - Lesson 3

Viewing Type InformationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/t0cs7xez(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 119 (536P_5.6.4_02)

_________________________________________________________________________________________________________________

You receive a call from an application developer who wants to play with an assembly she downloaded from the Internet. The developer has downloaded the assembly to her local computer, so it will run within the My Computer zone. The developer's computer is a member of an Active Directory domain, and a domain administrator has created a code group in the Enterprise security policy that grants assemblies on the local computer the Everything permission set. The Machine security policy grants assemblies in the My Computer zone the FullTrust permission set. The developer then applies the Internet permission set at the User security policy.

What is the effective permission set?

1. Everything

2. Internet <Correct>

3. Nothing

4. FullTrust

Explanation :The Internet permission set is in effect because the runtime applies the most restrictive set of permissions. The Internet permission set is more restrictive than the Everything or the FullTrust permission set.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Control code privileges by using System.Security.Policy classes. (Refer System.Security.Policy namespace) CodeGroup class, FileCodeGroup class, FirstMatchCodeGroup class, NetCodeGroup class, and UnionCodeGroup class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 1

Named Permission SetsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/4652tyx7.aspx

How to: Change Permission Sets Associated with an Existing Code GroupMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/96fz91b0.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 120 (536P_3.6.1_01)

_________________________________________________________________________________________________________________

You need to provide users with a list of network drives so that they can choose where to store a file. Which of the following code samples correctly displays network drives and available space?

1. ' VBDim oq As New ObjectQuery("SELECT Win32_LogicalDisk where DriveType=4")

Dim moc As ManagementObjectCollection = ManagementObjectSearcher.Get(oq)

For Each mo As ManagementObject In moc Console.WriteLine(mo("Name").ToString() + ", Free Space: " + mo("Size").ToString())Next

// C#ObjectQuery oq = new ObjectQuery("SELECT FROM Win32_LogicalDisk where DriveType=4");

ManagementObjectCollection moc = ManagementObjectSearcher.Get(oq);

foreach (ManagementObject mo in moc) Console.WriteLine(mo["Name"] + ", Free Space: " + mo["Size"]);

2. ' VBDim oq As New ObjectQuery("SELECT Win32_LogicalDisk where DriveType=4")

Dim mos As New ManagementObjectSearcher(oq)Dim moc As ManagementObjectCollection = mos.Get

For Each mo As ManagementObject In moc Console.WriteLine(mo("Name").ToString() + ", Free Space: " + mo("Size").ToString())Next

// C#ObjectQuery oq = new ObjectQuery("SELECT Win32_LogicalDisk where DriveType=4");

ManagementObjectSearcher mos = new ManagementObjectSearcher(oq);ManagementObjectCollection moc = mos.Get();

foreach (ManagementObject mo in moc) Console.WriteLine(mo["Name"] + ", Free Space: " + mo["Size"]);

3. ' VBDim oq As New ObjectQuery("SELECT Size, Name FROM Win32_LogicalDisk where DriveType=4")

Dim moc As ManagementObjectCollection = ManagementObjectSearcher.Get(oq)

For Each mo As ManagementObject In moc Console.WriteLine(mo("Name").ToString() + ", Free Space: " + mo("Size").ToString())Next

// C#ObjectQuery oq = new ObjectQuery("SELECT Size, Name FROM Win32_LogicalDisk where DriveType=4");

ManagementObjectCollection moc = ManagementObjectSearcher.Get(oq);

foreach (ManagementObject mo in moc) Console.WriteLine(mo["Name"] + ", Free Space: " + mo["Size"]);

4. ' VBDim oq As New ObjectQuery("SELECT Size, Name FROM Win32_LogicalDisk where DriveType=4")

Dim mos As New ManagementObjectSearcher(oq)Dim moc As ManagementObjectCollection = mos.Get

For Each mo As ManagementObject In moc Console.WriteLine(mo("Name").ToString() + ", Free Space: " + mo("Size").ToString())Next

// C#ObjectQuery oq = new ObjectQuery("SELECT Size, Name FROM Win32_LogicalDisk where DriveType=4");

ManagementObjectSearcher mos = new ManagementObjectSearcher(oq);ManagementObjectCollection moc = mos.Get();

foreach (ManagementObject mo in moc) Console.WriteLine(mo["Name"] + ", Free Space: " + mo["Size"]);

<Correct>

Explanation :To query available drives:

1. Create an instance of ObjectQuery using a Windows Management Instrumentation (WMI) query. The WMI query must be in the form "SELECT fields FROM Win32_LogicalDisk WHERE criteria".2. Create an instance of ManagementObjectSearcher based on the query.3. Create an instance of ManagementObjectCollection by calling the ManagementObjectSearcher.Get method.

You can then iterate through the ManagementObjects in the ManagementObjectCollection to examine individual drives.

ManagementObjectSearcher.Get is not a static method; you must create an instance to use it.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Embed management information and events into a NET Framework application. (Refer System.Management namespace) Retrieve a collection of Management objects by using the ManagementObjectSearcher class and its derived classes.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 4

ManagementObjectSearcher ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.management.managementobjectsearcher.aspx

ObjectQuery ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.management.objectquery(VS.80).aspx

WMI .NET OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms257340(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 121 (536P_3.5.2_01)

_________________________________________________________________________________________________________________

You are in the process of isolating a complicated bug in a console application that occurs only in rare circumstances. You want to be able to write messages to the Output window in Microsoft Visual Studio 2005, as shown in the following figure. Which of the following code samples accomplishes this by writing the message, "Entering main processing loop"?

1. ' VBDim dtl As New DefaultTraceListenerTrace.Listeners.Add(dtl)Debugger.Log(2, "Entering main processing loop", "Information")

// C#DefaultTraceListener dtl = new DefaultTraceListener();Trace.Listeners.Add(dtl);Debugger.Log(2, "Entering main processing loop", "Information");

2. ' VBDim dtl As New DefaultTraceListenerTrace.Listeners.Add(dtl)Debugger.Log(2, "Information", "Entering main processing loop")

// C#DefaultTraceListener dtl = new DefaultTraceListener();Trace.Listeners.Add(dtl);Debugger.Log(2, "Information", "Entering main processing loop");

<Correct>

3. ' VBDim dtl As New DefaultTraceListenerTrace.Listeners.Log(dtl, "Information", "Entering main processing loop")

// C#DefaultTraceListener dtl = new DefaultTraceListener();Trace.Listeners.Log(dtl, "Information", "Entering main processing loop");

4. ' VBDim dtl As New DefaultTraceListenerTrace.Listeners.Log(dtl, "Entering main processing loop", "Information")

// C#DefaultTraceListener dtl = new DefaultTraceListener();Trace.Listeners.Log(dtl, "Entering main processing loop", "Information");

Explanation :To write information to the Output window, first create an instance of DefaultTraceListener. Then add it to the Trace.Listeners collection. Finally, call Debugger.Log to write the message. Debugger.Log takes three parameters: a level, a category, and a message. The third parameter is the message that appears in the Output window.

There is no Trace.Listeners.Log method.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Debug and trace a .NET Framework application by using the System.Diagnostics namespace. Trace class, CorrelationManager class, TraceListener class, TraceSource class, TraceSwitch class, XmlWriterTraceListener class, DelimitedListTraceListener class, and EventlogTraceListener class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 2

Debugger.Log MethodMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.debugger.log(VS.80).aspx

Trace.Listeners PropertyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.trace.listeners.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 122 (536P_2.1.2_01)

_________________________________________________________________________________________________________________

Which of the following code samples would successfully start the Server service?

1. ' VBServiceController.Continue("Server")

// C#ServiceController.Continue("Server");

2. ' VBDim sc As ServiceController = New ServiceController("Server")sc.Start()

// C#ServiceController sc = new ServiceController("Server");sc.Start();

<Correct>

3. ' VBServiceController.Start("Server")

// C#ServiceController.Start("Server");

4. ' VBDim sc As ServiceController = New ServiceController()sc.Start("Server")

// C#ServiceController sc = new ServiceController();sc.Start("Server");

Explanation :To start a service, first create an instance of the ServiceController class. Define the service name (which you can do with the constructor), and then call the Start method.

The ServiceController.Start method is not static. Therefore, you must first create an instance of the class.

You cannot define the service name using the ServiceController.Start method.

The ServiceController.Continue method is not static. Therefore, you must first create an instance of the class. Additionally, you should call the Start method, not the Continue method.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Implement, install, and control a service. (Refer System.ServiceProcess namespace) ServiceController class and ServiceControllerPermission class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 8 - Lesson 3

How to: Start ServicesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/htkdfk18.aspx

ServiceController ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 123 (536P_4.1.1_03)

_________________________________________________________________________________________________________________

You are writing a class that implements the ISerializable interface. Which of the following are requirements for a method that responds to the Deserialized event? (Choose all that apply.)

1. Accepts zero parameters

2. Returns void<Correct>

3. Accepts a SerializationInfo object as a parameter

4. Accepts a StreamingContext object as a parameter <Correct>

5. Returns a StreamingContext object

Explanation :Methods that respond to serialization events must accept a StreamingContext object as a parameter and return void.

A method cannot respond to a serialization event if it accepts zero parameters. It must accept a StreamingContext object.

Methods that respond to serialization events cannot return a StreamingContext object. They must return void.

A method cannot respond to a serialization event if it accepts a SerializationInfo object. It must accept a StreamingContext object.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) Serialization interfaces

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 1

Custom SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ty01x675.aspx

Basics of .NET Framework SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms233836.aspx

ISerializable InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.iserializable.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 124 (536P_1.5.2_01)

_________________________________________________________________________________________________________________

Which of the following methods is inherited from the IDisposable interface?

1. ToString()

2. Clone()

3. GetType()

4. Equals()

5. Dispose() <Correct>

6. CompareTo()

Explanation :The Dispose() method is a member of the IDisposable interface.

The CompareTo() method is a member of the IComparable interface.

All classes inherit the ToString(), Equals(), and GetType() methods from the base Object class.

The Clone() method is a member of the ICloneable interface.

Objective:Developing applications that use system types and collections

Sub Objective(s):Implement .NET Framework interfaces to cause components to comply with standard contracts. (Refer System namespace) IDisposable interface

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

IDisposable InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.idisposable.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 125 (536P_6.4.8_01)

_________________________________________________________________________________________________________________

You are writing an application that sends outgoing e-mail messages. You want to provide both plain text and HTML versions of the messages. Which System.Net.Mail member would you use to provide multiple versions of the message?

1. DeliveryNotificationOptions

2. Attachments

3. SubjectEncoding

4. AlternateViews <Correct>

Explanation :Mail.AlternateViews is a collection that stores multiple AlternateView objects. Each AlternateView object can provide a different representation of your message, such as HTML or plain text versions.

Mail.Attachments is a collection of Attachment objects that will be attached to the message. While you could use Attachment objects to provide alternate views, it would require recipients to open a separate attachment.

The DeliveryNotificationOptions property gets or sets the delivery notifications for the message, such as notifying the sender when the recipient reads the message.

The SubjectEncoding property specifies the encoding type for the subject of the message and does not affect the body of the message.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery from a .NET Framework application. (Refer System.Net.Mail namespace) AlternateView class and AlternateViewCollection class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 15 - Lesson 1

MailMessage.AlternateViews PropertyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.net.mail.mailmessage.alternateviews(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 126 (536P_5.1.4_02)

_________________________________________________________________________________________________________________

Which of the following permission sets provides the best performance?

1. Nothing

2. FullTrust <Correct>

3. Execution

4. LocalIntranet

5. Internet

Explanation :The FullTrust permission set exempts an assembly from CAS permission checks, which improves performance.

All other permission sets require the runtime to perform security checks, which has a performance impact.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement code access security to improve the security of a .NET Framework application. (Refer System.Security namespace) PermissionSet class and NamedPermissionSet class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 1

Named Permission SetsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/4652tyx7.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 127 (536P_5.3_03)

_________________________________________________________________________________________________________________

You are creating a service that accepts incoming Secure Sockets Layer (SSL) connections. All valid clients will be based on the .NET Framework version 2.0. You want to ensure that only the most secure communications will be allowed; however, all clients must be able to connect to your service. Which of the SslProtocols enumerations will you specify?

1. Ssl3

2. Ssl2

3. Default

4. Tls <Correct>

Explanation :SslProtocols.Tls is the most secure connection protocol supported by .NET Framework version 2.0 and its clients.

SslProtocols.Ssl3 and SslProtocols.Ssl2 have been superseded by SslProtocols.Tls.

SslProtocol.Default allows both SSL 3.0 and TLS 1.0 communications. In this case, it is not necessary to allow SSL 3.0 communications.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement a custom authentication scheme by using the System.Security.Authentication classes. (Refer System.Security.Authentication namespace)

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 1

SslProtocols EnumerationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.authentication.sslprotocols(VS.80).aspx

SslStream ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.net.security.sslstream.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 128 (536P_7.3.5_02)

_________________________________________________________________________________________________________________

If you do not specify an encoding type, which encoding type does the .NET Framework use?

1. UTF-8

2. ASCII

3. UTF-32

4. UTF-16 <Correct>

Explanation :The .NET Framework uses UTF-16 by default, which is a 16-bit Unicode encoding format.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.RegularExpressions namespace) Encode text by using Encoding classes.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 3 - Lesson 2

Encoding.Unicode PropertyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.text.encoding.unicode.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 129 (536P_1.2.1_01)

_________________________________________________________________________________________________________________

By default, what is the initial capacity of an ArrayList instance?

1. 16

2. 64

3. 256

4. 0 <Correct>

Explanation :The default initial capacity of ArrayList is zero. ArrayList grows dynamically.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage a group of associated data in a .NET Framework application by using collections. (Refer System.Collections namespace) ArrayList class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 4 - Lesson 1

EvidenceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/7y5x1hcd.aspx

AppDomain ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.appdomain.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 130 (536P_2.2.9_03)

_________________________________________________________________________________________________________________

You have issued an asynchronous request and are waiting for the result. How can you determine whether the result is available but continue to respond to user input if the result is not yet available?

1. IAsyncResult.CompletedSynchronously

2. IAsyncResult.AsyncWaitHandle.WaitOne

3. IAsyncResult.AsyncWaitHandle.SafeWaitHandle

4. IAsyncResult.IsCompleted <Correct>

Explanation :IAsyncResult.IsCompleted is true if the asynchronous request is complete. If it is false, you can respond to the user and check the result later.

IAsyncResult.CompletedSynchronously is true if the request was synchronous rather than asynchronous. It does not correctly indicate whether an asynchronous request is complete.

IAsyncResult.AsyncWaitHandle.WaitOne waits until the request is complete, interrupting your processing.

IAsyncResult.AsyncWaitHandle.SafeWaitHandle gets or sets the native operating system handle. It does not check to determine whether a request is complete.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Develop multithreaded .NET Framework applications. (Refer System.Threading namespace) IAsyncResult interface (Refer System namespace)

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 7 - Lesson 3

Polling for the Status of an Asynchronous OperationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms228968(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 131 (536P_2.3.3_01)

_________________________________________________________________________________________________________________

Which of the following is the proper way to construct an AppDomain object?

1. ' VBDim d As AppDomain = AppDomain.CreateDomain("Domain")

// C#AppDomain d = AppDomain.CreateDomain("Domain");

<Correct>

2. ' VBDim z As Object() = {New Zone (SecurityZone.Internet)}Dim e As Evidence = New Evidence (z, Nothing)Dim d As AppDomain = New AppDomain("Domain", e)

// C#object [] z = {new Zone(SecurityZone.Internet)};Evidence e = new Evidence(z, null);AppDomain d = new AppDomain("Domain", e);

3. ' VBDim d As AppDomain = New AppDomain("Domain", New Zone (SecurityZone.Internet))

// C#AppDomain d = new AppDomain("Domain", new Zone(SecurityZone.Internet));

4. ' VBDim d As AppDomain = New AppDomain("Domain")

// C#AppDomain d = new AppDomain("Domain");

Explanation :The proper way to construct an AppDomain object is to call the static AppDomain.CreateDomain method.

AppDomain does not have a standard constructor.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Create a unit of isolation for common language runtime in a .NET Framework application by using application domains. (Refer System namespace) Configure an application domain.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 8 - Lesson 2

Creating and Configuring Application DomainsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/wxtzfyw3.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 132 (536P_4.4.1_02)

_________________________________________________________________________________________________________________

You need to create a text file using the static File.CreateText method. Which of the following values is an acceptable parameter? (Choose all that apply.)

1. http://server/text.txt

2. ftp://server/text.txt

3. \\server\text.txt <Correct>

4. file://server.txt

5. C:\text.txt <Correct>

Explanation :File.CreateText can accept local file paths or universal naming convention (UNC) paths.

File.CreateText cannot accept URLs.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Access files and folders by using the File System classes. (Refer System.IO namespace) File class and FileInfo class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 1

File ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/library/3saad2h5.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 133 (536P_7.1.3_05)

_________________________________________________________________________________________________________________

You are creating a Windows Service. Which of the following security contexts should you specify for the Account property to reduce security risks by running as a nonprivileged user while presenting computer credentials to network resources?

1. NetworkService <Correct>

2. LocalService

3. LocalSystem

4. User

Explanation :NetworkService runs in the context of an account that acts as a nonprivileged user on the local computer, and it presents the computer's credentials (not a specific user's credentials) to any remote server.

LocalService runs in the context of an account that acts as a nonprivileged user on the local computer, and it presents anonymous credentials to any remote server.

User causes the system to prompt for a valid user name and password when the service is installed, and it runs in the context of an account specified by a single user on the network.

LocalSystem runs in the context of an account that provides extensive local privileges, and it presents the computer's credentials to any remote server.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Format data based on culture information. (Refer System.Globalization namespace) Format number values based on the culture.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 16 - Lesson 1

How to: Specify the Security Context for ServicesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/0x72fzyf(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 134 (536P_7.2.1_02)

_________________________________________________________________________________________________________________

Which of the following code samples draws this graphic?

1. ' VBDim bm As Bitmap = New Bitmap(300, 300)Dim g As Graphics = Graphics.FromImage(bm)

Dim b As Brush = New LinearGradientBrush(New Point(1, 1), New Point(300, 300), Color.White, Color.Blue)Dim points As Point() = New Point() {New Point(1, 1), New Point(300, 1), New Point(300, 300), New Point(1, 300)}

g.FillPolygon(b, points)

// C#Bitmap bm = new Bitmap(300, 300);Graphics g = Graphics.FromImage(bm);

Brush b = new LinearGradientBrush(new Point(1, 1), new Point(300, 300), Color.White, Color.Blue);Point[] points = new Point[] {new Point(1, 1), new Point(300, 1), new Point(300, 300), new Point(1, 300)};

g.FillPolygon(b, points);

2. ' VBDim bm As Bitmap = New Bitmap(300, 300)Dim g As Graphics = Graphics.FromImage(bm)

Dim b As Brush = New LinearGradientBrush(New Point(1, 1), New Point(300, 300), Color.Blue, Color.White)Dim points As Point() = New Point() {New Point(1, 1), New Point(300, 1), New Point(300, 300), New Point(1, 300)}

g.FillPolygon(b, points)

// C#Bitmap bm = new Bitmap(300, 300);Graphics g = Graphics.FromImage(bm);

Brush b = new LinearGradientBrush(new Point(1, 1), new Point(300, 300), Color.Blue, Color.White);Point[] points = new Point[] {new Point(1, 1), new Point(300, 1), new Point(300, 300), new Point(1, 300)};

g.FillPolygon(b, points);<Correct>

3. ' VBDim bm As Bitmap = New Bitmap(300, 300)Dim g As Graphics = Graphics.FromImage(bm)

Dim b As Brush = New LinearGradientBrush(New Point(1, 1), New Point(300, 300), Color.White, Color.Blue)Dim points As Point() = New Point() {New Point(1, 1), New Point(300, 300), New Point(300, 1), New Point(1, 300)}

g.FillPolygon(b, points)

// C#Bitmap bm = new Bitmap(300, 300);Graphics g = Graphics.FromImage(bm);

Brush b = new LinearGradientBrush(new Point(1, 1), new Point(300, 300), Color.Blue, Color.White);

Point[] points = new Point[] {new Point(1, 1), new Point(300, 300), new Point(300, 1), new Point(1, 300)};

g.FillPolygon(b, points);

4. ' VBDim bm As Bitmap = New Bitmap(300, 300)Dim g As Graphics = Graphics.FromImage(bm)

Dim b As Brush = New LinearGradientBrush(New Point(1, 1), New Point(300, 300), Color.Blue, Color.White)Dim points As Point() = New Point() {New Point(1, 1), New Point(300, 300), New Point(300, 1), New Point(1, 300)}

g.FillPolygon(b, points)

// C#Bitmap bm = new Bitmap(300, 300);Graphics g = Graphics.FromImage(bm);

Brush b = new LinearGradientBrush(new Point(1, 1), new Point(300, 300), Color.Blue, Color.White);Point[] points = new Point[] {new Point(1, 1), new Point(300, 300), new Point(300, 1), new Point(1, 300)};

g.FillPolygon(b, points);

Explanation :The linear gradient fades from blue in the upper-left corner to white in the lower-right corner, and the points defined in this code sample correctly draw a box.

Creating a Brush with LinearGradientBrush(New Point(1, 1), New Point(300, 300), Color.White, Color.Blue) would draw a box that fades from white in the upper-left corner to blue in the lower-right corner.

Creating the point array with Point(1, 1), Point(300, 300), Point(300, 1), Point(1, 300) would not draw a box; it would draw an X-shaped polygon.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the user interface of a .NET Framework application by using the System.Drawing namespace. Enhance the user interface of a .NET Framework application by using brushes, pens, colors, and fonts.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 6 - Lesson 1

How to: Create a Linear GradientMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/0sdy66e6.aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 6 - Lesson 3

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 135 (536P_1.1.3_01)

_________________________________________________________________________________________________________________

Which of the following is a valid use for an attribute? (Choose all that apply.)

1. Place constraints on a generic class

2. Specify which security privileges a class requires <Correct>

3. Describe an assembly <Correct>

4. Declare capabilities <Correct>

Explanation :Attributes describe a type, method, or property in a way that can be programmatically queried using a technique called Reflection. Some common uses for attributes are specifying which security privileges a class requires, declaring capabilities, and describing an assembly.

You cannot use attributes to place constraints on a generic class.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Attributes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

Setting Assembly AttributesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/4w8c1y2s.aspx

Attributes in Visual BasicMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/39967861.aspx

Attributes (C# Programming Guide)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/z0w1kczw.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 136 (536P_1.1.5_04)

_________________________________________________________________________________________________________________

You are writing a method that might throw an exception at several points during the method's execution. You need to run several lines of code after the method runs, whether or not an exception occurred. Which type of block can you use to implement this?

1. Done

2. Finally <Correct>

3. Try

4. Catch

Explanation :Use a Finally block to run code whether or not an exception occurs. A Finally block is always executed, regardless of whether an exception is thrown.

Use a Try block when you need to catch an exception.

Use a Catch block to run code if an exception occurs.

The .NET Framework does not provide a Done block type.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Exception classes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

How to: Use Finally BlocksMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ke0zf0f5.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 137 (536P_1.1.2_08)

_________________________________________________________________________________________________________________

You retrieve an array of CultureInfo objects using CultureInfo.GetCultures(CultureTypes.NeutralCultures). Which of the following culture names might be members of the resulting array? (Choose all that apply.)

1. hi-IN

2. en <Correct>

3. ka-GE

4. ko <Correct>

5. gl-ES

6. ro <Correct>

Explanation :Neutral cultures are language, but not region, specific. Neutral culture names are in the form xx, with only two lowercase characters.

Cultures with names in the format xx-XX are specific cultures and could be retrieved using CultureInfo.GetCultures(CultureTypes.SpecificCultures).

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Reference types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

CultureTypes EnumerationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.globalization.culturetypes.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 138 (536P_1.6.3_02)

_________________________________________________________________________________________________________________

Based on the following delegate, which of the following class declarations could respond to an event?

' VBPublic Delegate Sub AlarmEventHandler(sender As Object, e As AlarmEventArgs)

// C#public delegate void AlarmEventHandler(object sender, AlarmEventArgs e);

1. ' VBPublic Sub AlarmRang(sender As Object, e As AlarmEventArgs)

// C#public void AlarmRang(object sender, AlarmEventArgs e)

<Correct>

2. ' VBPublic Sub AlarmRang(sender As Object, e As EventArgs)

// C#public void AlarmRang(object sender, EventArgs e)

3. ' VBPublic Sub AlarmRang(sender As Object, e As AlarmEventArgs) As EventArgs

// C#public EventArgs AlarmRang(object sender, AlarmEventArgs e)

4. ' VBPublic Sub AlarmRang()

// C#public void AlarmRang()

Explanation :Event handlers must match the delegate's signature. In this case, the delegate requires two parameters (Object and AlarmEventArgs) and returns void.

You cannot return a value in an event handler.

Event handlers must accept the same parameters as the delegate.

Event handlers must accept the same parameters as the delegate. In this case, the second parameter must be AlarmEventArgs (a custom type), rather than EventArgs.

Objective:Developing applications that use system types and collections

Sub Objective(s):Control interactions between .NET Framework application components by using events and delegates. (Refer System namespace) EventHandler delegates

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

Events and DelegatesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/17sde2xt.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 139 (536P_3.1.1_04)

_________________________________________________________________________________________________________________

Which of the following configuration files correctly defines the information required to connect to a database by defining the first element of ConfigurationManager.ConnectionStrings regardless of other configuration files that might exist?

1. <?xml version="1.0" encoding="utf-8" ?><configuration> <connectionStrings> <clear/> <add name="System.Data.SqlClient" providerName="AdventureWorksString" connectionString="Data Source=localhost;Initial Catalog=AdventureWorks; Integrated Security=true"/> </connectionStrings></configuration>

2. <?xml version="1.0" encoding="utf-8" ?><configuration> <connectionStrings> <clear/> <add name="AdventureWorksString" providerName="System.Data.SqlClient" connectionString="Data Source=localhost;Initial Catalog=AdventureWorks; Integrated Security=true"/> </connectionStrings></configuration>

<Correct>

3. <?xml version="1.0" encoding="utf-8" ?><configuration> <connectionStrings> <add name="AdventureWorksString" providerName="System.Data.SqlClient" connectionString="Data Source=localhost;Initial Catalog=AdventureWorks; Integrated Security=true"/> </connectionStrings></configuration>

4. <?xml version="1.0" encoding="utf-8" ?><configuration> <connectionStrings> <add name="System.Data.SqlClient" providerName="AdventureWorksString" connectionString="Data Source=localhost;Initial Catalog=AdventureWorks; Integrated Security=true"/> </connectionStrings></configuration>

Explanation :To define the first element of ConfigurationManager.ConnectionStrings, you must include the <clear/> element, which removes any existing <connectionStrings> elements. You must set the providerName attribute to the database type, such as System.Data.SqlClient. The Name element is a friendly name used to refer to that specific connection string.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Embed configuration management functionality into a .NET Framework application. (Refer System.Configuration namespace) Configuration class and ConfigurationManager class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development

Foundation, MicrosoftChapter 9 - Lesson 1

ConfigurationManager.ConnectionStrings PropertyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.configuration.configurationmanager.connectionstrings.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 140 (536P_3.1.1_05)

_________________________________________________________________________________________________________________

You are writing an application that stores window state in the application's configuration file. Given the following configuration file, which of the following code samples correctly tests the IsMaximized element in a .NET Framework 2.0 application? (Choose all that apply.)

<?xml version="1.0" encoding="utf-8" ?><configuration> <appSettings> <add key="IsMinimized" value="False"/> <add key="IsMaximized" value="True"/> <add key="username" value="user1"/> </appSettings></configuration>

1. ' VBIf ConfigurationManager("IsMaximized") = "True" Then

// C#if (ConfigurationManager["IsMaximized"] == "True")

2. ' VBIf ConfigurationSettings.AppSettings("IsMaximized") = "True" Then

// C#if (ConfigurationSettings.AppSettings["IsMaximized"] == "True")

3. ' VBIf ConfigurationManager.Get("IsMaximized") = "True" Then

// C#if (ConfigurationManager.Get("IsMaximized") == "True")

4. ' VBIf ConfigurationManager.AppSettings("IsMaximized") = "True" Then

// C#if (ConfigurationManager.AppSettings["IsMaximized"] == "True")

<Correct>

5. ' VBIf ConfigurationManager.AppSettings.Get("IsMaximized") = "True" Then

// C#if (ConfigurationManager.AppSettings.Get("IsMaximized") == "True")

<Correct>

Explanation :The ConfigurationManager.AppSettings collection provides access to elements defined in the <appSettings> section of a configuration file. Because it is a collection, you can access elements as an array or by using the Get method.

The ConfigurationSettings class is obsolete in the .NET Framework 2.0.

ConfigurationManager does not contain AppSettings elements. You must access ConfigurationManager.AppSettings instead.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Embed configuration management functionality into a .NET Framework application. (Refer System.Configuration namespace) Configuration class and ConfigurationManager class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 1

ConfigurationManager.AppSettings PropertyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.configuration.configurationmanager.appsettings.aspx

Configuration File Schema for the .NET FrameworkMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-US/library/1fk1t1t0.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 141 (536P_1.6.3_04)

_________________________________________________________________________________________________________________

Which of the following is the proper way to raise an event, assuming the Alarm event, the AlarmEventArgs class, and the AlarmEventHandler delegate have been declared?

1. ' VBDim e As New AlarmEventArgs(1, 2)RaiseEvent Alarm(Me)

// C#AlarmEventArgs e = new AlarmEventArgs(1, 2)AlarmEventHandler handler = Alarm; if (handler != null) { handler(this);}

2. ' VBDim e As New AlarmEventArgs(1, 2)Alarm(Me, e)

// C#AlarmEventArgs e = new AlarmEventArgs(1, 2)if (Alarm!= null) { // Invokes the delegates. Alarm (this, e);}

3. ' VBDim e As New AlarmEventArgs(1, 2)RaiseEvent e

// C#AlarmEventArgs e = new AlarmEventArgs(1, 2)AlarmEventHandler handler = Alarm; if (handler != null) { handler(e);}

4. ' VBDim e As New AlarmEventArgs(1, 2)RaiseEvent Alarm(Me, e)

// C#AlarmEventArgs e = new AlarmEventArgs(1, 2)AlarmEventHandler handler = Alarm; if (handler != null) { handler(this, e);} <Correct>

Explanation :To raise an event in Microsoft Visual Basic, use the RaiseEvent keyword and provide Me and an instance of a class that derives from EventArgs. To raise an event in Microsoft Visual C#, create an instance of the event handler class, and call it with this and an instance of a class that derives from EventArgs.

Objective:Developing applications that use system types and collections

Sub Objective(s):Control interactions between .NET Framework application components by using events and delegates. (Refer System namespace) EventHandler delegates

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development

Foundation, MicrosoftChapter 1 - Lesson 3

How to: Raise and Consume EventsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/9aackb16(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 142 (536P_2.2.1_01)

_________________________________________________________________________________________________________________

What is the primary difference between a background thread and a foreground thread?

1. Background threads run at a lower priority.

2. In the event of resource contention, forerground threads receive access to the resource.

3. Foreground threads are associated with the active window. Background threads are associated with windows that are minimized or are not currently active.

4. When all foreground threads have stopped, the runtime stops all background threads. <Correct>

Explanation :The primary difference between foreground and background threads is that background threads can be stopped automatically. Use background threads so that the thread does not prevent your process from terminating.

Background threads do not run at a lower priority.

Background status does not affect access to resources.

Background status is not related to active windows.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Develop multithreaded .NET Framework applications. (Refer System.Threading namespace) Thread class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 7 - Lesson 1

Foreground and Background ThreadsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/h339syd0.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 143 (536P_5.2.5_02)

_________________________________________________________________________________________________________________

You have written an application that specifies System Access Control Lists (SACLs) on a registry key so that events will be added to the Security event log if a user modifies a value. What else do you need to do to enable auditing?

1. 1. Open the Local Security Policy console.2. Expand Local Policies, and select Audit Policy.3. Set Audit Object Access to Failure.

2. 1. Open the Local Security Policy console.2. Expand Local Policies, and select Audit Policy.3. Set Audit Privilege Use to Failure.

3. 1. Open the Local Security Policy console.2. Expand Local Policies, and select Audit Policy.3. Set Audit Privilege Use to Success.

4. 1. Open the Local Security Policy console.2. Expand Local Policies, and select Audit Policy.3. Set Audit Object Access to Success.

<Correct>

5. 1. Open the Local Security Policy console.2. Expand Local Policies, and select Audit Policy.3. Set Audit Process Tracking to Success.

6. 1. Open the Local Security Policy console.2. Expand Local Policies, and select Audit Policy.3. Set Audit Process Tracking to Failure.

Explanation :Object auditing is disabled by default because it negatively affects system performance, However, you must enable it using the Local Security Policy or a domain Group Policy object for file or registry auditing to occur. The requirements state that you want an event logged if a user successfully modifies a key, so you should set the Audit Object Access policy to Success.

Setting the Audit Object Access to Failure would only log unsuccessful attempts to modify the registry key, which would not meet the requirements.

The Audit Privilege Use policy setting determines whether to audit each instance of a user who exercises a user right. It does not enable auditing of registry changes.

The Audit Process Tracking policy setting determines whether to audit detailed tracking information for events such as program activation, process exit, handle duplication, and indirect object access. It does not enable auditing of registry changes.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement access control by using the System.Security.AccessControl classes. AuditRule class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 2

Threats and CountermeasuresMicrosoft TechNet, MicrosoftChapter 3: Audit PolicyLink: http://www.microsoft.com/technet/security/topics/serversecurity/tcg/tcgch03n.mspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 144 (536P_4.2.2_03)

_________________________________________________________________________________________________________________

Given the following class, which of the following files represents how an instance of that class would be serialized using the XmlSerializer class?

' VB<XmlRoot("CartItem")> Public Class ShoppingCartItem Public productId As Int32 Public price As Decimal Public quantity As Int32 <XmlIgnore()> Public total As Decimal

Public Sub New() MyBase.New End SubEnd Class

// C#[XmlRoot ("CartItem")]public class ShoppingCartItem { public Int32 productId; public decimal price; public Int32 quantity; [XmlIgnore] public decimal total;

public ShoppingCartItem() { }}

1. <?xml version="1.0" ?> <ShoppingCartItem> <productId>100</productId> <price>10.25</price> <quantity>2</quantity> </ShoppingCartItem>

2. <?xml version="1.0" ?> <CartItem> <productId>100</productId> <price>10.25</price> <quantity>2</quantity> </CartItem>

<Correct>

3. <?xml version="1.0" ?> <CartItem productId="100" price="10.25" quantity="2"></CartItem>

4. <?xml version="1.0" ?> <CartItem productId="100" price="10.25" quantity="2" total="20.50"></CartItem>

Explanation :The specified attributes change the root XML element to CartItem from the default ShoppingCartItem, and they cause the total to be ignored during serialization.

By default, XmlSerializer serializes all members as elements, not attributes.

By default, XmlSerializer serializes all members as elements, not attributes. Additionally, the total member would be left out of serialization.

The specified attributes change the root XML element to CartItem from the default ShoppingCartItem.

Objective:

Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Control the serialization of an object into XML format by using the System.Xml.Serialization namespace. Control serialization by using serialization attributes.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 2

Basic SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/4abbf6k0.aspx

XmlSerializer ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx

How to: Qualify XML Element and XML Attribute NamesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/xzys86e8.aspx

Introducing XML SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/182eeyhh.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 145 (536P_6.4.1_03)

_________________________________________________________________________________________________________________

Which of the following System.Net.Mail.MailMessage properties are collections? (Choose all that apply.)

1. To <Correct>

2. Sender

3. Attachments <Correct>

4. From

5. Subject

Explanation :The MailMessage.Attachments and MailMessage.To properties are collections, because you must be able to specify multiple attachments and multiple recipients.

MailMessage.From and MailMessage.Sender are a MailAddress types.

MailMessage.Subject is a String type.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery from a .NET Framework application. (Refer System.Net.Mail namespace) MailMessage class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 15 - Lesson 1

MailMessage PropertiesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/45ddcb0d(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 146 (536P_4.1.6_02)

_________________________________________________________________________________________________________________

Which of the following is a task performed by the ObjectManager class as part of serialization?

1. During deserialization, track which objects have been deserialized and which are pending. <Correct>

2. During serialization, perform customized formatting to describe member objects.

3. During serialization, describe the client who will perform deserialization.

4. Ensure the assembly has the necessary permissions to perform serialization.

Explanation :The ObjectManager class keeps track of objects as they are deserialized.

The ObjectManager class does not perform the other tasks.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) StreamingContext structure

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 3

ObjectManager ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.objectmanager.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 147 (536P_5.7.4_01)

_________________________________________________________________________________________________________________

You are writing an application that for a government organization. The application will provide access to highly confidential information, and one of their security requirements is that the user management system be integrated into the application rather than relying on an external system such as Active Directory.

The organization has a long list of requirements for the user management system. You must be able to determine authorization based on group memberships, clearance levels, assigned projects, and locations. Additionally, groups will have clearance levels and will be assigned a list of custom policies.

What classes or interface would you use to implement the custom user management system? (Choose all that apply.)

1. IPrincipal <Correct>

2. WindowsPrincipal

3. GenericIdentity

4. GenericPrincipal

5. IIdentity <Correct>

6. WindowsIdentity

Explanation :IIdentity and IPrincipal are interfaces designed to allow the implementation of custom user management systems. These interfaces would enable you to meet the client's requirements.

GenericIdentity and GenericPrincipal do not provide the flexibility required.

WindowsIdentity and WindowsPrincipal require an Active Directory domain, or that accounts be stored in a computer's local user database. This does not meet the client's requirements.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Access and modify identity information by using the System.Security.Principal classes. (Refer System.Security.Principal namespace) IIdentity interface and IPrincipal interface

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 1

IIdentity InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.principal.iidentity(VS.80).aspx

IPrincipal InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.principal.iprincipal(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 148 (536P_7.1.2_01)

_________________________________________________________________________________________________________________

You need to display the date by using culture-specific formatting. Which of the following code samples formats the date for the German language in Germany?

1. ' VBDim dt As DateTime = DateTime.NowDim ci As CultureInfo = New CultureInfo("de-DE")Console.WriteLine(dt.ToString("d", ci))

// C#DateTime dt = DateTime.Now; CultureInfo ci = new CultureInfo("de-DE");Console.WriteLine(dt.ToString("d", ci));

<Correct>

2. ' VBDim dt As DateTime = DateTime.NowConsole.WriteLine(dt.ToString("d", CultureTypes.de-De))

// C#DateTime dt = DateTime.Now; Console.WriteLine(dt.ToString(("d", CultureTypes.de-De));

3. ' VBDim dt As DateTime = DateTime.NowDim ct As CultureTypes = New CultureTypes("de-DE")Console.WriteLine(dt.ToString("d", ct))

// C#DateTime dt = DateTime.Now; CultureTypes ct = new CultureTypes("de-DE");Console.WriteLine(dt.ToString("d", ct));

4. ' VBDim dt As DateTime = DateTime.NowConsole.WriteLine(dt.ToString("d", "de-DE"))

// C#DateTime dt = DateTime.Now; Console.WriteLine(dt.ToString("d", "de-DE"));

Explanation :To format the date for a specific culture, create a CultureInfo object and then use the DateTime.ToString override that accepts a CultureInfo object.

DateTime.ToString cannot accept a CultureTypes enumeration or a string to specify the culture.

You cannot create an instance of CultureTypes because it is an enumeration.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Format data based on culture information. (Refer System.Globalization namespace) Format date and time values based on the culture.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 16 - Lesson 1

Formatting Date and Time for a Specific CultureMSDN Library, Microsoft

Link: http://msdn2.microsoft.com/en-us/library/5hh873ya(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 149 (536P_4.4.2_02)

_________________________________________________________________________________________________________________

You need to create a directory if it does not yet exist. Of the following code samples, which most efficiently creates a directory without throwing an exception if it already exists? If more than one code sample would work correctly, choose the sample that performs the desired task with the fewest lines of code.

1. ' VBDim di As DirectoryInfo = New DirectoryInfo("C:\dir\")If Not di.Exists Then di.Create()End If

// C#DirectoryInfo di = new DirectoryInfo(@"C:\dir\");if (!di.Exists) di.Create();

2. ' VBDirectory.CreateDirectory("C:\dir\")

// C#Directory.CreateDirectory(@"C:\dir\");

<Correct>

3. ' VBDim di As DirectoryInfo = New DirectoryInfo("C:\dir\")di.Create()

// C#DirectoryInfo di = new DirectoryInfo(@"C:\dir\");di.Create();

4. ' VBIf Not Directory.Exists("C:\dir\") Then Directory.CreateDirectory("C:\dir\")End If

// C#if (!Directory.Exists(@"C:\dir\")) Directory.CreateDirectory(@"C:\dir\");

Explanation :All of these code samples creates a directory without causing the runtime to throw an exception if the directory already exists. The most efficient technique is to call the static Directory.CreateDirectory method.

Calling DirectoryInfo.Create does create a directory without causing the runtime to throw an exception if the directory already exists. However, the most efficient technique is to call the static Directory.CreateDirectory method.

It is unnecessary to test whether a directory already exists before creating it.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Access files and folders by using the File System classes. (Refer System.IO namespace) Directory class and DirectoryInfo class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 1

Directory ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.io.directory.aspx

DirectoryInfo ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/8s2fzb02(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 150 (536P_7.1.3_01)

_________________________________________________________________________________________________________________

You need to display a number using culture-specific formatting. Which of the following code samples formats the number for the Danish language in Denmark?

1. ' VBDim d As Double = 65533.22Dim ci As CultureInfo = New CultureInfo("da-DK")Console.WriteLine(d, ci)

// C#double d = 65533.22;CultureInfo ci = new CultureInfo("da-DK");Console.WriteLine(d, ci);

2. ' VBDim d As Double = 65533.22Console.WriteLine(d, "da-CK")

// C#double d = 65533.22;Console.WriteLine(d, "da-CK");

3. ' VBDim d As Double = New Double(65533.22, "da-CK")Console.WriteLine(d)

// C#double d = new double(65533.22, "da-CK");Console.WriteLine(d);

4. ' VBDim d As Double = 65533.22Dim ci As CultureInfo = New CultureInfo("da-DK")Console.WriteLine(d.ToString(ci))

// C#double d = 65533.22;CultureInfo ci = new CultureInfo("da-DK");Console.WriteLine(d.ToString(ci));

<Correct>

Explanation :To format a number for a specific culture, create a CultureInfo object and then use the ToString override that accepts a CultureInfo object.

You cannot specify a culture when creating a number object.

Console.Writeline does not accept culture information for the purpose of formatting numbers.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Format data based on culture information. (Refer System.Globalization namespace) Format number values based on the culture.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 16 - Lesson 1

Formatting Numeric Data for a Specific CultureMSDN Library, Microsoft

Link: http://msdn2.microsoft.com/en-us/library/syy068tk(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 151 (536P_1.1.1_01)

_________________________________________________________________________________________________________________

You have created a class to represent a stop light. The stop light value can be set to either red, green, or yellow. Which of the following elements would you use to simplify how developers defined the value?

1. Method

2. Interface

3. Enumeration <Correct>

4. Structure

Explanation :An enumeration enables developers to use symbols--such as "Red", "Green", or "Yellow"--instead of more abstract values such as 1, 2, or 3.

A structure is a user-defined type created from a composite of other types.

A method is a member of a class that executes code.

An interface is a definition for a common set of members that you can use to provide compatibility for custom classes.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Value types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 1

When to Use an EnumerationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/zfezz6cy.aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 152 (536P_2.3.4_01)

_________________________________________________________________________________________________________________

Which of the following would you examine to determine whether the currently running assembly has permission to download assemblies via HTTP?

1. AppDomainSetup.CurrentDomain.DisallowCodeDownlaod

2. AppDomain.CurrentDomain.DisallowCodeDownload

3. this.SetupInformation.DisallowCodeDownlaod

4. AppDomain.CurrentDomain.SetupInformation.DisallowCodeDownload <Correct>

Explanation :To determine whether the currently running assembly has permission to download assemblies via HTTP, examine the AppDomain.CurrentDomain.SetupInformation.DisallowCodeDownload object.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Create a unit of isolation for common language runtime in a .NET Framework application by using application domains. (Refer System namespace) Retrieve setup information from an application domain.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 8 - Lesson 2

AppDomain ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.appdomain.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 153 (536P_2.2.9_01)

_________________________________________________________________________________________________________________

You are writing a multithreaded application where multiple threads must be synchronized so that they do not attempt to access the same object at the same time. Which of the following code samples demonstrates how to properly synchronize threads?

1. ' VBPrivate x As String

Monitor.Enter(x)Try ' Code that needs to be protected by the monitor.Finally Monitor.Exit(x)End Try

// C#private string x;Monitor.Enter(x);try { // Code that needs to be protected by the monitor.}finally { Monitor.Exit(x);}

2. ' VBPrivate x As IntegerMonitor.Enter(x)Try ' Code that needs to be protected by the monitor.Finally Monitor.Exit(x)End Try

// C#private int x;Monitor.Enter(x);try { // Code that needs to be protected by the monitor.}finally { Monitor.Exit(x);}

3. ' VBPrivate x As IntegerPrivate o As Object = x

Monitor.Enter(x)Try ' Code that needs to be protected by the monitor.Finally Monitor.Exit(x)End Try

// C#private int x;private Object o = x;Monitor.Enter(x);try { // Code that needs to be protected by the monitor.}finally { Monitor.Exit(x);}

4. ' VBPrivate x As ObjectMonitor.Enter(x)

Try ' Code that needs to be protected by the monitor.Finally Monitor.Exit(x)End Try

// C#private Object x;Monitor.Enter(x);try { // Code that needs to be protected by the monitor.}finally { Monitor.Exit(x);} <Correct>

Explanation :Monitor.Enter and Monitor.Exit should be used only with reference types.

You cannot pass a value type to Monitor because it will throw a run-time exception. You can only lock reference types.

Boxing a value type would not enable Monitor to function correctly because changes to the variable are not reflected in the boxed copy, and there is no way to change the value of the boxed copy.

While Strings are reference types, they behave like value types and should not be used with Monitor.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Develop multithreaded .NET Framework applications. (Refer System.Threading namespace) IAsyncResult interface (Refer System namespace)

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 7 - Lesson 3

MonitorsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/hf5de04k.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 154 (536P_7.2.2_02)

_________________________________________________________________________________________________________________

Which of the following code samples draws this graphic?

1. ' VBDim bm As Bitmap = New Bitmap(350, 75) Dim g As Graphics = Graphics.FromImage(bm) Dim f As Font = New Font("Arial", 35) Dim b As Brush = New SolidBrush(Color.Wheat) g.Clear(Color.Red) g.DrawString("Contoso, Inc.", f, b, 40, 40)

// C#Bitmap bm = new Bitmap(350, 75);Graphics g = Graphics.FromImage(bm);Font f = new Font("Arial", 35);Brush b = new SolidBrush(Color.Wheat);g.Clear(Color.Red);g.DrawString("Contoso, Inc.", f, b, 40, 40);

2. ' VBDim bm As Bitmap = New Bitmap(350, 75) Dim g As Graphics = Graphics.FromImage(bm) Dim f As Font = New Font("Arial", 4) Dim b As Brush = New SolidBrush(Color.Red) g.Clear(Color.Wheat) g.DrawString("Contoso, Inc.", f, b, 5, 5)

// C#Bitmap bm = new Bitmap(350, 75);Graphics g = Graphics.FromImage(bm);Font f = new Font("Arial", 4);Brush b = new SolidBrush(Color.Red);g.Clear(Color.Wheat);g.DrawString("Contoso, Inc.", f, b, 5, 5);

3. ' VBDim bm As Bitmap = New Bitmap(75, 350) Dim g As Graphics = Graphics.FromImage(bm) Dim f As Font = New Font("Arial", 40) Dim b As Brush = New SolidBrush(Color.Red) g.Clear(Color.Wheat) g.DrawString("Contoso, Inc.", f, b, 5, 5)

// C#Bitmap bm = new Bitmap(75, 350);Graphics g = Graphics.FromImage(bm);Font f = new Font("Arial", 40);Brush b = new SolidBrush(Color.Red);g.Clear(Color.Wheat);g.DrawString("Contoso, Inc.", f, b, 5, 5);

4. ' VBDim bm As Bitmap = New Bitmap(350, 75) Dim g As Graphics = Graphics.FromImage(bm) Dim f As Font = New Font("Arial", 40) Dim b As Brush = New SolidBrush(Color.Red) g.Clear(Color.Wheat) g.DrawString("Contoso, Inc.", f, b, 5, 5)

// C#Bitmap bm = new Bitmap(350, 75);Graphics g = Graphics.FromImage(bm);Font f = new Font("Arial", 40);Brush b = new SolidBrush(Color.Red);g.Clear(Color.Wheat);g.DrawString("Contoso, Inc.", f, b, 5, 5);

<Correct>

Explanation :Only this code sample creates a correctly shaped bitmap, fills the bitmap with a wheat-colored background, and then draws properly sized text.

Creating a Font object with a size of 4 would create an extremely small, unreadable font.

Creating a Bitmap object with the Bitmap(75, 350) constructor would create a tall, thin graphic rather than a wide, short graphic.

Drawing the text using the command g.DrawString("Contoso, Inc.", f, b, 40, 40) would draw the text too far down in the graphic.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the user interface of a .NET Framework application by using the System.Drawing namespace. Enhance the user interface of a .NET Framework application by using graphics, images, bitmaps, and icons.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 6 - Lesson 2

Graphics.DrawString MethodMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.drawing.graphics.drawstring.aspx

How to: Print Text in Windows FormsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/cwbe712d.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 155 (536P_3.2.8_01)

_________________________________________________________________________________________________________________

You have created an assembly called MyClass that contains a custom class that will be used by multiple applications. You want any assembly to be able to reference a single instance of MyClass without specifying the file path. You open the .NET Framework 2.0 Configuration tool. Where do you click?

In the illustration, click on the node you should use to make an assembly globally available.

Explanation :The assembly cache contains the set of assemblies available to all applications targeting the .NET Framework. Multiple versions of the same assembly can be placed in the assembly cache. This allows two applications to correctly execute even if they require different versions of the same shared assembly.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Create a custom Microsoft Windows Installer for the .NET Framework components by using the System.Configuration.Install namespace, and configure the .NET Framework applications by using configuration files, environment variables, and the .NET Framework Configuration tool (Mscorcfg.msc).). Configure a .NET Framework application by using the .NET Framework Configuration tool (Mscorcfg.msc).

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 2

.NET Framework Configuration Tool (Mscorcfg.msc)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/2bc0cxhc.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 156 (536P_1.6.2_01)

_________________________________________________________________________________________________________________

Which of the following are valid reasons to create a new class that inherits from the EventArgs class?

1. You need to pass specialized information to an event handler. <Correct>

2. You need to respond to nonstandard events.

3. You are responding to keyboard events, and you need to analyze the keys the user pressed.

4. You need to raise an event within a custom class.

Explanation :If you need to pass specialized information in addition to the source and an EventArgs object to an event handler, you should create a new class that inherits from the EventArgs class. You can then add custom properties to your class containing the specialized information.

You do not need to declare a new class to respond to nonstandard events, respond to keyboard events, or to raise an event within a custom class.

Objective:Developing applications that use system types and collections

Sub Objective(s):Control interactions between .NET Framework application components by using events and delegates. (Refer System namespace) EventArgs class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

EventArgs ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.eventargs.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 157 (536P_3.3.1_03)

_________________________________________________________________________________________________________________

You are writing an application that must perform event logging. Which of the following operating systems support event logging? (Choose all that apply.)

1. Windows 95

2. Windows 98

3. Windows ME

4. Windows XP<Correct>

5. Windows Server 2003 <Correct>

Explanation :Windows XP and Windows Server 2003 support event logging.

Windows ME, Windows 98, and Windows 95 do not support event logging.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Manage an event log by using the System.Diagnostics namespace. Write to an event log.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 1

EventLog ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 158 (536P_3.2.8_03)

_________________________________________________________________________________________________________________

You recently accepted a new job as an internal application developer, replacing a developer who recently moved on. Your manager has asked you to troubleshoot a problem with one of the internally developed applications that the support desk was unable to resolve. According to the support desk notes, the internal application no longer works for the user. During the troubleshooting process, the support desk determined that the application was missing a dependancy, but they couldn't identify the exact dependency.

The application is based on the .NET Framework 2.0. After opening the .NET Framework 2.0 Configuration tool, where would you click to identify and fix the dependency?

In the illustration, click on the node you should use to view and fix dependancies.

Explanation :The .NET Framework 2.0 Configuration tool gives you the ability to view, manage, and fix dependancies. First, click the Applications node. If necessary, add the application. Then select the application and click View The Assembly Dependencies or Fix This Application.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Create a custom Microsoft Windows Installer for the .NET Framework components by using the System.Configuration.Install namespace, and configure the .NET Framework applications by using configuration files, environment variables, and the .NET Framework Configuration tool (Mscorcfg.msc).). Configure a .NET Framework application by using the .NET Framework Configuration tool (Mscorcfg.msc).

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 2

.NET Framework Configuration Tool (Mscorcfg.msc)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/2bc0cxhc.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 159 (536P_4.4.3_01)

_________________________________________________________________________________________________________________

You need to verify that the C:\ drive is a fixed drive and throw an exception if it is not. Which of the following code samples accomplishes this in the most efficient manner?

1. ' VBIf Not (DriveInfo.GetDriveType("C") = DriveType.Fixed) Then Throw New Exception("The C:\ drive must be fixed")End If

// C#if (DriveInfo.GetDriveType("C") != DriveType.Fixed) throw new Exception(@"The C:\ drive must be fixed");

2. ' VBDim di As DriveInfo = New DriveInfo("C")If Not (di.DriveType = DriveType.Fixed) Then Throw New Exception("The C:\ drive must be fixed")End If

// C#DriveInfo di = new DriveInfo(@"C");if (di.DriveType != DriveType.Fixed) throw new Exception(@"The C:\ drive must be fixed");

<Correct>

3. ' VBDim di As DriveInfo() = DriveInfo.GetDrivesIf Not (di("C").DriveType = DriveType.Fixed) Then Throw New Exception("The C:\ drive must be fixed")End If

// C#DriveInfo[] di = DriveInfo.GetDrives();if (di["C"].DriveType != DriveType.Fixed) throw new Exception(@"The C:\ drive must be fixed");

4. ' VBDim di As DriveInfo = DriveInfo.GetDrives("C")If Not (di.DriveType = DriveType.Fixed) Then Throw New Exception("The C:\ drive must be fixed")End If

// C#DriveInfo di = DriveInfo.GetDrives("C");if (di.DriveType != DriveType.Fixed) throw new Exception(@"The C:\ drive must be fixed");

Explanation :To determine if a drive is fixed, create an instance of the DriveInfo class and then check DriveInfo.DriveType.

DriveInfo does not have a static GetDriveType method.

The DriveInfo.GetDrives static method does not accept a drive letter as a parameter.

The DriveInfo.GetDrives static method returns a standard, integer-indexed array of DriveInfo objects. The array cannot be accessed with the drive letter.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Access files and folders by using the File System classes. (Refer System.IO namespace) DriveInfo class and DriveType enumeration

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 1

DriveInfo ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/abt1306t(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 160 (536P_3.1.1_02)

_________________________________________________________________________________________________________________

You are writing an application that communicates with a database. The connection string is stored in the application configuration file. Which of the following would correctly retrieve the connection string?

1. ' VBConfigurationSettings.ConnectionStrings.ConnectionString

// C#ConfigurationSettings.ConnectionStrings.ConnectionString

2. ' VBConfigurationManager.ConnectionStrings.ConnectionString

// C#ConfigurationManager.ConnectionStrings.ConnectionString

3. ' VBConfigurationManager.ConnectionStrings(0).ConnectionString

// C#ConfigurationManager.ConnectionStrings[0].ConnectionString

<Correct>

4. ' VBConfigurationSettings.ConnectionStrings(0).ConnectionString

// C#ConfigurationSettings.ConnectionStrings[0].ConnectionString

Explanation :ConfigurationManager.ConnectionStrings is a collection of type ConnectionStringSettingsCollection that contains the connection strings loaded from the application's configuration file. Because it is a collection, you must access it using an index. ConfigurationSettings, which is obsolete, does not contain a ConnectionStrings property.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Embed configuration management functionality into a .NET Framework application. (Refer System.Configuration namespace) Configuration class and ConfigurationManager class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 1

ConfigurationManager.ConnectionStrings PropertyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.configuration.configurationmanager.connectionstrings.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 161 (536P_4.6.4_01)

_________________________________________________________________________________________________________________

Which of the following code samples correctly creates a new file named "Hello.dat" and writes the string "Hello, world!" to it?

1. ' VBDim fs As New FileStream("Hello.dat", FileMode.CreateNew)Dim bw As New BinaryWriter(fs)fs.Write("Hello, World!")bw.Close()fs.Close()

// C#FileStream fs = new FileStream("Hello.dat", FileMode.CreateNew);BinaryWriter bw = new BinaryWriter(fs);fs.Write("Hello, world!");bw.Close();fs.Close();

2. ' VBDim fs As New FileStream("Hello.dat", FileMode.CreateNew)Dim bw As New BinaryWriter(fs)bw.BaseStream.Write("Hello, World!")bw.Close()fs.Close()

// C#FileStream fs = new FileStream("Hello.dat", FileMode.CreateNew);BinaryWriter bw = new BinaryWriter(fs);bw.BaseStream.Write("Hello, world!");bw.Close();fs.Close();

3. ' VBDim fs As New FileStream("Hello.dat", FileMode.CreateNew)Dim bw As New BinaryWriter(fs)bw.Write("Hello, World!")bw.Close()fs.Close()

// C#FileStream fs = new FileStream("Hello.dat", FileMode.CreateNew);BinaryWriter bw = new BinaryWriter(fs);bw.Write("Hello, world!");bw.Close();fs.Close();

<Correct>

4. ' VBDim bw As New BinaryWriter("Hello.dat", FileMode.CreateNew)bw.Write("Hello, World!")bw.Close()

// C#BinaryWriter bw = new BinaryWriter("Hello.dat", FileMode.CreateNew);bw.Write("Hello, world!");bw.Close();

Explanation :To write to a file with BinaryWriter, first create a FileStream object and use that to create the BinaryWriter object. Then call the BinaryWriter.Write method. Finally, close both the BinaryWriter object and the FileStream object.

You can write directly to a FileStream object; however, the FileStream.Write method does not accept a string parameter.

You cannot use a BinaryWriter object without creating a FileStream object first.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Manage the .NET Framework application data by using Reader and Writer classes. (Refer System.IO namespace) BinaryReader class and BinaryWriter class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 2

How to: Read and Write to a Newly Created Data FileMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/36b93480(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 162 (536P_7.3.2_04)

_________________________________________________________________________________________________________________

Which of the following regular expressions would you use to validate a URL?

1. ([^@]+)@(.+)

2. http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)? <Correct>

3. ((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}

4. \d{5}

Explanation :http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)? validates a well-formed URL.

((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4} validates a well-formed phone number.

([^@]+)@(.+) validates a well-formed e-mail address.

\d{5} validates a postal code.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.RegularExpressions namespace) Regex class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 3 - Lesson 1

Validating User InputMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms172105.aspx

Regular Expression ClassesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/30wbz966.aspx

Regex ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 163 (536P_4.4.1_01)

_________________________________________________________________________________________________________________

Which of the following code samples is the most efficient way to rename a file from "File1.txt" to "File2.txt"?

1. ' VBFile.Rename("File1.txt", "File2.txt")

// C#File.Rename("File1.txt", "File2.txt");

2. ' VBFile.Replace("File1.txt", "File2.txt")

// C#File.Replace("File1.txt", "File2.txt");

3. ' VBFile.Move("File1.txt", "File2.txt")

// C#File.Move("File1.txt", "File2.txt");

<Correct>

4. ' VBFile.Copy("File1.txt", "File2.txt")File.Delete("File1.txt")

// C#File.Copy("File1.txt", "File2.txt");File.Delete("File1.txt");

Explanation :Use the static System.IO.File.Move method to rename files.

There is no File.Rename method. You should use File.Move instead.

Although copying and then deleting a file does effectively rename the file, it is not the most efficient way to rename a file.

Use File.Replace to copy a file while overwriting the destination file. File.Replace does not rename files.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Access files and folders by using the File System classes. (Refer System.IO namespace) File class and FileInfo class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 1

File ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/library/3saad2h5.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 164 (536P_4.4.5_02)

_________________________________________________________________________________________________________________

Which of the following is the most efficient way to create a name for a new temp file?

1. ' VBPath.GetTempPath + Path.GetTempFileName()

// C#Path.GetTempPath + Path.GetTempFileName();

2. ' VBPath.GetTempFileName()

// C#Path.GetTempFileName();

<Correct>

3. ' VBPath.GetTempPath + "\" + Path.GetTempFileName()

// C#Path.GetTempPath + @"\" + Path.GetTempFileName();

4. ' VBPath.Combine(Path.GetTempPath(), Path.GetTempFileName())

// C#Path.Combine(Path.GetTempPath(), Path.GetTempFileName());

Explanation :Path.GetTempFileName() is the most efficient way to identify a name for a new temp file.

Combining both Path.GetTempPath() and Path.GetTempFileName() is unnecessary because Path.GetTempFileName() already includes the path.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Access files and folders by using the File System classes. (Refer System.IO namespace) Path class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 1

Path ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/3bdzys9w(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 165 (536P_7.3.4_02)

_________________________________________________________________________________________________________________

You are writing a method that accepts dates as a string in mm/dd/yyyy format and returns the same date in yyyy-mm-dd format. Which of the following methods accomplishes this?

1. ' VBFunction ReformatDate(ByVal s As String) As String Dim m As Match = Regex.Match(s, "\b(<month>\d{1,2})/(<day>\d{1,2})/(<year>\d{2,4})\b") Return m.Groups("year").ToString() + "-" + m.Groups("month").ToString() + "-" + m.Groups("day").ToString()End Function

// C#static string ReformatDate(string s){ Match m = Regex.Match(s, @"\b(<month>\d{1,2})/(<day>\d{1,2})/(<year>\d{2,4})\b"); return m.Groups["year"] + "-" + m.Groups["month"] + "-" + m.Groups["day"];}

2. ' VBFunction ReformatDate(ByVal s As String) As String Dim m As Match = Regex.Match(s, "\b(?<month>\d{1,2})/(?<day>\d{1,2})/(?<year>\d{2,4})\b") Return m.Groups(year).ToString() + "-" + m.Groups(month).ToString() + "-" + m.Groups(day).ToString()End Function

// C#static string ReformatDate(string s){ Match m = Regex.Match(s, @"\b(?<month>\d{1,2})/(?<day>\d{1,2})/(?<year>\d{2,4})\b"); return m.Groups[year] + "-" + m.Groups[month] + "-" + m.Groups[day];}

3. ' VBFunction ReformatDate(ByVal s As String) As String Dim m As Match = Regex.Match(s, "\b(?<month>\d{1,2})/(?<day>\d{1,2})/(?<year>\d{2,4})\b") Return m.Groups("year").ToString() + "-" + m.Groups("month").ToString() + "-" + m.Groups("day").ToString()End Function

// C#static string ReformatDate(string s){ Match m = Regex.Match(s, @"\b(?<month>\d{1,2})/(?<day>\d{1,2})/(?<year>\d{2,4})\b"); return m.Groups["year"] + "-" + m.Groups["month"] + "-" + m.Groups["day"];} <Correct>

4. ' VBFunction ReformatDate(ByVal s As String) As String Dim m As Match = Regex.Match(s, "\b(<month>\d{1,2})/(<day>\d{1,2})/(<year>\d{2,4})\b") Return m.Groups(year).ToString() + "-" + m.Groups(month).ToString() + "-" + m.Groups(day).ToString()End Function

// C#static string ReformatDate(string s){ Match m = Regex.Match(s, @"\b(<month>\d{1,2})/(<day>\d{1,2})/(<year>\d{2,4})\b"); return m.Groups[year] + "-" + m.Groups[month] + "-" + m.Groups[day];}

Explanation :To extract information from a string, create a regular expression and surround the matched text with parentheses. In the case of a date number, you must match three groups of numbers, each separated by a slash. Months and days are two digits each, and the year can be one to four digits. Compare the date to the regular expression using Regex.Match. In this code sample, named groups are used. The year is placed in the "year" named group, the month in the "month" named group, and the day in the "day" named group. You can access each group from the Match.Groups collection using the group name, which must be in the form of a string with quotes.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.RegularExpressions namespace) Group class and GroupCollection class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 3 - Lesson 1

Regular Expression ClassesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/30wbz966.aspx

Regex ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 166 (536P_4.1.2_01)

_________________________________________________________________________________________________________________

Which attribute would you add to a member class to prevent it from being serialized?

1. IDeserializationCallback

2. ISerializable

3. OptionalField

4. NonSerialized <Correct>

Explanation :The NonSerialized attribute prevents a member from being serialized.

ISerializable and IDeserializationCallback are interfaces that you can implement when you need to control the serialization process.

OptionalField does not affect the serialization of a member. OptionalField affects only deserialization by preventing the runtime from throwing an exception if the member is not present in serialized data.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) Serilization attributes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 1

Selective SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/axwwbcs6.aspx

NonSerializedAttribute ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.nonserializedattribute.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 167 (536P_2.2.9_04)

_________________________________________________________________________________________________________________

Given the following code sample, how could you display the contents of the host variable in the ProcessDnsInformation method?

' VBDim callBack As AsyncCallback = New AsyncCallback(ProcessDnsInformation)host = Console.ReadLineDns.BeginGetHostEntry(host, callBack, host)

// C#AsyncCallback callBack = new AsyncCallback(ProcessDnsInformation);host = Console.ReadLine();Dns.BeginGetHostEntry(host, callBack, host);

1. ' VBShared Sub ProcessDnsInformation(result as IAsyncResult) Console.WriteLine(result.ToString())End Sub

// C#static void ProcessDnsInformation(IAsyncResult result){ Console.WriteLine(result.ToString());}

2. ' VBShared Sub ProcessDnsInformation(result as IAsyncResult) Console.WriteLine(result.AsyncState)End Sub

// C#static void ProcessDnsInformation(IAsyncResult result){ Console.WriteLine(result.AsyncState);}

3. ' VBShared Sub ProcessDnsInformation(result as IAsyncResult, host as String) Console.WriteLine(host)End Sub

// C#static void ProcessDnsInformation(IAsyncResult result, string host){ Console.WriteLine(host);}

4. ' VBShared Sub ProcessDnsInformation(result as IAsyncResult) Console.WriteLine(CType(result.AsyncState, String))End Sub

// C#static void ProcessDnsInformation(IAsyncResult result){ Console.WriteLine((string)result.AsyncState);} <Correct>

Explanation :If you provide an AsyncCallback delegate, you can provide an object when creating the asynchronous request. This object is not processed during the request and is simply passed to the method specified to handle the completed request. The object is stored in IAsyncResult.AsyncState, and you must cast or convert it to the proper type.

AsyncCallback delegates always accept a single parameter: an IAsyncResult object.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Develop multithreaded .NET Framework applications. (Refer System.Threading namespace) IAsyncResult interface (Refer System namespace)

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 7 - Lesson 3

Using an AsyncCallback Delegate to End an Asynchronous OperationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms228972(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 168 (536P_4.4.3_02)

_________________________________________________________________________________________________________________

You are writing an assembly that analyzes all files ending in a .txt or .dat extension in a specific folder. Which of the following code samples stores an array of all files with a .txt or a .dat extension contained in the C:\Windows folder in the allFiles array?

1. ' VBDim directoryInfo As DirectoryInfo = New DirectoryInfo("c:\windows")Dim txtFiles As FileInfo() = directoryInfo.GetFiles("*.txt")Dim datFiles As FileInfo() = directoryInfo.GetFiles("*.dat")Dim allFiles(txtFiles.Length + datFiles.Length - 1) As FileInfoArray.Copy(datFiles, 0, allFiles, 0, datFiles.Length)Array.Copy(txtFiles, 0, allFiles, datFiles.Length, txtFiles.Length)

// C#DirectoryInfo directoryInfo = new DirectoryInfo(@"c:\windows");FileInfo[] txtFiles = directoryInfo.GetFiles("*.txt"); FileInfo[] datFiles = directoryInfo.GetFiles("*.dat");FileInfo[] allFiles = new FileInfo[txtFiles.Length + datFiles.Length];Array.Copy(datFiles, 0, allFiles, 0, datFiles.Length);Array.Copy(txtFiles, 0, allFiles, datFiles.Length, txtFiles.Length);

<Correct>

2. ' VBDim directoryInfo As DirectoryInfo = New DirectoryInfo("c:\windows")Dim txtFiles As FileInfo() = directoryInfo.GetFiles("*.txt")Dim datFiles As FileInfo() = directoryInfo.GetFiles("*.dat")Dim allFiles() As FileInfo = txtFiles + datFiles

// C#DirectoryInfo directoryInfo = new DirectoryInfo(@"c:\windows");FileInfo[] txtFiles = directoryInfo.GetFiles("*.txt"); FileInfo[] datFiles = directoryInfo.GetFiles("*.dat");FileInfo[] allFiles = txtFiles + datFiles;

3. ' VBDim directoryInfo As DirectoryInfo = New DirectoryInfo("c:\windows")Dim allFiles As FileInfo() = directoryInfo.GetFiles("*.txt"|"*.dat")

// C#DirectoryInfo directoryInfo = new DirectoryInfo(@"c:\windows");FileInfo[] allFiles = directoryInfo.GetFiles("*.txt"|"*.dat");

4. ' VBDim directoryInfo As DirectoryInfo = New DirectoryInfo("c:\windows")Dim allFiles As FileInfo() = directoryInfo.GetFiles("*.txt | *.dat")

// C#DirectoryInfo directoryInfo = new DirectoryInfo(@"c:\windows");FileInfo[] allFiles = directoryInfo.GetFiles("*.txt | *.dat");

Explanation :DirectoryInfo.GetFiles can perform only one search at a time. Therefore, you would need to perform multiple searches and add the arrays using Array.Copy.

You cannot add arrays using the + operator.

DirectoryInfo.GetFiles cannot perform multiple searches simultaneously.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Access files and folders by using the File System classes. (Refer System.IO namespace) DriveInfo class and DriveType enumeration

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 1

Array.Copy MethodMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.array.copy.aspx

DirectoryInfo.GetFiles MethodMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.io.directoryinfo.getfiles.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 169 (536P_5.7.1_01)

_________________________________________________________________________________________________________________

You are writing an application that for a small organization that does not have an Active Directory domain. They would like you to implement your own user management system. Their requirements are simple: each user should have a unique username, and users should be granted privileges based on group memberships.

What classes or interfaces would you use to implement most efficiently the custom user management system? (Choose all that apply.)

1. GenericIdentity <Correct>

2. IPrincipal

3. WindowsIdentity

4. IIdentity

5. GenericPrincipal <Correct>

6. WindowsPrincipal

Explanation :In this example, you can meet all of the client's requirements by using the GenericIdentity and GenericPrincipal classes.

Using WindowsIdentity and WindowsPrincipal would require an Active Directory domain.

You could implement IIdentity and IPrincipal, but that would require writing more code than it would if you used GenericIdentity and GenericPrincipal.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Access and modify identity information by using the System.Security.Principal classes. (Refer System.Security.Principal namespace) GenericIdentity class and GenericPrincipal class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 1

GenericIdentity ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.principal.genericidentity(VS.80).aspx

GenericPrincipal ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.principal.genericprincipal(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 170 (536P_1.1.1_03)

_________________________________________________________________________________________________________________

Which of the following are value types? (Choose all that apply.)

1. char <Correct>

2. double <Correct>

3. bool <Correct>

4. string

5. delegate

6. interface

7. long <Correct>

Explanation :The types bool, char, double, and long are value types.

The types delegate, interface, and string are reference types.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Value types

References :.NET Framework Class Library OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/hfa3fa08.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 171 (536P_1.2.2_01)

_________________________________________________________________________________________________________________

Which of the following collections are available under both System.Collections and System.Collections.Generic? (Choose all that apply.)

1. List

2. Comparer <Correct>

3. Hashtable

4. Stack <Correct>

5. SortedDictionary

6. SortedList <Correct>

Explanation :The Comparer, Stack, and SortedList classes are available in both generic and nongeneric versions.

The List class is generic and is not available in the System.Collections namespace.

The SortedDictionary class is generic and is not available in the System.Collections namespace.

The Hashtable class is not generic and is not available in the System.Collections.Generic namespace.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage a group of associated data in a .NET Framework application by using collections. (Refer System.Collections namespace) Collection interfaces

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 4 - Lesson 3

System.Collections NamespaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/k166wx47(en-US,VS.80).aspx

System.Collections.Generic NamespaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/0sbxh9x2(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 172 (536P_3.3.3_01)

_________________________________________________________________________________________________________________

You have created a custom event log for your application. Your application provides tools for managing the event log, and one of the methods you need to implement clears all events from the event log. Which of the following code samples would do this?

1. ' VBPublic Sub ClearEventLog() Dim el As New EventLog("MyApp") el.Source = "DemoApp" el.Log.Clear()End Sub

// C#public static void ClearEventLog(){ EventLog el = new EventLog("MyApp"); el.Source = "DemoApp"; el.Log.Clear();}

2. ' VBPublic Sub ClearEventLog() Dim el As New EventLog("MyApp") el.Source = "DemoApp" For Each ele As EventLogEntry In el.Entries ele.Dispose() NextEnd Sub

// C#public static void ClearEventLog(){ EventLog el = new EventLog("MyApp"); el.Source = "DemoApp"; foreach (EventLog ele in el.Entries) ele.Dispose();}

3. ' VBPublic Sub ClearEventLog() Dim el As New EventLog("MyApp") el.Source = "DemoApp" el.Clear() el.Commit()End Sub

// C#public static void ClearEventLog(){ EventLog el = new EventLog("MyApp"); el.Source = "DemoApp"; el.Clear(); el.Commit();}

4. ' VBPublic Sub ClearEventLog() Dim el As New EventLog("MyApp") el.Source = "DemoApp" el.Clear()End Sub

// C#public static void ClearEventLog(){ EventLog el = new EventLog("MyApp"); el.Source = "DemoApp"; el.Clear();} <Correct>

Explanation :To clear an event log, create an EventLog object and specify the EventLog.Source property. Then call EventLog.Clear.

There is no EventLog.Commit or EventLog.Log.Clear method.

Iterating through EventLogEntry objects and calling EventLogEntry.Dispose would not remove the events from the event log; it would only destroy the instances of the EventLogEntry objects created in the runtime.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Manage an event log by using the System.Diagnostics namespace. Create a new event log.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 1

EventLog ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-US/library/system.diagnostics.eventlog(VS.80).aspx

Logging Application, Server, and Security EventsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-US/library/e6t4tk09.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 173 (536P_6.2.3_01)

_________________________________________________________________________________________________________________

Which of the following code samples correctly creates a managed definition for an unmanaged function in the user32.dll file?

1. ' VBImports System.Runtime.InteropServicesPublic Class Win32 <DllImport ("user32.dll", CharSet := CharSet.Auto)> _ Public Shared Function MessageBox (ByVal hWnd As Integer, _ ByVal txt As String, ByVal caption As String, _ ByVal Typ As Integer) As IntPtr End FunctionEnd Class

// C#using System.Runtime.InteropServices;[DllImport("user32.dll")] public static extern IntPtr MessageBox(int hWnd, String text, String caption, uint type);

<Correct>

2. ' VBImports System.Runtime.InteropServicesPublic Class Win32 <DllImport ("user32.dll", CharSet := CharSet.Auto)> _ Declare Public Shared Function MessageBox (ByVal hWnd As Integer, _ ByVal txt As String, ByVal caption As String, _ ByVal Typ As Integer) As IntPtr End FunctionEnd Class

// C#using System.Runtime.InteropServices;[DllImport("user32.dll")] declare public static extern IntPtr MessageBox(int hWnd, String text, String caption, uint type);

3. ' VBImports System.Runtime.InteropServicesPublic Class Win32 <DllDeclare ("user32.dll", CharSet := CharSet.Auto)> _ Public Shared Function MessageBox (ByVal hWnd As Integer, _ ByVal txt As String, ByVal caption As String, _ ByVal Typ As Integer) As IntPtr End FunctionEnd Class

// C#using System.Runtime.InteropServices;[DllDeclare("user32.dll")] public static extern IntPtr MessageBox(int hWnd, String text, String caption, uint type);

4. ' VBImports System.Runtime.InteropServicesPublic Class Win32 <DllDeclare ("user32.dll", CharSet := CharSet.Auto)> _ Declare Public Shared Function MessageBox (ByVal hWnd As Integer, _ ByVal txt As String, ByVal caption As String, _ ByVal Typ As Integer) As IntPtr End FunctionEnd Class

// C#using System.Runtime.InteropServices;[DllDeclare("user32.dll")] declare public static extern IntPtr MessageBox(int hWnd, String text,

String caption, uint type);

Explanation :To create a managed definition for an unmanaged function, add the System.Runtime.InteropServices namespace. Then create a method that matches the signature of the unmanaged function (in C#, use the extern keyword), and specify the DllImport attribute.

There is no Declare keyword required for a managed definition of an unmanaged function.

There is no DllDeclare attribute.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Call unmanaged DLL functions in a .NET Framework application, and control the marshaling of data in a .NET Framework application. (Refer System.Runtime.InteropServices namespace) Create prototypes in managed code.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 13 - Lesson 3

Creating Prototypes in Managed CodeMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/w4byd5y4(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 174 (536P_3.1.1_01)

_________________________________________________________________________________________________________________

You are writing an application that remembers a username in the application settings. Which of the following code samples is the best way to retrieve a username?

1. ' VBDim un As String = ConfigurationManager.AppSettings.GetSetting("username")

// C#string un = ConfigurationManager.AppSettings.GetSetting("username");

2. ' VBDim un As String = ConfigurationSettings.AppSettings("username")

// C#string un = ConfigurationSettings.AppSettings["username"];

3. ' VBDim nvc As NameValueCollection = ConfigurationManager.AppSettingsDim un As String = nvc("username")

// C#NameValueCollection nvc = ConfigurationManager.AppSettings;string un = nvc["username"];

<Correct>

4. ' VBDim nvc As NameValueCollection = ConfigurationSettings.AppSettingsDim un As String = nvc("username")

// C#NameValueCollection nvc = ConfigurationSettings.AppSettings;string un = nvc["username"];

Explanation :When writing assemblies for the .NET Framework version 2.0, you should use ConfigurationManager.AppSettings instead of ConfigurationSettings.AppSettings. ConfigurationSettings is now obsolete, and using it will result in a compiler warning.

ConfigurationManager.AppSettings does not have a GetSetting method.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Embed configuration management functionality into a .NET Framework application. (Refer System.Configuration namespace) Configuration class and ConfigurationManager class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 1

ConfigurationManager.AppSettings PropertyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.configuration.configurationmanager.appsettings.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 175 (536P_7.3.2_02)

_________________________________________________________________________________________________________________

Which of the following regular expressions would you use to validate an e-mail address?

1. ((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}

2. ([^@]+)@(.+) <Correct>

3. http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?

4. \d{5}

Explanation :([^@]+)@(.+) validates a well-formed e-mail address.

((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4} validates a well-formed phone number.

http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)? validates a well-formed URL.

\d{5} validates a postal code.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.RegularExpressions namespace) Regex class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 3 - Lesson 1

Validating User InputMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms172105.aspx

Regular Expression ClassesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/30wbz966.aspx

Regex ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx

How to match a pattern by using regular expressions and Visual C# 2005 or Visual C# .NETMicrosoft Help and Support, MicrosoftLink: http://support.microsoft.com/default.aspx/kb/308252?

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 176 (536P_1.5.2_02)

_________________________________________________________________________________________________________________

You are creating a custom class that allocates large blocks of memory. Rather than wait for the runtime to automatically free the resources, you want developers who use your class to be able to free resources on demand when an instance of the class is no longer needed. Which interface should you implement?

1. IEquatable

2. ICloneable

3. IComparable

4. IConvertible

5. IFormattable

6. INullableValue

7. IDisposable <Correct>

Explanation :Implementing IDisposable enables developers to call the Dispose() method, which allows your class to free any consumed resources without waiting for automated garbage collection.

Implementing the other interfaces does not allow a class to be manually disposed of.

Objective:Developing applications that use system types and collections

Sub Objective(s):Implement .NET Framework interfaces to cause components to comply with standard contracts. (Refer System namespace) IDisposable interface

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

IDisposable InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.idisposable.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 177 (536P_1.6.3_01)

_________________________________________________________________________________________________________________

Which of the following are standard parameters for an event handler delegate? (Choose all that apply.)

1. EventHandler

2. Delegate

3. EventArgs <Correct>

4. Event

5. Object <Correct>

Explanation :Event handler delegates require two parameters: an instance of the Object class and an instance of the EventArgs class.

The EventHandler class is a predefined delegate that specifically represents an event handler method for an event that does not generate data. It is not a parameter for an event handler delegate.

The Delegate class is the base class for delegate types. It is not a parameter for event handler delegates.

The Event class is the base event for event types. It is not a parameter for event handler delegates.

Objective:Developing applications that use system types and collections

Sub Objective(s):Control interactions between .NET Framework application components by using events and delegates. (Refer System namespace) EventHandler delegates

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

Events and DelegatesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/17sde2xt.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 178 (536P_4.1.1_07)

_________________________________________________________________________________________________________________

Which tool would you use to create a class that, when serialized using XmlSerializer, would conform to a specific schema?

1. Xml.exe

2. Schema.exe

3. XmlSerializer.exe

4. Xsd.exe <Correct>

Explanation :If you have an XML Schema, you can run the XML Schema Definition tool (Xsd.exe) to produce a set of classes that are strongly typed to the schema and annotated with attributes.

XmlSerializer.exe, Schema.exe, and Xml.exe are not .NET Framework tools.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) Serialization interfaces

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 1

XML Schema Definition Tool (Xsd.exe)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/x6c1kb0s.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 179 (536P_1.1.2_06)

_________________________________________________________________________________________________________________

In which of the following circumstances should you NOT throw an exception?

1. A parameter contains a value that is out of range.

2. You have completed all iterations of a for loop. <Correct>

3. A file that you need to read does not exist.

4. Security restrictions prevent you from creating a file.

Explanation :Normal execution of program logic should not cause an exception.

You should throw an exception whenever something unexpected happens, including receiving a parameter that is out of range.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Reference types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

Exceptions OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/6kzk0czb.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 180 (536P_7.1.5_02)

_________________________________________________________________________________________________________________

Which of the following types would you first create an instance of to define a custom culture?

1. CultureAndRegionInfoBuilder <Correct>

2. CultureAndRegionModifier

3. CultureInfo

4. CultureTypes

Explanation :The CultureAndRegionInfoBuilder class defines a custom culture that is new or based on an existing culture and region. The custom culture can be installed on a computer and subsequently used by any application running on that computer.

The CultureInfo class provides information about a specific culture. Once you have defined a custom culture with CultureAndRegionInfoBuilder, you could then create a CultureInfo object based on the custom class. However, you must first define CultureAndRegionInfoBuilder.

The CultureAndRegionModifiers enumeration specifies constants that define a CultureAndRegionInfoBuilder object.

The CultureTypes enumeration defines the types of culture lists that can be retrieved using CultureInfo.GetCultures.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Format data based on culture information. (Refer System.Globalization namespace) Build a custom culture class based on existing culture and region classes.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 16 - Lesson 2

How to: Create Custom CulturesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms172469.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 181 (536P_4.1.1_01)

_________________________________________________________________________________________________________________

Which interface would you use to most efficiently automatically initialize a nonserialized member when deserializing data?

1. IFormatterConverter

2. IDeserializationCallback <Correct>

3. IFormatter

4. ISerializable

Explanation :The simplest way to initialize nonserialized members is to implement the IDeserializationCallback interface and override the OnDeserialization method.

The IFormatter interface provides functionality for formatting serialized objects, but it is not the most efficient way to initialize nonserialized members.

The ISerializable interface allows an object to control its own serialization and deserialization; however, it is not the most efficient way to initialize nonserialized members.

The IFormatterConverter interface provides the connection between an instance of SerializationInfo and the formatter-provided class best suited to parse the data inside SerializationInfo. It cannot be used to initialize nonserialized members.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) Serialization interfaces

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 1

Custom SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ty01x675.aspx

IDeserializationCallback InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.ideserializationcallback.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 182 (536P_1.1.2_04)

_________________________________________________________________________________________________________________

What is the output of the following code?

' VBDim s1 As String = "hello" Dim s2 As String = "h" s2 += "ello" Console.WriteLine(s1 = s2) Console.WriteLine(CType(s1, Object) = CType(s2, Object))

// C#string s1 = "hello";string s2 = "h";s2 += "ello";Console.WriteLine(s1 == s2);Console.WriteLine((object)s1 == (object)s2);

1. ' VBTrueFalse

// C#TrueTrue

2. ' VBFalseTrue

// C#FalseFalse

3. ' VBFalseFalse

// C#FalseTrue

4. ' VBTrueTrue

// C#TrueFalse

<Correct>

Explanation :The first comparison is true because the values in both s1 and s2 are equal. In C#, the second comparison is false because string is a reference type, and s1 and s2 are two distinct objects with different references. In Visual Basic, the second comparison is true because comparing the strings after converting them to Objects still compares the values in s1 and s2.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Reference types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

Common Type System OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/2hf02550.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 183 (536P_7.3.2_06)

_________________________________________________________________________________________________________________

A coworker has written an application that uses regular expressions to validate user input, and you are performing a security review on the application. The user input should be two numbers, a hyphen, and then two more numbers to match the pattern ##-##. The application uses the regular expression "\d{2}-\d{2}" to accomplish this. Which of the following inputs would the regular expression allow? (Choose all that apply.)

1. 252-35 <Correct>

2. 583

3. 15-64 <Correct>

4. 234+32

5. 1623

6. 73-255 <Correct>

Explanation :The regular expression "\d{2}-\d{2}" matches the beginning, middle, or end of a string. Therefore, it will match any string that contains the pattern ##-##. If there are additional characters before or after that pattern, it will still match. This is not what the original developer was trying to accomplish, however. The developer should change the regular expression to "^\d{2}-\d{2}$" so that no additional characters can preceed or follow the regular expresion.

Values that lack a hyphen will not match the regular expression.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.RegularExpressions namespace) Regex class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 3 - Lesson 1

Validating User InputMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms172105.aspx

Regular Expression ClassesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/30wbz966.aspx

Regex ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 184 (536P_7.2.2_01)

_________________________________________________________________________________________________________________

Which of the following code samples correctly saves a JPEG image? (Choose all that apply.)

1. ' VBDim Bm As Bitmap = New Bitmap(100, 100)Bm.Save("picture.jpg", ImageFormat.Jpeg)

// C#Bitmap bm = new Bitmap(100, 100);bm.Save("picture.jpg", ImageFormat.Jpeg);

<Correct>

2. ' VBDim Bm As Bitmap = New Bitmap(100, 100)Bm.Save("picture.jpg", "JPEG")

// C#Bitmap bm = new Bitmap(100, 100);bm.Save("picture.jpg", "JPEG");

3. ' VBDim Bm As Bitmap = New Bitmap(100, 100, ImageFormat.Jpeg)Bm.Save("picture.jpg")

// C#Bitmap bm = new Bitmap(100, 100, ImageFormat.Jpeg);bm.Save("picture.jpg");

4. ' VBDim Bm As Bitmap = New Bitmap(100, 100)Bm.Save("picture.jpg")

// C#Bitmap bm = new Bitmap(100, 100);bm.Save("picture.jpg");

<Correct>

Explanation :You can specify the image format when calling the Bitmap.Save method. If you do not specify an image format, Bitmap.Save defaults to the JPEG format.

You cannot specify the image format using a string.

You cannot specify the image format during the Bitmap constructor.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the user interface of a .NET Framework application by using the System.Drawing namespace. Enhance the user interface of a .NET Framework application by using graphics, images, bitmaps, and icons.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 6 - Lesson 2

Image.Save Method (Stream, ImageFormat)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms142147.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 185 (536P_2.1.3_01)

_________________________________________________________________________________________________________________

Which of the following must you do before running a service?

1. Create a LocalSystem user account.

2. Add the service to the user's Startup group.

3. Install the service. <Correct>

4. Open a command prompt.

Explanation :Services must be installed prior to running. As a result, you cannot launch a service directly from your development environment.

You cannot add a service to a user's startup group because services cannot be run directly by users.

You cannot run a service directly from a command prompt.

You do not need to create the LocalSystem account; it is built into Microsoft Windows.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Implement, install, and control a service. (Refer System.ServiceProcess namespace) ServiceInstaller and ServiceProcessInstaller class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 8 - Lesson 3

Introduction to Windows Service ApplicationsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/d56de412.aspx

Walkthrough: Creating a Windows Service Application in the Component DesignerMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/zt39148a.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 186 (536P_2.2.5_01)

_________________________________________________________________________________________________________________

You have written a multithreaded application for the .NET Framework version 2.0. What happens if an unhandled exception occurs in a thread you start?

1. The exception is forwarded to the main thread. <Correct>

2. The runtime terminates the application.

3. The runtime provides a backstop for the unhandled exception.

4. The runtime ignores the exception and continues running the thread.

Explanation :The runtime will forward the exception to the parent thread in the .NET Framework version 2.0.

In the .NET Framework versions 1.0 and 1.1, the runtime would provide a backstop for unhandled exceptions in child threads. However, this behavior has changed in the .NET Framework version 2.0.

Unhandled exceptions often result in terminating the application; however, the parent process does have the opportunity to handle the exception.

The runtime does not ignore exceptions under any circumstances.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Develop multithreaded .NET Framework applications. (Refer System.Threading namespace) ThreadExceptionEventArgs class and ThreadExceptionEventHandler class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 7 - Lesson 3

Exceptions in Managed ThreadsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms228965.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 187 (536P_1.5.1_01)

_________________________________________________________________________________________________________________

Which of the following methods is inherited from the IComparable interface?

1. Clone()

2. CompareTo() <Correct>

3. Dispose()

4. ToString()

5. GetType()

6. Equals()

Explanation :The CompareTo() method is a member of the IComparable interface.

All classes inherit the ToString(), Equals(), and GetType() methods from the base Object class.

The Dispose() method is a member of the IDisposable interface.

The Clone() method is a member of the ICloneable interface.

Objective:Developing applications that use system types and collections

Sub Objective(s):Implement .NET Framework interfaces to cause components to comply with standard contracts. (Refer System namespace) IComparable interface

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

IComparable InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ey2t2ys5(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 188 (536P_1.1.2_01)

_________________________________________________________________________________________________________________

Which of the following are reference types? (Choose all that apply.)

1. double

2. interface <Correct>

3. string <Correct>

4. long

5. delegate <Correct>

6. bool

7. char

Explanation :The types delegate, interface, and string are reference types.

The types bool, char, double, and long are value types.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Reference types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

.NET Framework Class Library OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/hfa3fa08.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 189 (536P_7.2.1_01)

_________________________________________________________________________________________________________________

Which of the following code samples draws a line from the upper-left corner towards the lower-right corner?

1. ' VBDim g As Graphics = Me.CreateGraphics Dim b As Brush = New Brush(Color.Red, 7) g.DrawLine(b, 1, 1, 100, 100)

// C#Graphics g = this.CreateGraphics();Brush b = new Brush(Color.Red, 7);g.DrawLine(b, 1, 1, 100, 100);

2. ' VBDim g As Graphics = Me.CreateGraphics Dim p As Pen = New Pen(Color.Red, 7) g.DrawLine(p, 100, 1, 1, 100)

// C#Graphics g = this.CreateGraphics();Pen p = new Pen(Color.Red, 7);g.DrawLine(p, 100, 1, 1, 100);

3. ' VBDim g As Graphics = Me.CreateGraphics Dim p As Pen = New Pen(Color.Red, 7) g.DrawLine(p, 1, 1, 100, 100)

// C#Graphics g = this.CreateGraphics();Pen p = new Pen(Color.Red, 7);g.DrawLine(p, 1, 1, 100, 100);

<Correct>

4. ' VBDim g As Graphics = Me.CreateGraphics Dim b As Brush = New Brush(Color.Red, 7) g.DrawLine(b, 100, 1, 1, 100)

// C#Graphics g = this.CreateGraphics();Brush b = new Brush(Color.Red, 7);g.DrawLine(b, 100, 1, 1, 100);

Explanation :The command DrawLine(p, 1, 1, 100, 100) draws a line from the point 1, 1 (the upper-left corner) to 100, 100 (the lower-right corner). The first coordinate describes the horizontal position relative to the upper-left corner. The second coordinate describes the vertical position relative to the upper-left corner.

You cannot draw a line with a Brush object. You must use a Pen object.

DrawLine(p, 100, 1, 1, 100) would draw a line from the upper-right corner to the lower-left corner.

You cannot draw a line with a Brush object. You must use a Pen object. Additionally, DrawLine(p, 100, 1, 1, 100) would draw a line from the upper-right corner to the lower-left corner.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the user interface of a .NET Framework application by using the System.Drawing namespace. Enhance the user interface of a .NET Framework application by using brushes, pens, colors, and fonts.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 6 - Lesson 1

Graphics.DrawLine MethodMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.drawing.graphics.drawline.aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 6 - Lesson 3

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 190 (536P_7.1.1_01)

_________________________________________________________________________________________________________________

You are writing an English-language client application that must process data files generated by a server application. The server application runs at your organization's office in Sweden and was developed locally. How can you change the culture of your application to ensure the data file is processed correctly?

1. ' VBCultureInfo.CurrentCulture = "sv-SE"

// C#CultureInfo.CurrentCulture = "sv-SE";

2. ' VBThread.CurrentThread.CurrentCulture.Name = "sv-SE"

// C#Thread.CurrentThread.CurrentCulture.Name = "sv-SE";

3. ' VBCultureInfo.CurrentCulture = New CultureInfo("sv-SE")

// C#CultureInfo.CurrentCulture = new CultureInfo("sv-SE");

4. ' VBThread.CurrentThread.CurrentCulture = New CultureInfo("sv-SE")

// C#Thread.CurrentThread.CurrentCulture = new CultureInfo("sv-SE");

<Correct>

Explanation :To modify the culture setting, set the Thread.CurrentThread.CurrentCulture property using a CultureInfo object.

CultureInfo.CurrentCulture is read-only.

CultureInfo.CurrentCulture is read-only and is of type CultureInfo.

Thread.CurrentThread.CurrentCulture.Name is a read-only property.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Format data based on culture information. (Refer System.Globalization namespace) Access culture and region information in a .NET Framework application.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 16 - Lesson 1

CultureInfo ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 191 (536P_4.1.2_03)

_________________________________________________________________________________________________________________

You are creating a class that implements the ISerializable interface. Which serialization event should you respond to if you need to run code prior to serialization?

1. Deserialized

2. Serializing <Correct>

3. Deserializing

4. Serialized

Explanation :The Serializing event occurs prior to serialization.

The Serialized event occurs immediately after serialization.

The Deserializing event occurs prior to deserialization.

The Deserialized event occurs immediately after serialization.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) Serilization attributes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 1

Custom SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ty01x675.aspx

Basics of .NET Framework SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms233836.aspx

ISerializable InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.iserializable.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 192 (536P_3.1.1_07)

_________________________________________________________________________________________________________________

While performing a security review of a peer's code, you see an If statement that checks the ConfigurationManager.AppSettings("username") value and grants additional privileges if it is equal to "Tom". You need to test the behavior, but the application does not currently have a configuration file. How would you create the configuration file to define that value?

1. <?xml version="1.0" encoding="utf-8" ?><configuration> <appSettings> <key="username" value="Tom"/> </appSettings></configuration>

2. <?xml version="1.0" encoding="utf-8" ?><configuration> <add key="username" value="Tom"/></configuration>

3. <?xml version="1.0" encoding="utf-8" ?><configuration> <key="username" value="Tom"/></configuration>

4. <?xml version="1.0" encoding="utf-8" ?><configuration> <appSettings> <add key="username" value="Tom"/> </appSettings></configuration>

<Correct>

Explanation :Elements accessed through ConfigurationManager.AppSettings must be defined in the application configuration file, in an <appSettings> element nested within <configuration>. To define a specific key, use the <add key> element.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Embed configuration management functionality into a .NET Framework application. (Refer System.Configuration namespace) Configuration class and ConfigurationManager class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 1

Application Settings ArchitectureMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/8eyb2ct1.aspx

add Element for appSettings (General Settings Schema)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms228312.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 193 (536P_1.2.10_02)

_________________________________________________________________________________________________________________

You are writing an application that needs to perform Boolean math on a set of 42 bits. Which of the following classes would be most efficient?

1. BitVector32

2. ArrayList

3. Boolean

4. BitArray <Correct>

Explanation :The BitArray class is a resizable collection that can store Boolean values. In addition to being resizable, it supports common bit-level operations such as And, Not, Or, and Exclusive-or (XOR).

The purpose of the BitVector32 structure is to aid in manipulating bits in a 32-bit integer. The BitVector32 is not a resizable collection at all. Instead, it is fixed at 32 bits so that it can manipulate the individual bits of a 32-bit integer. In this case, BitVector32 does not have enough bits.

Boolean is a single bit value. You would need to separately access 42 Boolean variables, which would not be efficient.

You could use an ArrayList, however, it would not be as efficient because it does not support Boolean math.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage a group of associated data in a .NET Framework application by using collections. (Refer System.Collections namespace) BitArray class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 4 - Lesson 4

BitArray ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.collections.bitarray.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 194 (536P_5.4.17_01)

_________________________________________________________________________________________________________________

You are writing an assembly that verifies files have not been modified since they were initially scanned. The checksums will be stored in a text file. Which hashing algorithms could you use to prevent an attacker from modifying both the file and the checksum? (Choose all that apply.)

1. MACTripleDES <Correct>

2. HMACSHA1<Correct>

3. SHA256

4. MD5

Explanation :HMACSHA1 and MACTripleDES are keyed hashing algorithms, which protect against modification of the hash by encrypting it through the use of a secret key that both the sender and receiver must have.

MD5 and SHA256 are unkeyed hashing algorithms, which can be modified by an unauthorized user without being easily detected.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace) Hash-based Message Authentication Code (HMAC)

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 3

Cryptography OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/92f9ye3s.aspx

KeyedHashAlgorithm ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.cryptography.keyedhashalgorithm.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 195 (536P_4.1.5_01)

_________________________________________________________________________________________________________________

Which class should you use when serializing data to be consumed only by .NET applications?

1. SoapFormatter

2. XmlSerializer

3. BinaryFormatter <Correct>

4. ISerializable

Explanation :BinaryFormatter provides the best efficiency when only .NET applications will consume the serialized data.

SoapFormatter provides standards-based serialization, but it is not as efficient as BinaryFormatter.

ISerializable is an interface you can use to implement custom serialization. You cannot use it directly to perform serialization.

XmlSerializer provides standards-based serialization, but it is not as efficient as BinaryFormatter.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) Formatter class, FormatterConverter class, and FormatterServices class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 3

BinaryFormatter ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.formatters.binary.binaryformatter.aspx

Basic SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/4abbf6k0.aspx

Basic Serialization Technology SampleMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/s4w7yaw2.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 196 (536P_5.1.2_01)

_________________________________________________________________________________________________________________

Which of the following would you use to limit the permissions available to a portion of a method by declaring only the permissions the code segment should have?

1. CodeAccessPermission.PermitOnly <Correct>

2. SecurityAction.PermitOnly

3. CodeAccessPermission.Assert

4. SecurityAction.Deny

Explanation :Use CodeAccessPermission.PermitOnly to imperatively reduce permissions when a section of a method requires fewer permissions than the rest of the method. This is particularly important when calling objects created by third parties.

SecurityAction.PermitOnly declarations limit the permissions available to a method by specifying only the permissions the method should have. SecurityAction.PermitOnly is similar to CodeAccessPermission.PermitOnly, except it is declarative rather than imperative.

SecurityAction.Deny declarations refine the permissions available to a method by eliminating specific, named permissions. It cannot be used imperatively.

Use CodeAccessPermission.Assert when you want to allow partially trusted code to call a method that requires permissions the caller might lack.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement code access security to improve the security of a .NET Framework application. (Refer System.Security namespace) CodeAccessPermission class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 2

CodeAccessPermission.PermitOnly MethodMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.codeaccesspermission.permitonly.aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 3

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 197 (536P_5.4.7_01)

_________________________________________________________________________________________________________________

Which of the following classes provide asymmetric encryption?

1. RijndaelManaged

2. DES

3. DSACryptoServiceProvider

4. RC2

5. TripleDES

6. RSACryptoServiceProvider <Correct>

Explanation :RSACryptoServiceProvider provides asymmetric encryption.

DSACryptoServiceProvider provides asymmetric digital signatures; it does not provide encryption.

RijndaelManaged, DES, RC2, and TripleDES are all symmetric encryption classes.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace) RSA class and RSACryptoServiceProvider class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 3

RSACryptoServiceProvider ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.cryptography.rsacryptoserviceprovider.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 198 (536P_4.1.1_02)

_________________________________________________________________________________________________________________

Which of the following are requirements for implementing custom serialization using the ISerializable interface? (Choose all that apply.)

1. Designate a method to respond to the Serialized and Deserialized events.

2. Override the GetObjectData method. <Correct>

3. Designate a method to respond to the Serializing and Deserializing events.

4. Override the OnDeserialization method.

5. Implement a constructor that accepts SerializationInfo and StreamingContext objects as parameters. <Correct>

Explanation :To implement ISerializable, you must override the GetObjectData method and create a constructor that accepts SerializationInfo and StreamingContext objects as parameters.

You can respond to the Serializing and Deserializing events, but it is not a requirement.

You can respond to the Serialized and Deserialized events, but it is not a requirement.

You must override the OnDeserialization method when you implement the IDeserializationCallback interface. It is not a member of the ISerializable interface.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) Serialization interfaces

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 1

Custom SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ty01x675.aspx

Basics of .NET Framework SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms233836.aspx

ISerializable InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.iserializable.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 199 (536P_2.2.1_04)

_________________________________________________________________________________________________________________

You are writing managed code that will be executed within a thread. What do you need to do to enable your code to recover from a call to Thread.Sleep and a subsequent Thread.Interrupt call?

1. Respond to the parent process's On_Interrupt event.

2. Catch the ThreadInterruptedException and do whatever is appropriate to continue working. <Correct>

3. Nothing. Processing will automatically continue where it left off.

4. Implement the IInterruptible interface.

Explanation :You can interrupt a waiting thread by calling System.Threading.Thread.Interrupt on the blocked thread to throw a ThreadInterruptedException, which breaks the thread out of the blocking call. The thread should catch the ThreadInterruptedException and do whatever is appropriate to continue working.

If a thread does not respond to an exception, the runtime catches the exception and stops the thread.

There is no IInterruptible interface.

There is no On_Interrupt event.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Develop multithreaded .NET Framework applications. (Refer System.Threading namespace) Thread class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 7 - Lesson 1

Pausing and Resuming ThreadsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/tttdef8x.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 200 (536P_5.7.2_04)

_________________________________________________________________________________________________________________

You are writing a method for internal use within your organization. Per instructions from your IT department, only users who are members of the domain group CONTOSO\Developers should be able to run your method. Which of the following code samples would prevent users who are not members of the Developers domain group from running your method?

1. ' VBDim i As WindowsIdentity = WindowsIdentity.GetCurrent If Not i.IsInRole("CONTOSO\Developers") Then Throw New SecurityException("You must be a Developer")End If

// C#WindowsIdentity i = WindowsIdentity.GetCurrent();if (!i.IsInRole(@"CONTOSO\Developers")) throw new SecurityException("You must be a Developer");

2. ' VBDim i As WindowsIdentity = WindowsIdentity.GetCurrent Dim currentPrincipal As WindowsPrincipal = New WindowsPrincipal(i)If Not currentPrincipal.IsInRole("Developers") Then Throw New SecurityException("You must be a Developer")End If

// C#WindowsIdentity i = WindowsIdentity.GetCurrent();WindowsPrincipal currentPrincipal = new WindowsPrincipal(i);if (!currentPrincipal.IsInRole("Developers")) throw new SecurityException("You must be a Developer");

3. ' VBDim i As WindowsIdentity = WindowsIdentity.GetCurrent Dim currentPrincipal As WindowsPrincipal = New WindowsPrincipal(i)If Not currentPrincipal.IsInRole("CONTOSO\Developers") Then Throw New SecurityException("You must be a Developer")End If

// C#WindowsIdentity i = WindowsIdentity.GetCurrent();WindowsPrincipal currentPrincipal = new WindowsPrincipal(i);if (!currentPrincipal.IsInRole(@"CONTOSO\Developers")) throw new SecurityException("You must be a Developer");

<Correct>

4. ' VBDim i As WindowsIdentity = WindowsIdentity.GetCurrent If Not i.IsInRole("Developers") Then Throw New SecurityException("You must be a Developer")End If

// C#WindowsIdentity i = WindowsIdentity.GetCurrent();if (!i.IsInRole("Developers")) throw new SecurityException("You must be a Developer");

Explanation :To check which domain groups a user is in, create a WindowsPrincipal object based on WindowsIdentity.GetCurrent(). Then check WindowsPrincipal.IsInRole using just the domain name, a backslash, and the group name.

WindowsIdentity does not have an IsInRole method. Instead, you should create a WindowsPrincipal object. Additionally, you must prepend the domain name to the group name when using WindowsPrincipal.IsInRole to determine domain group memberships.

Objective:

Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Access and modify identity information by using the System.Security.Principal classes. (Refer System.Security.Principal namespace) WindowsIdentity class and WindowsPrincipal class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 1

WindowsIdentity ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.principal.windowsidentity.aspx

WindowsPrincipal ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.principal.windowsprincipal.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 201 (536P_1.1.2_05)

_________________________________________________________________________________________________________________

Which of the following is an accurate description of a reference type?

1. An error condition or unexpected behavior encountered by an executing program that causes normal execution to be halted.

2. A class that uses placeholders for one or more of the types it uses.

3. A type from one assembly that is moved into another assembly so that it is not necessary to recompile clients that consume the first assembly.

4. A type that stores a pointer to the data, rather than the actual data. <Correct>

Explanation :Reference types store a pointer to the data, rather than the actual data.

Type forwarding enables moving a type from one assembly into another assembly without requiring recompiling.

Exceptions are error conditions that cause normal execution to be halted.

Generics use placeholders for their types, which allow multiple types of objects to be used as a parameter.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Reference types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

Value Types and Reference TypesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/t63sy5hs.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 202 (536P_1.1.6_02)

_________________________________________________________________________________________________________________

Which of the following samples demonstrates unboxing?

1. ' VBDim o As Object = 123 Dim i As Integer = CType(o, Integer)

// C#object o = 123;int i = (int) o;

<Correct>

2. ' VBDim d As Double = 123 Dim i As Integer = CType(d, Integer)

// C#double d = 123;int i = (int)d;

3. ' VBDim i As Integer = 123 Dim d As Double = i

// C#int i = 123;double d = i;

4. ' VBDim i As Integer = 123 Dim o As Object = CType(i, Object)

// C#int i = 123;object o = (object) i;

Explanation :Unboxing converts a reference type to a value type. In this example, the Integer object is a value type, and the instance of the Object class is a reference type. Converting from the reference type to the value type requires unboxing.

Converting from a value type to a reference type is boxing.

Converting between two value types requires neither boxing nor unboxing.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Boxing and UnBoxing

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 4

Boxing and Unboxing (C# Programming Guide)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/yz2be5wk.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 203 (536P_4.5.1_01)

_________________________________________________________________________________________________________________

Which of the following classes interact with the file system? (Choose all that apply.)

1. MemoryStream

2. FileStream <Correct>

3. StreamReader <Correct>

4. StringReader

5. SslStream

Explanation :You can directly interact with the file system by using FileStream or StreamReader.

MemoryStream and StringReader both interact with memory, not the file system. SslStream interacts with a remote host.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Manage byte streams by using Stream classes. (Refer System.IO namespace) FileStream class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 2

File and Stream I/OMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/k3352a4t(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 204 (536P_4.6.2_01)

_________________________________________________________________________________________________________________

You need to write text to a file. Which of the following demonstrates the most efficient way to use the TextWriter class?

1. ' VBDim tw As TextWriter = New TextWriter("Hello.dat")tw.Write("Hello, world!")tw.Close

// C#TextWriter tw = new TextWriter("Hello.dat");tw.Write("Hello, world!");tw.Close();

2. ' VBDim tw As TextWriter = New FileStream("Hello.dat", FileMode.Create)tw.Write("Hello, world!")tw.Close

// C#TextWriter tw = new StreamWriter("Hello.dat");tw.Write("Hello, world!");tw.Close();

3. ' VBDim tw As TextWriter = New StreamWriter("Hello.dat")tw.Write("Hello, world!")tw.Close

// C#TextWriter tw = new FileStream("Hello.dat", FileMode.Create);tw.Write("Hello, world!");tw.Close();

4. ' VBDim fs As FileStream = New FileStream("Hello.dat", FileMode.Create)Dim tw As TextWriter = New StreamWriter(fs)tw.Write("Hello, world!")tw.Closefs.Close

// C#FileStream fs = new FileStream("Hello.dat", FileMode.Create);TextWriter tw = new StreamWriter(fs);tw.Write("Hello, world!");tw.Close();fs.Close();

<Correct>

Explanation :The TextWriter class does not have a constructor. Instead, you should create it using the StreamWriter constructor. To create a StreamWriter object, you must use an existing Stream object, such as an instance of FileStream.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Manage the .NET Framework application data by using Reader and Writer classes. (Refer System.IO namespace) TextReader class and TextWriter class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, Microsoft

Chapter 2 - Lesson 2

TextWriter ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-US/library/system.io.textwriter.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 205 (536P_5.5.1_02)

_________________________________________________________________________________________________________________

Which of the following declarations would cause the runtime to throw an exception if the assembly lacked permission to print to the LPT1 port?

1. ' VB<Assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum, "LPT1")>

// C#[assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum, "LPT1")]

2. ' VB<Assembly:PrintingPermission(SecurityAction.RequestMinimum)>

// C#[assembly:PrintingPermission(SecurityAction.RequestMinimum)]

<Correct>

3. ' VB<Assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum)>

// C#[assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum)]

4. ' VB<Assembly:PrintingPermission(SecurityAction.RequestMinimum, "LPT1")>

// C#[assembly:PrintingPermission(SecurityAction.RequestMinimum, "LPT1")]

Explanation :Use the PrintingPermissionAttribute to declare printing permission requirements. In this case, you should specify SecurityAction.RequestMinimum to cause the runtime to throw an exception if the assembly does not have permission to print.

The .NET Framework provides PrintingPermissionAttribute. Use FileIOPermissionAttribute when you need to declare permissions for the file system. Additionally, you cannot specify a specific port in this way.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Control permissions for resources by using the System.Security.Permission classes. (Refer System.Security.Permission namespace) SecurityPermission class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 3

Assemblies should declare minimum securityMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms182325.aspx

PrintingPermissionAttribute ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/5eeax1dy(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 206 (536P_3.1.1_06)

_________________________________________________________________________________________________________________

You are writing a Windows Forms application called MyApp. You need to define application settings and database connection strings in a custom configuration file in the same folder as your MyApp.exe file. What should you name the configuration file?

1. .config

2. Web.config

3. MyApp.config

4. MyApp.exe.config <Correct>

Explanation :Application configuration files should be located in the same folder as the executable file and named <filename.exe>.config.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Embed configuration management functionality into a .NET Framework application. (Refer System.Configuration namespace) Configuration class and ConfigurationManager class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 1

Application Settings ArchitectureMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/8eyb2ct1.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 207 (536P_6.3.2_01)

_________________________________________________________________________________________________________________

Which of the following System.Reflection attributes would you use to specify whether an assembly was a retail or debug build?

1. AssemblyInformationalVersionAttribute

2. AssemblyDescriptionAttribute

3. AssemblyProductAttribute

4. AssemblyConfigurationAttribute <Correct>

Explanation :AssemblyConfigurationAttribute specifies the build configuration, such as retail or debug, for an assembly.

AssemblyDescriptionAttribute provides a text description for an assembly.

AssemblyInformationalVersionAttribute defines additional version information for an assembly manifest.

AssemblyProductAttribute defines a product name custom attribute for an assembly manifest.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Implement reflection functionality in a .NET Framework application (refer System.Reflection namespace), and create metadata, Microsoft intermediate language (MSIL), and a PE file by using the System.Reflection.Emit namespace. Assembly attributes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 14 - Lesson 2

System.Reflection NamespaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.reflection.aspx

AssemblyConfigurationAttribute ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.reflection.assemblyconfigurationattribute.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 208 (536P_4.7.3_01)

_________________________________________________________________________________________________________________

What is the maximum file size you can compress by using the DeflateStream class?

1. 4 GB <Correct>

2. 256 MB

3. 2 GB

4. 1 TB

5. 16 GB

6. 128 MB

Explanation :The maximum file size DeflateStream can compress is 4 GB.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Compress or decompress stream information in a .NET Framework application (refer System.IO.Compression namespace), and improve the security of application data by using isolated storage. (Refer System.IO.IsolatedStorage namespace) DeflateStream class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 3

DeflateStream ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.io.compression.deflatestream.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 209 (536P_6.1.5_01)

_________________________________________________________________________________________________________________

You intend to expose types in an assembly to COM applications. Which of the following guidelines must you adhere to? (Choose all that apply.)

1. Declare all methods, properties, and events as private.

2. Create abstract types.

3. Declare all types that should be exported as public. <Correct>

4. Declare all methods, properties, and events as public. <Correct>

5. Create a constructor with no arguments. <Correct>

6. Create a constructor that accepts a pointer argument.

Explanation :If you intend to expose types in an assembly to COM applications, consider the requirements of COM interop at design time. Managed types (class, interface, structure, and enumeration) seamlessly integrate with COM types when you adhere to the following guidelines:

* Classes should implement interfaces explicitly.* Managed types must be public.* Methods, properties, fields, and events must be public.* Types must have a public default constructor to be activated from COM.* Types cannot be abstract.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Expose COM components to the .NET Framework and the .NET Framework components to COM. (Refer System.Runtime.InteropServices namespace) Qualify the .NET Framework types for interoperation.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 13 - Lesson 1

Qualifying .NET Types for InteroperationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/7fcfby2t(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 210 (536P_4.4.5_01)

_________________________________________________________________________________________________________________

You are writing an application that will run on a computer that acts as a kiosk. Users should have very limited access to the computer. You want to allow users to save files to the local disk, but users should only be able to specify a relative path to their files; you do not want users to be able to specify an absolute path. Which of the following classes would you use to test the path users provide?

1. System.IO.Path <Correct>

2. System.IO.Directory

3. System.IO.DriveInfo

4. System.IO.DirectoryInfo

Explanation :You can test a path to determine whether it is absolute or relative by calling the Path.IsPathRooted method.

System.IO.Directory contains static methods for processing directories, but it does not enable you to test whether a path is absolute.

System.IO.DirectoryInfo provides directory management capabilities, but it does not enable you to test whether a path is absolute.

System.IO.DriveInfo enables you to examine the properties of a drive, and does not enable you to test whether a path is absolute.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Access files and folders by using the File System classes. (Refer System.IO namespace) Path class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 1

Path ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/3bdzys9w(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 211 (536P_6.3.3_02)

_________________________________________________________________________________________________________________

You have created a Type object. Which method would you call to retrieve a collection containing all methods, interfaces, properties, and constructors for the class?

1. Type.GetDefaultMembers

2. Type.GetMethods

3. Type.GetMembers <Correct>

4. Type.GetFields

Explanation :Type.GetMembers retrieves all members, including methods, interfaces, properties, and constructors.

Type.GetFields searches for fields defined by the current type.

Type.GetDefaultMembers searches for members defined by the current type whose System.Reflection.DefaultMemberAttribute is set.

Type.GetMethods returns a collection containing only methods, and not interfaces or properties.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Implement reflection functionality in a .NET Framework application (refer System.Reflection namespace), and create metadata, Microsoft intermediate language (MSIL), and a PE file by using the System.Reflection.Emit namespace. Info classes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 14 - Lesson 3

Viewing Type InformationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/t0cs7xez(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 212 (536P_1.1.5_02)

_________________________________________________________________________________________________________________

You are creating a class that performs calculations based on calendar dates. Which of the following exception classes would you use if a calling assembly provided the value 13 for a month?

1. IndexOutOfRangeException

2. ArgumentOutOfRangeException <Correct>

3. ArgumentNullException

4. ArgumentException

Explanation :You should throw an ArgumentOutOfRangeException when a caller provides a value for a parameter but that value is invalid.

ArgumentException is a base class for all argument exceptions. You should use more specific exceptions whenever appropriate, specifically ArgumentOutOfRangeException and ArgumentNullException.

Use ArgumentNullException when a calling assembly provides a null value for a parameter that must have a value.

Only the runtime should throw an IndexOutOfRangeException. The runtime throws an IndexOutOfRangeException when an array is indexed improperly.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Exception classes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

Exception HierarchyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/z4c5tckx.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 213 (536P_5.1.4_01)

_________________________________________________________________________________________________________________

Which of the following permission sets provides the fewest privileges while still allowing an assembly to run?

1. Nothing

2. FullTrust

3. LocalIntranet

4. Execution <Correct>

5. Internet

Explanation :The Execution permission set enables an assembly to run while granting no additional permissions.

The Internet permission set grants a restricted set of permissions to an assembly. Generally, you can run an assembly with this permission set with very little risk. Even malicious assemblies should not be able to cause any serious damage when run with this permission set. However, the Internet permission set does grant privileges beyond those provided by the Execution permission set.

The LocalIntranet permission set grants a generous set of permissions to assemblies, including the ability to print and access the event log.

The Nothing permission set grants no permissions to an assembly. The assembly will not even be allowed to run.

The FullTrust permission set exempts an assembly from CAS permission checks.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement code access security to improve the security of a .NET Framework application. (Refer System.Security namespace) PermissionSet class and NamedPermissionSet class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 1

Named Permission SetsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/4652tyx7.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 214 (536P_1.1.5_03)

_________________________________________________________________________________________________________________

You are creating a class that processes a text file and returns a result to the calling assembly. Which of the following exception classes would you use if a calling assembly called the method to read the file before specifying the file name?

1. ArgumentException

2. ArgumentNullException

3. InvalidOperationException <Correct>

4. ArgumentOutOfRangeException

Explanation :Throw an InvalidOperationException if a property set or method call is not appropriate given the object's current state.

You should throw an ArgumentOutOfRangeException when a caller provides a value for a parameter but that value is invalid.

ArgumentException is a base class for all argument exceptions. You should use more specific exceptions whenever appropriate, specifically ArgumentOutOfRangeException and ArgumentNullException.

Use ArgumentNullException when a calling assembly provides a null value for a parameter that must have a value.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Exception classes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

Exception HierarchyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/z4c5tckx.aspx

Best Practices for Handling ExceptionsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/seyhszts.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 215 (536P_1.6.3_05)

_________________________________________________________________________________________________________________

You are using Microsoft Visual Studio 2005 to create a Microsoft Windows Forms application. You want to run code when the user clicks a button. What is the easiest way to use the designer to run code when a button is clicked?

1. In the designer, click the button.

2. In the designer, right-click the button and then click Add Event. Follow the prompts that appear to select the event.

3. In the designer, right-click the button and then click View Code.

4. In the designer, double-click the button. <Correct>

Explanation :The simplest way to write code that responds to the Button.Click event is to double-click the button in the designer. Visual Studio will automatically generate the code required to respond to the event.

The other procedures do not automatically generate the event-handling code.

Objective:Developing applications that use system types and collections

Sub Objective(s):Control interactions between .NET Framework application components by using events and delegates. (Refer System namespace) EventHandler delegates

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

How to: Create a Windows Forms ApplicationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms235634.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 216 (536P_4.1.2_02)

_________________________________________________________________________________________________________________

You are adding a new member to class that is already in use. You want to provide backward compatibility with serialized data that was created before the member was added. Which attribute would you add to the new member so that it would be serialized in the future, but deserialization would not throw an exception if the member class was not present in the serialized data?

1. OptionalField <Correct>

2. IDeserializationCallback

3. ISerializable

4. NonSerialized

Explanation :The OptionalField attribute prevents deserialization from throwing an exception if the member is not present, while still serializing the member.

ISerializable and IDeserializationCallback are interfaces that you can implement when you need to control the serialization process.

The NonSerialized attribute would prevent the runtime from throwing an exception if the member was not present; however, it also prevents the member from being serialized.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) Serilization attributes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 1

Selective SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/axwwbcs6.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 217 (536P_4.4.4_01)

_________________________________________________________________________________________________________________

You are writing an application that needs to process files when they are added to a folder. Which of the following events should you respond to?

1. FileSystemWatcher.Deleted

2. FileSystemWatcher.Created <Correct>

3. FileSystemWatcher.Renamed

4. FileSystemWatcher.Changed

Explanation :FileSystemWatcher.Created occurs when a file or directory in the specified path is created.

FileSystemWatcher.Changed only occurs when an existing file is modified.

FileSystemWatcher.Deleted occurs when a file is removed.

FileSystemWatcher.Renamed occurs when a file is renamed.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Access files and folders by using the File System classes. (Refer System.IO namespace) FileSystemInfo class and FileSystemWatcher class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 1

FileSystemWatcher EventsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/5h9akw31(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 218 (536P_2.2.1_06)

_________________________________________________________________________________________________________________

You are writing an application that needs to perform processing that will run for several hours. However, you need the application to remain responsive to the user during that time, so you are using multiple threads. Which of the following code samples would launch the thread in such a way as to minimize the impact on the performance of other applications? (Choose all that apply.)

1. ' VBDim myThreadDelegate As New ThreadStart(AddressOf ThreadWork.DoWork)Dim myThread As New Thread(myThreadDelegate)myThread.Priority = ThreadPriority.LowestmyThread.Start()

// C#ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork);Thread myThread = new Thread(myThreadDelegate);myThread.Priority = ThreadPriority.Lowest;myThread.Start();

<Correct>

2. ' VBDim myThreadDelegate As New ThreadStart(AddressOf ThreadWork.DoWork, ThreadPriority.Lowest)Dim myThread As New Thread(myThreadDelegate)myThread.Start()

// C#ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork, ThreadPriority.Lowest);Thread myThread = new Thread(myThreadDelegate);myThread.Start();

3. ' VBDim myThreadDelegate As New ThreadStart(AddressOf ThreadWork.DoWork)Dim myThread As New Thread(myThreadDelegate)myThread.StartLowPriority()

// C#ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork);Thread myThread = new Thread(myThreadDelegate);myThread.StartLowPriority();

<Correct>

4. ' VBDim myThreadDelegate As New ThreadStart(AddressOf ThreadWork.DoWork)Dim myThread As New Thread(myThreadDelegate, ThreadPriority.Lowest)myThread.Start()

// C#ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork);Thread myThread = new Thread(myThreadDelegate, ThreadPriority.Lowest);myThread.Start();

Explanation :Set the Thread.Priority property to control a thread's processing priority.

The Thread.StartLowPriority method does not exist.

You cannot pass a priority level to the Thread constructor.

You cannot pass a priority level to the ThreadStart constructor.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Develop multithreaded .NET Framework applications. (Refer System.Threading namespace) Thread class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 7 - Lesson 1

Scheduling ThreadsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/2k34xtf3.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 219 (536P_6.1.1_02)

_________________________________________________________________________________________________________________

You need to create an interop assembly and namespace for a COM type library. Which tool would you use?

1. Regsvcs.exe

2. Mdbg.exe

3. Tlbimp.exe <Correct>

4. Tlbexp.exe

Explanation :Tlbimp.exe is the Type Library Importer command-line tool. This tool automatically generates an interop assembly based on a COM type library. You can then add an interop assembly to a .NET Framework project just like a native .NET Framework library.

The Type Library Exporter (Tlbexp.exe) generates a type library from a common language runtime assembly.

The Managed Code Debugger (Mdbg.exe) provides command-line debugging services to help application developers find and fix bugs in programs written using the .NET Framework. Use this tool to find and fix bugs in programs that target the runtime.

The .NET Services Installation Tool (Regsvcs.exe) adds managed classes to Microsoft Windows 2000 Component Services by loading and registering the assembly and generating, registering, and installing the type library into an existing COM+ 1.0 application.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Expose COM components to the .NET Framework and the .NET Framework components to COM. (Refer System.Runtime.InteropServices namespace) Import a type library as an assembly.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 13 - Lesson 1

How to: Generate Interop Assemblies from Type LibrariesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/697w37zd(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 220 (536P_3.2.8_02)

_________________________________________________________________________________________________________________

You have created a .NET Framework 2.0 application that uses several classes from a third-party assembly. Recently, the assembly vendor released a new version. However, your application still binds to the older version of the assembly. The assembly is currently in the global application cache. You open the .NET Framework 2.0 Configuration tool. Where do you click to configure a binding redirection to force your application to use the updated version of the assembly?

In the illustration, click on the node you should use to configure binding policy.

Explanation :Binding policy allows you to specify a new version of the assembly when an application requests a different version. To configure binding policy, the assembly must first be in the global assembly cache (GAC). Then, you can configure it from the Configured Assemblies node.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Create a custom Microsoft Windows Installer for the .NET Framework components by using the System.Configuration.Install namespace, and configure the .NET Framework applications by using configuration files, environment variables, and the .NET Framework Configuration tool (Mscorcfg.msc).). Configure a .NET Framework application by using the .NET Framework Configuration tool (Mscorcfg.msc).

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 2

.NET Framework Configuration Tool (Mscorcfg.msc)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/2bc0cxhc.aspx

Redirecting Assembly VersionsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/7wd6ex19.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 221 (536P_3.3.3_03)

_________________________________________________________________________________________________________________

You are writing a .NET Framework version 2.0 application that adds events to an event log. You need to specify the Event ID, as displayed in the Event Properties dialog in the following figure. Which property should you set to define the Event ID?

1. EventLogEntry.InstanceId <Correct>

2. EventLogEntry.Index

3. EventLogEntry.Source

4. EventLogEntry.EventID

Explanation :EventLogEntry.InstanceId, in the .NET Framework version 2.0, defines the Event ID number shown in the Event Log console.

EventLogEntry.EventID was used to define the Event ID in the .NET Framework versions 1.0 and 1.1; however, it is now obsolete.

EventLogEntry.Index gets the index of an event in the Event Log.

EventLogEntry.Source gets the name of the application that generated the event.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Manage an event log by using the System.Diagnostics namespace. Create a new event log.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 1

EventLogEntry ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.eventlogentry(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 222 (536P_6.1.2_01)

_________________________________________________________________________________________________________________

You are creating an assembly that references a COM object. To ensure the COM object is available and properly referenced, you want to perform early-bound activation. Which of the following code samples correctly activates an instance of the MyLib.MyClass coclass?

1. ' VBImports SystemImports MyLibPreload MyLib

Public Class MyApp Public Shared Sub Main() ' TODO: Complete application End SubEnd Class

// C#using System;using MyLib;preload MyLib;

public class MyApp { public static void Main(String[] Args) { // TODO: Complete application }}

2. ' VBImports SystemImports MyLib

Public Class MyApp Load MyClass Public Shared Sub Main() ' TODO: Complete application End SubEnd Class

// C#using System;using MyLib;

public class MyApp { load MyClass; public static void Main(String[] Args) { // TODO: Complete application }}

3. ' VBImports SystemImports MyLib

Public Class MyApp Public Shared Sub Main() Dim mc As New MyClass() ' TODO: Complete application End SubEnd Class

// C#using System;using MyLib;

public class MyApp { public static void Main(String[] Args) { MyClass mc = new MyClass(); // TODO: Complete application }

} <Correct>

4. ' VBImports SystemImports MyLib

Public Class MyApp Public Shared Sub Main() Activate MyClass ' TODO: Complete application End SubEnd Class

// C#using System;using MyLib;

public class MyApp { public static void Main(String[] Args) { activate MyClass // TODO: Complete application }}

Explanation :To perform early-bound activation, simply create an instance of the class. When a .NET client creates an instance of a coclass, the runtime must locate its metadata, regardless of whether the class is a .NET class or a COM coclass. Metadata must be available at run time in order to early bind to a class. Metadata is not required for late-bound activation.

There are no Load, Preload, or Activate keywords.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Expose COM components to the .NET Framework and the .NET Framework components to COM. (Refer System.Runtime.InteropServices namespace) Create COM types in managed code.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 13 - Lesson 1

Activating a COM ObjectMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/7c01w25h(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 223 (536P_3.6.2_01)

_________________________________________________________________________________________________________________

You need to perform a management query for resources located on the local computer. Which classes do you need to create instances of? (Choose all that apply.)

1. DeleteOptions

2. ConnectionOptions

3. ManagementObjectCollection <Correct>

4. ObjectQuery<Correct>

5. ManagementScope

6. ManagementObjectSearcher <Correct>

Explanation :To query local resources, you need instances of ObjectQuery, ManagementObjectSearcher, and ManagementObjectCollection.

You do not need instances of ConnectionOptions and ManagementScope when querying local resources. Those objects are used when querying remote resources.

DeleteOptions specifies options for deleting a management object and is not required when querying local resources.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Embed management information and events into a NET Framework application. (Refer System.Management namespace) ManagementQuery class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 4

ManagementObjectSearcher ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.management.managementobjectsearcher.aspx

ObjectQuery ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.management.objectquery(VS.80).aspx

ManagementObjectCollection ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.management.managementobjectcollection.aspx

WMI .NET OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms257340(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 224 (536P_2.2.9_02)

_________________________________________________________________________________________________________________

You are creating a multithreaded application by creating asynchronous requests for Domain Name System (DNS) information. After you issue the initial DNS request using Dns.BeginGetHostEntry, your application performs some processing while waiting for the DNS request to complete. If the DNS request has not been completed when your application is done processing, how can you wait for the request to complete? (Choose all that apply.)

1. Call Dns.EndGetHostEntry. <Correct>

2. Call IAsyncResult.AsyncWaitHandle.Wait.

3. Call IAsyncResult.AsyncState.WaitOne.

4. Call Dns.WaitGetHostEntry.

5. Call IAsyncResult.AsyncWaitHandle.WaitOne. <Correct>

Explanation :You can wait for a response by calling either IAsyncResult.AsyncWaitHandle.WaitOne or Dns.EndGetHostEntry. Alternatively, you could check to see if the request is ready by checking the IAsyncResult.IsCompleted property.

There is no IAsyncResult.AsyncWaitHandle.Wait, Dns.WaitGetHostEntry, or IAsyncResult.AsyncState.WaitOne method.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Develop multithreaded .NET Framework applications. (Refer System.Threading namespace) IAsyncResult interface (Refer System namespace)

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 7 - Lesson 3

Asynchronous Programming OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms228963(VS.80).aspx

Dns MethodsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.net.dns_methods(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 225 (536P_5.4.7_02)

_________________________________________________________________________________________________________________

In which of the following asymmetric encryption scenarios would you need to store a key pair? (Choose all that apply.)

1. Signing documents to prove authenticity <Correct>

2. Transferring encrypted data across a network

3. Storing an encrypted file for later retrieval <Correct>

4. Storing encrypted data in a database <Correct>

Explanation :You must store a key pair any time a file is going to be decrypted at a later data. Without the key pair, decryption cannot occur. When signing documents, you must store the key pair so that the key pair can be used to validate the signature later.

You do not need to store a key pair when transferring encrypted data across a network. In this circumstance, you can destroy the keys after the network communication has completed.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace) RSA class and RSACryptoServiceProvider class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 3

How to: Store Asymmetric Keys in a Key ContainerMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/tswxhw92.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 226 (536P_1.1.4_03)

_________________________________________________________________________________________________________________

Given the following class declaration, which of the following constructors is correct?

' VBClass CompGen(Of T As IComparable) Public t1 As T Public t2 As T

Public Sub New(ByVal _t1 As T, ByVal _t2 As T) t1 = _t1 t2 = _t2 End SubEnd Class

// C#class CompGen<T> where T : IComparable { public T t1; public T t2;

public CompGen(T _t1, T _t2) { t1 = _t1; t2 = _t2; }}

1. ' VBDim gb As New CompGen(Of Double, Integer)(10.125, 2005)

// C#CompGen<double, int> gb = new CompGen<double, int>(10.125, 2005);

2. ' VBDim gb As New CompGen(Of Double)(10.125, 2005)

// C#CompGen<double> gb = new CompGen<double>(10.125, 2005);

<Correct>

3. ' VBDim gb As New CompGen(10.125, 2005)

// C#CompGen gb = new CompGen(10.125, 2005);

4. ' VBDim gb As New CompGen(Of StringBuilder)("Hello", "World")

// C#CompGen<StringBuilder> gb = new CompGen<StringBuilder>("Hello", "World");

Explanation :The sample class is a generic. To create a generic, you must provide a type for each generic type, and that type must meet all constraints.

The StringBuilder class does not implement the IComparable interface, which is a constraint of the sample class.

The sample class only specifies a single generic type. This constructor provides two generic types.

To create an instance of a generic class, you must provide a type. This constructor does not provide a type.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Generic types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

Overview of Reflection and GenericsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms172334.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 227 (536P_3.5.1_03)

_________________________________________________________________________________________________________________

To improve the reliability of your code, you want to verify an important value and stop execution if the value is not set properly. However, you only want to stop execution during debugging. You do not want users with release versions of your application experiencing problems. Which method should you use?

1. Debug.Flush

2. Debug.Fail <Correct>

3. Debug.Assert

4. Debug.Indent

Explanation :Debug.Fail causes the debugger to break at the line of code and output a failure message.

Debug.Assert evaluates a condition and displays a message, but it does not interrupt processing.

Debug.Flush flushes the debug output buffer.

Debug.Indent controls the output formatting.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Debug and trace a .NET Framework application by using the System.Diagnostics namespace. Debug class and Debugger class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 2

Debug ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.debug(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 228 (536P_3.6.3_01)

_________________________________________________________________________________________________________________

You are creating an assembly that needs to stop processing until a process is launched. You want to wait for the process by subscribing to a management event.

From the list on the right, select the tasks that you should perform to subscribe to management events. Place your selections in the list on the left in the order in which the tasks should be performed. Place your selections in the list on the left by clicking the items in the list on the right and clicking the arrow. You can also use the Up and Down buttons to rearrange items in the list on the left. You might not need to use all the items from the list on the right.

Explanation :To wait for a management event:

1. Create a new ManagementEventWatcher object.2. Associate an EventQuery object with the ManagementEventWatcher object.3. Call the ManagementEventWatcher.WaitForNextEvent method.4. Call the ManagementEventWatcher.Stop method.

You do not need to call the ManagementEventWatcher.Start method when calling ManagementEventWatcher.WaitForNextEvent. You only need to call ManagementEventWatcher.Start when registering an event handler.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Embed management information and events into a NET Framework application. (Refer System.Management namespace) Subscribe to management events by using the ManagementEventWatcher class.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 4

ManagementEventWatcher ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.management.managementeventwatcher.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 229 (536P_7.1.3_02)

_________________________________________________________________________________________________________________

You need to display a currency value using culture-specific formatting. Which of the following code samples DOES NOT correctly display the currency value correctly for the Danish language in Denmark?

1. ' VBDim d As Double = 4328.69Dim ci As CultureInfo = CultureInfo.GetCultureInfo("da-DK")Console.WriteLine(String.Format(ci, "{0:c}", d))

// C#double d = 4328.69;CultureInfo ci = CultureInfo.GetCultureInfo("da-DK");Console.WriteLine(String.Format(ci, "{0:c}", d));

2. ' VBDim d As Double = 4328.69Dim ci As CultureInfo = New CultureInfo("da-DK")Console.WriteLine(d.ToString("c", ci))

// C#double d = 4328.69;CultureInfo ci = new CultureInfo("da-DK");Console.WriteLine(d.ToString("c", ci));

3. ' VBDim d As Double = 4328.69Dim ci As CultureInfo = New CultureInfo("da-DK")Console.WriteLine(d.ToString(ci, "{0:c}", d))

// C#double d = 4328.69;CultureInfo ci = new CultureInfo("da-DK");Console.WriteLine(d.ToString(ci, "{0:c}", d));

<Correct>

4. ' VBDim d As Double = 4328.69Dim ci As CultureInfo = CultureInfo.GetCultureInfo("da-DK")Console.WriteLine(d.ToString("c", ci))

// C#double d = 4328.69;CultureInfo ci = CultureInfo.GetCultureInfo("da-DK");Console.WriteLine(d.ToString("c", ci));

Explanation :To format a number as currency for a specific culture, you can use either the ToString method or the String.Format method. If you use ToString, pass "c" as the format parameter, and pass a CultureInfo object. String.Format requires the CultureInfo object as the first parameter, a format string, and then the number to be formatted.

The Double.ToString method does not accept the "{0:C}" formatting style.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Format data based on culture information. (Refer System.Globalization namespace) Format number values based on the culture.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, Microsoft

Chapter 16 - Lesson 1

Formatting Numeric Data for a Specific CultureMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/syy068tk(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 230 (536P_3.4.4_01)

_________________________________________________________________________________________________________________

You are writing a multithreaded application that performs custom performance logging to enable users to use the Performance console to track the current number of users who have connected to your application. Which method should you call when a user disconnects?

1. PerformanceCounter.IncrementBy

2. PerformanceCounter.RawValue

3. PerformanceCounter.Increment

4. PerformanceCounter.Decrement <Correct>

Explanation :PerformanceCounter.Decrement works well in multithreaded environments. Because users are disconnecting, you would want to decrease the user counter.

You would call PerformanceCounter.Increment when a user connects, not disconnects.

You would call PerformanceCounter.IncrementBy when a user connects, not disconnects.

PerformanceCounter.RawValue would offer better performance than PerformanceCounter.Decrement. However, PerformanceCounter.RawValue may yield an inaccurate count in multithreaded applications.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Manage system processes and monitor the performance of a .NET Framework application by using the diagnostics functionality of the .NET Framework 2.0. (Refer System.Diagnostics namespace) PerformanceCounter class, PerformanceCounterCategory, and CounterCreationData class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 3

PerformanceCounter ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.performancecounter.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 231 (536P_2.3.2_01)

_________________________________________________________________________________________________________________

Which of the following is the proper way to close an application domain and free any resources consumed by assemblies running within the application domain?

1. ' VBDim d As AppDomain = AppDomain.CreateDomain("NewDomain")d = Nothing

// C#AppDomain d = AppDomain.CreateDomain("NewDomain");d = null;

2. ' VBDim d As AppDomain = AppDomain.CreateDomain("NewDomain")AppDomain.Unload(d)

// C#AppDomain d = AppDomain.CreateDomain("NewDomain");AppDomain.Unload(d);

<Correct>

3. ' VBDim d As AppDomain = AppDomain.CreateDomain("NewDomain")d.Close()

// C#AppDomain d = AppDomain.CreateDomain("NewDomain");d.Close();

4. ' VBDim d As AppDomain = AppDomain.CreateDomain("NewDomain")d.Unload()

// C#AppDomain d = AppDomain.CreateDomain("NewDomain");d.Unload();

Explanation :To close an application domain and free the resources the application domain is currently consuming, you should call the AppDomain.Unload static method and pass the AppDomain object.

You cannot call Unload on an instance of the AppDomain class. Instead, you must call the AppDomain.Unload static method.

Setting an AppDomain to null or Nothing does not free resources used by the application domain.

The AppDomain class does not have a Close method.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Create a unit of isolation for common language runtime in a .NET Framework application by using application domains. (Refer System namespace) Unload an application domain.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 8 - Lesson 1

AppDomain.Unload MethodMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.appdomain.unload.aspx

How to: Unload an Application DomainMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/library/c5b8a8f9(en-us,vs.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 232 (536P_5.2.2_02)

_________________________________________________________________________________________________________________

You are writing an internal application. Your IT department is responsible for defining permissions that different groups have to the configuration files your application uses. They have provided you the following requirements:

* Members of the Administrators group can modify the file and its permissions.* Members of the Power Users group can edit the file, but cannot change its permissions.* Members of the Users group can view the file, but cannot edit it.* Guests cannot read or edit the file.

Which of the following code samples efficiently creates a file with the proper permissions?

1. ' VBDim fs As FileSecurity = New FileSecurityfs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Administrators"), FileSystemRights.FullControl, AccessControlType.Allow))fs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Power Users"), FileSystemRights.Modify, AccessControlType.Allow))fs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Users"), FileSystemRights.Read, AccessControlType.Allow))fs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Guests"), FileSystemRights.FullControl, AccessControlType.Deny))System.IO.File.Create("config.xml", 1000, FileOptions.None, fs)

// C#FileSecurity fs = new FileSecurity();fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Administrators"), FileSystemRights.FullControl, AccessControlType.Allow));fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Power Users"), FileSystemRights.Modify, AccessControlType.Allow));fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Users"), FileSystemRights.Read, AccessControlType.Allow));fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Guests"), FileSystemRights.FullControl, AccessControlType.Deny));System.IO.File.Create("config.xml", 1000, FileOptions.None, fs);

<Correct>

2. ' VBDim fs As FileSecurity = New FileSecurityfs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Administrators"), FileSystemRights.FullControl, AccessControlType.Allow))fs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Power Users"), FileSystemRights.FullControl, AccessControlType.Allow))fs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Power Users"), FileSystemRights.ChangePermissions, AccessControlType.Deny))fs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Users"), FileSystemRights.Read, AccessControlType.Allow))fs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Guests"), FileSystemRights.FullControl, AccessControlType.Deny))System.IO.File.Create("config.xml", 1000, FileOptions.None, fs)

// C#FileSecurity fs = new FileSecurity();fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Administrators"), FileSystemRights.FullControl, AccessControlType.Allow));fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Power Users"), FileSystemRights.FullControl, AccessControlType.Allow));fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Power Users"), FileSystemRights.ChangePermissions, AccessControlType.Deny));fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Users"), FileSystemRights.Read, AccessControlType.Allow));fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Guests"), FileSystemRights.FullControl, AccessControlType.Deny));System.IO.File.Create("config.xml", 1000, FileOptions.None, fs);

3. ' VBDim fs As FileSecurity = New FileSecurityfs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Administrators"),

FileSystemRights.FullControl, AccessControlType.Allow))fs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Power Users"), FileSystemRights.Modify, AccessControlType.Allow))fs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Users"), FileSystemRights.Read, AccessControlType.Allow))fs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Guests"), FileSystemRights.Delete, AccessControlType.Allow))System.IO.File.Create("config.xml", 1000, FileOptions.None, fs)

// C#FileSecurity fs = new FileSecurity();fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Administrators"), FileSystemRights.FullControl, AccessControlType.Allow));fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Power Users"), FileSystemRights.Modify, AccessControlType.Allow));fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Users"), FileSystemRights.Read, AccessControlType.Allow));fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Guests"), FileSystemRights.Delete, AccessControlType.Allow));System.IO.File.Create("config.xml", 1000, FileOptions.None, fs);

4. ' VBDim fs As FileSecurity = New FileSecurityfs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Administrators"), FileSystemRights.FullControl, AccessControlType.Allow))fs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Power Users"), FileSystemRights.FullControl, AccessControlType.Allow))fs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Power Users"), FileSystemRights.ChangePermissions, AccessControlType.Deny))fs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Users"), FileSystemRights.Read, AccessControlType.Allow))fs.AddAccessRule(New FileSystemAccessRule(New NTAccount("Guests"), FileSystemRights.Delete, AccessControlType.Allow))System.IO.File.Create("config.xml", 1000, FileOptions.None, fs)

// C#FileSecurity fs = new FileSecurity();fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Administrators"), FileSystemRights.FullControl, AccessControlType.Allow));fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Power Users"), FileSystemRights.FullControl, AccessControlType.Allow));fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Power Users"), FileSystemRights.ChangePermissions, AccessControlType.Deny));fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Users"), FileSystemRights.Read, AccessControlType.Allow));fs.AddAccessRule(new FileSystemAccessRule(new NTAccount("Guests"), FileSystemRights.Delete, AccessControlType.Allow));System.IO.File.Create("config.xml", 1000, FileOptions.None, fs);

Explanation :To create a file with the specified permissions, you need to add four access rules to a FileSecurity object: Administrators with FullControl, Power Users with Modify, Users with Read, and Guests with FullControl/Deny.

This code sample grants the Guests group the right to Delete the file. Although they will not be able to view or edit the file, Guests will still be able to remove the file. Additionally, while you can add both an Allow and Deny permission for Power Users, this is not the most efficient way to prevent Power Users from modifying privileges. Instead, you can simply specify the Modify permission.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement access control by using the System.Security.AccessControl classes. AccessRule class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 2

ACL Technology ScenariosMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms229925(VS.80).aspx

FileSystemAccessRule ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.accesscontrol.filesystemaccessrule.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 233 (536P_6.3.3_01)

_________________________________________________________________________________________________________________

You need to examine the methods available for a type. Which of the following code samples most efficiently displays the methods available for the System.IO.File type?

1. ' VBDim memberInfoArray As MemberInfo() = myType.GetMembers("System.IO.File")

For Each mi As MemberInfo In memberInfoArray If mi.MemberType = MemberTypes.Method Then Console.WriteLine(mi.Name) End IfNext

// C#MemberInfo[] memberInfoArray = myType.GetMembers("System.IO.File");foreach (MemberInfo mi in memberInfoArray) if (mi.MemberType == MemberTypes.Method) Console.WriteLine(mi.Name);

2. ' VBDim myType As Type = Type.GetTypeFromCLSID("System.IO.File")Dim memberInfoArray As MemberInfo() = myType.GetMembers()

For Each mi As MemberInfo In memberInfoArray If mi.MemberType = MemberTypes.Method Then Console.WriteLine(mi.Name) End IfNext

// C#Type myType = Type.GetTypeFromCLSID("System.IO.File");MemberInfo[] memberInfoArray = myType.GetMembers();foreach (MemberInfo mi in memberInfoArray) if (mi.MemberType == MemberTypes.Method) Console.WriteLine(mi.Name);

3. ' VBDim myType As Type = Type.GetType("System.IO.File")Dim memberInfoArray As MemberInfo() = myType.GetMembers()

For Each mi As MemberInfo In memberInfoArray If mi.MemberType = MemberTypes.Method Then Console.WriteLine(mi.Name) End IfNext

// C#Type myType = Type.GetType("System.IO.File");MemberInfo[] memberInfoArray = myType.GetMembers();foreach (MemberInfo mi in memberInfoArray) if (mi.MemberType == MemberTypes.Method) Console.WriteLine(mi.Name);

4. ' VBDim myType As Type = Type.GetType("System.IO.File")Dim methodInfoArray As MethodInfo() = myType.GetMethods()

For Each mi As MethodInfo In methodInfoArray Console.WriteLine(mi.Name)Next

// C#Type myType = Type.GetType("System.IO.File");MethodInfo[] methodInfoArray = myType.GetMethods();foreach (MethodInfo mi in methodInfoArray) Console.WriteLine(mi.Name);

<Correct>

Explanation :The most efficient way to examine the methods for a class is to create a Type object using the Type.GetType method. Then iterate through the members of the collection returned by the Type.GetMethods method.

You can iterate through the members of the collection returned by the Type.GetMembers method, but it is not as efficient as using Type.GetMethods.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Implement reflection functionality in a .NET Framework application (refer System.Reflection namespace), and create metadata, Microsoft intermediate language (MSIL), and a PE file by using the System.Reflection.Emit namespace. Info classes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 14 - Lesson 3

Viewing Type InformationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/t0cs7xez(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 234 (536P_6.4.3_01)

_________________________________________________________________________________________________________________

You are writing an application that needs to transmit e-mail messages through a standard SMTP server, as well as perform other actions. To ensure administrators configure the application with the appropriate permissions, you want to declare the required permission. You do not want to affect the permissions granted to the assembly, however. Which of the following declarations accomplishes this most effectively?

1. ' VB<Assembly:SmtpPermission(SecurityAction.RequestOptional, Access:="Connect")>

// C#[assembly:SmtpPermission(SecurityAction.RequestOptional, Access="Connect")]

2. ' VB<Assembly:SmtpPermission(SecurityAction.RequestOptional, Access:="ConnectToUnrestrictedPort")>

// C#[assembly:SmtpPermission(SecurityAction.RequestOptional, Access="ConnectToUnrestrictedPort")]

3. ' VB<Assembly:SmtpPermission(SecurityAction.RequestMinimum, Access:="ConnectToUnrestrictedPort")>

// C#[assembly:SmtpPermission(SecurityAction.RequestMinimum, Access="ConnectToUnrestrictedPort")]

4. ' VB<Assembly:SmtpPermission(SecurityAction.RequestMinimum, Access:="Connect")>

// C#[assembly:SmtpPermission(SecurityAction.RequestMinimum, Access="Connect")]

<Correct>

Explanation :Use SecurityAction.RequestMinimum to demand specific permissions and to declare them for administrators. SmtpAccess.Connect is the most precise access declaration available.

Using SmtpAccess.ConnectToUnrestrictedPort enables the assembly to connect to nonstandard SMTP servers, which is unnecessary in this example. Additionally, SecurityAction.RequestOptional would cause the runtime to revoke all permissions except those specifically listed. The question stated that you did not want to affect the assembly's permissions.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery from a .NET Framework application. (Refer System.Net.Mail namespace) SmtpClient class, SmtpPermission class, and SmtpPermissionAttribute class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 15 - Lesson 2

SmtpPermission ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.net.mail.smtppermission(VS.80).aspx

SmtpAccess EnumerationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.net.mail.smtpaccess(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 235 (536P_1.4.5_01)

_________________________________________________________________________________________________________________

You are writing an application that analyzes IP subnets and makes recommendations about how to most efficiently use an address space. IP addresses are 32-bit values, and you need to be able to analyze individual bits and perform Boolean arithmetic. Which of the following classes would be most efficient?

1. BitArray

2. ArrayList

3. Boolean

4. BitVector32 <Correct>

Explanation :The purpose of the BitVector32 structure is to aid in manipulating bits in a 32-bit integer, and it is perfect for IP addresses.

The BitArray class is a resizable collection that can store Boolean values. In addition to being resizable, it supports common bit-level operations such as and, not, or, and exclusive-or (XOR). However, you have more flexibility when working with a BitVector32 structure than a 32-bit BitArray instance.

Boolean is a single bit value. You would need to separately access 32 Boolean variables, which would not be efficient.

ArrayList does not support Boolean math.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using specialized collections. (Refer System.Collections.Specialized namespace) BitVector32 structure and BitVector32.Section structure

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 4 - Lesson 4

BitVector32 StructureMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.collections.specialized.bitvector32.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 236 (536P_2.2.2_02)

_________________________________________________________________________________________________________________

On a single processor computer, what does the following code display?

' VBDim workerThreads, completionPortThreads As IntegerThreadPool.GetMaxThreads(workerThreads, completionPortThreads)Console.WriteLine(workerThreads.ToString + ", " + completionPortThreads.ToString)

// C#int workerThreads, completionPortThreads;ThreadPool.GetMaxThreads(out workerThreads, out completionPortThreads);Console.WriteLine(workerThreads + ", " + completionPortThreads);

1. 25, 1000 <Correct>

2. 250, 10

3. 10, 25

4. 100, 2500

Explanation :The code sample displays 25, 1000 because the default number of worker threads on a single processor computer is 25, and the default number of completion threads is 1,000.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Develop multithreaded .NET Framework applications. (Refer System.Threading namespace) ThreadPool class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 7 - Lesson 3

The Managed Thread PoolMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/0ka9477y.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 237 (536P_1.5.3_01)

_________________________________________________________________________________________________________________

Given the following code sample, which interface does the custom class MyClass implement?

' VBDim a As MyClass, b As Booleana = 42' Convert using ToBoolean.b = Convert.ToBoolean(a)Console.WriteLine("a = {0}, b = {1}", a.ToString, b.ToString)

// C#MyClass a; bool b;a = 42;// Convert using ToBoolean.b = Convert.ToBoolean(a);Console.WriteLine("a = {0}, b = {1}", a.ToString(), b.ToString());

1. IComparable

2. IConvertible <Correct>

3. IFormattable

4. ICloneable

5. IEquatable

6. INullableValue

7. IDisposable

Explanation :Use the IConvertible interface to enable a custom class to be converted to other types.

Implementing the other interfaces does not allow a class to be converted.

Objective:Developing applications that use system types and collections

Sub Objective(s):Implement .NET Framework interfaces to cause components to comply with standard contracts. (Refer System namespace) IConvertible interface

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 4

IConvertible InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.iconvertible.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 238 (536P_2.1.2_03)

_________________________________________________________________________________________________________________

You have created a Microsoft Windows Service. After calling the OnStart method to start your service, how long does the Windows Service Manager wait before abandoning the attempt to start the service?

1. 1 minute

2. 30 seconds <Correct>

3. 10 seconds

4. 5 seconds

Explanation :When you debug a Windows service application, your service and the Windows Service Manager interact. The Service Manager starts your service by calling the OnStart method, and then waits 30 seconds for the OnStart method to return. If the method does not return in this time, the manager shows an error indicating that the service cannot be started.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Implement, install, and control a service. (Refer System.ServiceProcess namespace) ServiceController class and ServiceControllerPermission class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 8 - Lesson 3

Troubleshooting: Debugging Windows ServicesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/kbe0xeh6(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 239 (536P_5.4.5_03)

_________________________________________________________________________________________________________________

You are developing an internal Windows Forms-based inventory management application. One form you have created has a control named managerControl that should be visible only if users are a member of the CONTOSO\Managers group. Which of the following code segments is the most effective way to implement this?

1. ' VBDim user As WindowsPrincipal = New WindowsPrincipal(WindowsIdentity.GetCurrent)If user.IsInRole("CONTOSO\Managers") Then managerControl.Visible = TrueElse managerControl.Visible = FalseEnd If

// C#WindowsPrincipal user = new WindowsPrincipal(WindowsIdentity.GetCurrent());if (user.IsInRole(@"CONTOSO\Managers")) managerControl.Visible = true;else managerControl.Visible = false;

<Correct>

2. ' VBSystem.AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal)Dim myPerm As PrincipalPermission = New PrincipalPermission(Nothing, "CONTOSO\Managers", True)myPerm.Demand()managerControl.Visible = False

// C#System.AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);PrincipalPermission myPerm = new PrincipalPermission(null, @"CONTOSO\Managers", true);myPerm.Demand();managerControl.Visible = False;

3. ' VBDim user As WindowsPrincipal = New WindowsPrincipal(WindowsIdentity.GetCurrent)If user.IsInRole("CONTOSO\Managers") Then managerControl.Visible = FalseElse managerControl.Visible = TrueEnd If

// C#WindowsPrincipal user = new WindowsPrincipal(WindowsIdentity.GetCurrent());if (user.IsInRole(@"CONTOSO\Managers")) managerControl.Visible = false;else managerControl.Visible = true;

4. ' VBSystem.AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal)Dim myPerm As PrincipalPermission = New PrincipalPermission(Nothing, "CONTOSO\Managers", True)myPerm.Demand()managerControl.Visible = True

// C#System.AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);PrincipalPermission myPerm = new PrincipalPermission(null, @"CONTOSO\Managers", true);myPerm.Demand();managerControl.Visible = True;

Explanation :The best way to make decisions based on group memberships is to create a WindowsPrincipal object and call WindowsPrincipal.IsInRole. In this example, you should make the managerControl visible if the user is part of the CONTOSO\Managers group.

You should use PrincipalPermission.Demand only when you want to halt processing if the user does not meet security requirements, because the method call throws an exception. Although you could catch the exception, using an If statement is better programming style.

Although this code sample correctly calls WindowsPrincipal.IsInRole, it makes the control visible if the user is NOT a member of the CONTOSO\Managers group.

You should use PrincipalPermission.Demand only when you want to halt processing if the user does not meet security requirements, because the method call throws an exception. Although you could catch the exception, using an If statement is better programming style. Additionally, it makes the control visible if the user is NOT a member of the CONTOSO\Managers group.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace) TripleDES and TripleDESCryptoServiceProvider class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 3

WindowsIdentity ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.principal.windowsidentity.aspx

WindowsPrincipal ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.principal.windowsprincipal.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 240 (536P_5.6.4_01)

_________________________________________________________________________________________________________________

What are the default permission sets for the machine code groups?

From the list on the right, select the permission set and associate it with the appropriate machine code group. Place your selections in the list on the left under the appropriate node by clicking the node, clicking the item from the list on the right, and then clicking the arrow button. You can use items from the list on the right more than once, and you do not have to use each item from the list.

Explanation :By default, My_Computer_Zone receives the FullTrust permission set, LocalIntranet_Zone receives the LocalIntranet permission set, Internet_Zone receives the Internet permission set, Restricted_Zone receives the Nothing permission set, and Trusted_Zone also receives the Internet permission set.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Control code privileges by using System.Security.Policy classes. (Refer System.Security.Policy namespace) CodeGroup class, FileCodeGroup class, FirstMatchCodeGroup class, NetCodeGroup class, and UnionCodeGroup class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 1

Named Permission SetsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/4652tyx7.aspx

How to: Change Permission Sets Associated with an Existing Code GroupMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/96fz91b0.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 241 (536P_5.5.14_01)

_________________________________________________________________________________________________________________

Which of the following permissions are available with the Internet permission set? (Choose all that apply.)

1. Send requests to Web sites

2. Store a file in isolated storage <Correct>

3. Analyze performance counters

4. Open the File dialog box <Correct>

5. Examine environment variables

Explanation :Assemblies running with the Internet permission set do have the right to open the File dialog box or store a file in isolated storage.

Assemblies running with the Internet permission set do not have the right to examine environment variables, analyze performance counters, or send requests to Web sites.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Control permissions for resources by using the System.Security.Permission classes. (Refer System.Security.Permission namespace) IsolatedStorageFilePermission class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 3

Security PermissionsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/5ba4k1c5.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 242 (536P_5.5.5_01)

_________________________________________________________________________________________________________________

Which of the following would you use to declaratively limit the permissions available to a method by declaring only the permissions the method should have?

1. CodeAccessPermission.Assert

2. SecurityAction.PermitOnly <Correct>

3. SecurityAction.Deny

4. CodeAccessPermission.PermitOnly

Explanation :SecurityAction.PermitOnly declarations limit the permissions available to a method by specifying only the permissions the method should have.

SecurityAction.Deny declarations refine the permissions available to a method by eliminating specific, named permissions. In other words, SecurityAction.Deny lists the permissions a method should not have, while SecurityAction.PermitOnly lists the permissions a method should only have.

Use CodeAccessPermission.PermitOnly to imperatively reduce permissions when a section of a method requires fewer permissions than the rest of the method. This is particularly important when calling objects created by third parties. CodeAccessPermission.PermitOnly is similar to SecurityAction.PermitOnly, except it is imperative rather than declarative.

Use CodeAccessPermission.Assert when you want to allow partially trusted code to call a method that requires permissions the caller might lack. It cannot be used declaratively.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Control permissions for resources by using the System.Security.Permission classes. (Refer System.Security.Permission namespace) UIPermission class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 2

Using the PermitOnly MethodMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/y6abcbh4.aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 3

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 243 (536P_5.7.2_01)

_________________________________________________________________________________________________________________

Which of the following identifies both the user's current domain and login name?

1. System.Environment.GetEnvironmentVariable("username")

2. System.Environment.GetEnvironmentVariable("userdomain")

3. WindowsIdentity.GetCurrent() <Correct>

4. System.Environment.UserDomainName

5. System.Environment.UserName

Explanation :While there are several ways to retrieve the current user name, WindowsIdentity.GetCurrent() is the best way to retrieve both the domain and login name.

System.Environment.UserName retrieves only the user name.

System.Environment.UserDomainName retrieves only the domain name.

System.Environment.GetEnvironmentVariable("username") retrieves only the user name.

System.Environment.GetEnvironmentVariable("userdomain") retrieves only the domain name.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Access and modify identity information by using the System.Security.Principal classes. (Refer System.Security.Principal namespace) WindowsIdentity class and WindowsPrincipal class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 1

WindowsIdentity ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.principal.windowsidentity.aspx

Environment ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.environment.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 244 (536P_7.3.2_05)

_________________________________________________________________________________________________________________

Which of the following regular expressions would you use to validate a five-digit postal code?

1. http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?

2. ([^@]+)@(.+)

3. \d{5}<Correct>

4. ((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}

Explanation :\d{5} validates a postal code.

http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)? validates a well-formed URL.

((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4} validates a well-formed phone number.

([^@]+)@(.+) validates a well-formed e-mail address.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.RegularExpressions namespace) Regex class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 3 - Lesson 1

Validating User InputMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms172105.aspx

Regular Expression ClassesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/30wbz966.aspx

Regex ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 245 (536P_4.2.1_04)

_________________________________________________________________________________________________________________

Which of the following code samples correctly deserializes the current date and time from an XML file?

1. ' VBDim fs As FileStream = New FileStream("SerializedDate.XML", FileMode.Open)Dim t As DateTime = CType(XmlSerializer.Read(fs),DateTime)

// C#FileStream fs = new FileStream("SerializedDate.XML", FileMode.Open);DateTime t = (DateTime)XmlSerializer.Read(fs);

2. ' VBDim fs As FileStream = New FileStream("SerializedDate.XML", FileMode.Open)Dim xs As XmlSerializer = New XmlSerializer()Dim t As DateTime = CType(xs.Deserialize(fs),DateTime)

// C#FileStream fs = new FileStream("SerializedDate.XML", FileMode.Open);XmlSerializer xs = new XmlSerializer();DateTime t = (DateTime)xs.Deserialize(fs);

3. ' VBDim fs As FileStream = New FileStream("SerializedDate.XML", FileMode.Open)Dim xs As XmlSerializer = New XmlSerializer(GetType(DateTime))Dim t As DateTime = CType(xs.Deserialize(fs),DateTime)

// C#FileStream fs = new FileStream("SerializedDate.XML", FileMode.Open);XmlSerializer xs = new XmlSerializer(typeof(DateTime));DateTime t = (DateTime)xs.Deserialize(fs);

<Correct>

4. ' VBDim fs As FileStream = New FileStream("SerializedDate.XML", FileMode.Open)Dim xs As XmlSerializer = New XmlSerializer(fs)Dim t As DateTime = CType(xs.Deserialize(),DateTime)

// C#FileStream fs = new FileStream("SerializedDate.XML", FileMode.Open);XmlSerializer xs = new XmlSerializer(fs);DateTime t = (DateTime)xs.Deserialize();

Explanation :To deserialize an object, first create a Stream, TextReader, or XmlReader object to read the serialized input. Then create an XmlSerializer object (in the System.Xml.Serialization namespace) by passing it the type of object you plan to deserialize. Finally, call the XmlSerializer.Deserialize method to deserialize the object, and cast it to the correct type.

No overload for the XmlSerializer constructor takes zero parameters.

There is no static XmlSerializer.Read method.

The XmlSerializer constructor requires a Type object and cannot accept a FileStream object.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Control the serialization of an object into XML format by using the System.Xml.Serialization namespace. Serialize and deserialize objects into XML format by using the XmlSerializer class.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, Microsoft

Chapter 5 - Lesson 2

Basic SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/4abbf6k0.aspx

XmlSerializer ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx

Introducing XML SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/182eeyhh.aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 3

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 246 (536P_5.4.1_01)

_________________________________________________________________________________________________________________

You are reviewing a colleague's code for security vulnerabilities. Which of the following System.Security.Cryptography classes would indicate that the developer was using weak encryption that could potentially be cracked in a short amount of time?

1. RijndaelManaged

2. RC2

3. DES<Correct>

4. TripleDES

Explanation :The Data Encryption Standard (DES) is a symmetric encryption algorithm that uses relatively short key lengths that are vulnerable to cracking attacks. For that reason, it should be avoided.

RijndaelManaged, an implementation of Advanced Encryption Standard (AES), is a strong government encryption standard and is the only .NET Framework symmetric encryption class that is fully managed. All other encryption classes call unmanaged code. Because of this, RijndaelManaged is the preferred choice when your application will be running in a partially trusted environment.

RC2 is an encryption standard designed to replace DES that uses variable key sizes. It is more secure than DES.

TripleDES is the .NET Framework implementation of the Triple DES (3DES) symmetric encryption algorithm. It essentially applies the DES algorithm three times. It is approximately twice as strong as standard DES.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace) DES class and DESCryptoServiceProvider class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 3

Cryptography OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/92f9ye3s.aspx

SymmetricAlgorithm ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.cryptography.symmetricalgorithm.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 247 (536P_6.2.5_01)

_________________________________________________________________________________________________________________

You are writing an assembly that needs to make calls to unmanaged functions in order to perform graphical layout computations. Which of the following code samples correctly defines the PtInRect method and associated structures?

1. ' VBImports System.Runtime.InteropServices

<Structure(LayoutKind.Sequential)> Public Structure Point Public x As Integer Public y As IntegerEnd Structure

<Structure(LayoutKind.Explicit)> Public Structure Rect <FieldOffset(0)> Public left As Integer <FieldOffset(4)> Public top As Integer <FieldOffset(8)> Public right As Integer <FieldOffset(12)> Public bottom As IntegerEnd Structure

Class Win32API Declare Auto Function PtInRect Lib "user32.dll" _ (ByRef r As Rect, p As Point) As BooleanEnd Class

// C#using System.Runtime.InteropServices;

[struct(LayoutKind.Sequential)]public struct Point { public int x; public int y;}

[struct(LayoutKind.Explicit)]public struct Rect { [FieldOffset(0)] public int left; [FieldOffset(4)] public int top; [FieldOffset(8)] public int right; [FieldOffset(12)] public int bottom;}

class Win32API { [DllImport("User32.dll")] public static extern bool PtInRect(ref Rect r, Point p);}

2. ' VBImports System.Runtime.InteropServices

<StructLayout(LayoutKind.Explicit)> Public Structure Point Public x As Integer Public y As IntegerEnd Structure

<StructLayout(LayoutKind.Sequential)> Public Structure Rect <FieldOffset(0)> Public left As Integer <FieldOffset(4)> Public top As Integer <FieldOffset(8)> Public right As Integer <FieldOffset(12)> Public bottom As IntegerEnd Structure

Class Win32API Declare Auto Function PtInRect Lib "user32.dll" _ (ByRef r As Rect, p As Point) As BooleanEnd Class

// C#using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Explicit)]public struct Point { public int x; public int y;}

[StructLayout(LayoutKind.Sequential)]public struct Rect { [FieldOffset(0)] public int left; [FieldOffset(4)] public int top; [FieldOffset(8)] public int right; [FieldOffset(12)] public int bottom;}

class Win32API { [DllImport("User32.dll")] public static extern bool PtInRect(ref Rect r, Point p);}

3. ' VBImports System.Runtime.InteropServices

<Structure(LayoutKind.Explicit)> Public Structure Point Public x As Integer Public y As IntegerEnd Structure

<Structure(LayoutKind.Sequential)> Public Structure Rect <FieldOffset(0)> Public left As Integer <FieldOffset(4)> Public top As Integer <FieldOffset(8)> Public right As Integer <FieldOffset(12)> Public bottom As IntegerEnd Structure

Class Win32API Declare Auto Function PtInRect Lib "user32.dll" _ (ByRef r As Rect, p As Point) As BooleanEnd Class

// C#using System.Runtime.InteropServices;

[struct(LayoutKind.Explicit)]public struct Point { public int x; public int y;}

[struct(LayoutKind.Sequential)]public struct Rect { [FieldOffset(0)] public int left; [FieldOffset(4)] public int top; [FieldOffset(8)] public int right; [FieldOffset(12)] public int bottom;}

class Win32API { [DllImport("User32.dll")] public static extern bool PtInRect(ref Rect r, Point p);}

4. ' VBImports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential)> Public Structure Point Public x As Integer Public y As IntegerEnd Structure

<StructLayout(LayoutKind.Explicit)> Public Structure Rect <FieldOffset(0)> Public left As Integer <FieldOffset(4)> Public top As Integer <FieldOffset(8)> Public right As Integer <FieldOffset(12)> Public bottom As IntegerEnd Structure

Class Win32API Declare Auto Function PtInRect Lib "user32.dll" _ (ByRef r As Rect, p As Point) As BooleanEnd Class

// C#

using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential)]public struct Point { public int x; public int y;}

[StructLayout(LayoutKind.Explicit)]public struct Rect { [FieldOffset(0)] public int left; [FieldOffset(4)] public int top; [FieldOffset(8)] public int right; [FieldOffset(12)] public int bottom;}

class Win32API { [DllImport("User32.dll")] public static extern bool PtInRect(ref Rect r, Point p);} <Correct>

Explanation :To create a managed definition for an unmanaged function that accepts structures, you can create structure definitions using StructLayoutAttribute and declare the properties contained within the structure. You can declare the structures either sequentially, explicitly, or automatically. Explicitly declared structures must include a FieldOffset attribute for each property.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Call unmanaged DLL functions in a .NET Framework application, and control the marshaling of data in a .NET Framework application. (Refer System.Runtime.InteropServices namespace) Call a DLL function in special cases, such as passing structures and implementing callback functions.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 13 - Lesson 3

Passing StructuresMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/awbckfbz(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 248 (536P_2.2.1_05)

_________________________________________________________________________________________________________________

You are writing managed code that will be executed within a thread. What do you need to do to enable your code to finish writing a file if the parent calls Thread.Abort?

1. Respond to the parent process's On_Abort event.

2. Implement the IAbortable interface.

3. Catch the ThreadAbortException, and do whatever is appropriate to complete processing in either the Catch or Finally block. <Correct>

4. Nothing. Thread.Abort causes processing to stop immediately.

Explanation :Thread.Abort does not cause a thread to immediately stop. In fact, an aborted thread can continue to run indefinitely. To continue running to complete processing, catch the ThreadAbortedException and do whatever is appropriate.

Processing does not stop immediately if you catch the ThreadAbortedException.

There is no IAbortable interface.

There is no On_Abort event.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Develop multithreaded .NET Framework applications. (Refer System.Threading namespace) Thread class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 7 - Lesson 1

Pausing and Resuming ThreadsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/tttdef8x.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 249 (536P_4.1.2_04)

_________________________________________________________________________________________________________________

You are creating a class that implements the ISerializable interface. Which serialization event should you respond to if you need to run code after serialization occurs?

1. Deserialized

2. Deserializing

3. Serialized <Correct>

4. Serializing

Explanation :The Serialized event occurs immediately after serialization.

The Serializing event occurs prior to serialization.

The Deserializing event occurs prior to deserialization.

The Deserialized event occurs immediately after serialization.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Serialize or deserialize an object or an object graph by using runtime serialization techniques. (Refer System.Runtime.Serialization namespace) Serilization attributes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 1

Custom SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ty01x675.aspx

Basics of .NET Framework SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms233836.aspx

ISerializable InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.iserializable.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 250 (536P_3.4.2_01)

_________________________________________________________________________________________________________________

You are writing an application that performs long-running calculations. To minimize the impact on the responsiveness of the user's computer, you want to warn the user if your application is running at Normal or higher priority. Which of the following code samples accomplishes this?

1. ' VBIf Process.GetCurrentProcess.BasePriority.IsNormal Then Console.WriteLine("For best results, run this application at low priority.")End If

// C#if (Process.GetCurrentProcess().BasePriority.IsNormal) Console.WriteLine("For best results, run this application at low priority.");

2. ' VBIf Process.GetCurrentProcess.BasePriority >= 8 Then Console.WriteLine("For best results, run this application at low priority.")End If

// C#if (Process.GetCurrentProcess().BasePriority >= 8) Console.WriteLine("For best results, run this application at low priority.");

<Correct>

3. ' VBIf Not Process.GetCurrentProcess().BasePriority.IsLow Then Console.WriteLine("For best results, run this application at low priority.")End If

// C#if (!Process.GetCurrentProcess().BasePriority.IsLow) Console.WriteLine("For best results, run this application at low priority.");

4. ' VBIf Process.GetCurrentProcess.BasePriority >= 4 Then Console.WriteLine("For best results, run this application at low priority.")End If

// C#if (Process.GetCurrentProcess().BasePriority >= 4) Console.WriteLine("For best results, run this application at low priority.");

Explanation :You should examine the Process.GetCurrentProcess().BasePriority property. A value of 4 is considered low priority, 8 is normal priority, 13 is high priority, and 24 is real-time priority. Therefore, a value of 8 or higher indicates the current application is running at Normal priority.

There is no Process.BasePriority.IsNormal property.

There is no Process.BasePriority.IsLow property.

Checking Process.GetCurrentProcess().BasePriority for a value of 4 or higher would be true even if the process were running as a low priority.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Manage system processes and monitor the performance of a .NET Framework application by using the diagnostics functionality of the .NET Framework 2.0. (Refer System.Diagnostics namespace) Retrieve information about the current process.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 3

Process.BasePriority PropertyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.process.basepriority.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 251 (536P_5.1.3_02)

_________________________________________________________________________________________________________________

Which of the following commands adds the App.exe assembly to the full trust list for the machine policy?

1. Caspol -user -addgroup Full_Trust App.exe

2. Caspol -machine -addfulltrust App.exe <Correct>

3. Caspol -user -addfulltrust App.exe

4. Caspol -machine -addgroup Full_Trust App.exe

Explanation :Use the -machine and -addfulltrust arguments with the Caspol.exe command-line tool to add an assembly to the full trust list for the machine policy.

The -user argument adds the assembly to the user full trust list, not the machine full trust list.

You cannot use the -addgroup argument to add an assembly to the full trust list.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement code access security to improve the security of a .NET Framework application. (Refer System.Security namespace) Modify the Code Access security policy at the computer, user, and enterprise policy level by using the Code Access Security Policy tool (Caspol.exe).

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 1

Code Access Security Policy Tool (Caspol.exe)MSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/cb6t8dtz.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 252 (536P_1.1.5_06)

_________________________________________________________________________________________________________________

What is the output of the following code?

' VBTry Console.WriteLine("Connecting to server") Throw New SmtpException("Server unavailable") Console.WriteLine("Connected to server")Catch ex As SmtpException Console.WriteLine("SMTP Error: " + ex.Message)Catch ex As Exception Console.WriteLine("Error: " + ex.Message)Finally Console.WriteLine("Connection closed")End Try

// C#try{ Console.WriteLine("Connecting to server"); throw new SmtpException("Server unavailable"); Console.WriteLine("Connected to server");}catch(SmtpException ex){ Console.WriteLine("SMTP Error: " + ex.Message);}catch(Exception ex){ Console.WriteLine("Error: " + ex.Message);}finally{ Console.WriteLine("Connection closed");}

1. Connecting to serverError: Server unavailableConnection closed

2. Connecting to serverSMTP Error: Server unavailableConnection closed

<Correct>

3. Connecting to serverConnected to serverConnection closed

4. Connecting to serverConnected to serverSMTP Error: Server unavailableConnection closed

Explanation :In the Try block, the first Console.WriteLine command will always run. The Throw command halts execution and processing resumes in a Catch block. Because the first Catch block matches the exception type thrown, processing resumes in the first Catch block. After the Catch block has finished running, processing continues within the Finally block.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer

System namespace) Exception classes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

Exceptions in Managed ThreadsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms228965.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 253 (536P_2.2.1_03)

_________________________________________________________________________________________________________________

You need to pause a thread to ensure other threads have sufficient processor time. You need to resume processing of the thread later. Which method would you call?

1. Thread.Abort

2. Thread.Interrupt

3. Thread.Suspend

4. Thread.Sleep <Correct>

Explanation :Calling the System.Threading.Thread.Sleep method causes the current thread to immediately block for the number of milliseconds you pass to System.Threading.Thread.Sleep, yielding the remainder of its time slice to another thread. Calling System.Threading.Thread.Sleep with System.Threading.Timeout.Infinite causes a thread to sleep until it is interrupted by another thread that calls System.Threading.Thread.Interrupt, or until it is terminated by System.Threading.Thread.Abort.

In the .NET Framework version 2.0, the System.Threading.Thread.Suspend method is marked obsolete and will be removed in a future release. Therefore, you should not use it.

Thread.Abort terminates a thread without giving you the opportunity to resume it.

Thread.Interrupt is used to resume a thread that has been paused.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Develop multithreaded .NET Framework applications. (Refer System.Threading namespace) Thread class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 7 - Lesson 1

Pausing and Resuming ThreadsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/tttdef8x.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 254 (536P_6.1.7_01)

_________________________________________________________________________________________________________________

Which of the following tools would you use to register an assembly for COM?

1. Gacutil.exe

2. Regasm.exe<Correct>

3. Regsvcs.exe

4. Tlbexp.exe

Explanation :The Assembly Registration Tool (Regasm.exe) can generate and register a type library when you apply the /tlb: option.

The Type Library Exporter (Tlbexp.exe) is a command-line tool that converts the classes and interfaces contained in an assembly to a COM type library.

The .NET Services Installation Tool (Regsvcs.exe) adds managed classes to Microsoft Windows 2000 Component Services and combines several tasks within a single tool.

Use the Global Assembly Cache tool (Gacutil.exe) to add an assembly to the global assembly cache.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Expose COM components to the .NET Framework and the .NET Framework components to COM. (Refer System.Runtime.InteropServices namespace) Package an assembly for COM.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 13 - Lesson 2

Packaging an Assembly for COMMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/bctyca52(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 255 (536P_3.4.5_01)

_________________________________________________________________________________________________________________

You are writing an application that requires the user to open a second application named "Application.exe", make a configuration change, and then close the application. You want to automatically launch the application for the user, and then wait indefinitely until the user closes the application. Which of the following code samples accomplishes this?

1. ' VBDim p As Process = New Processp.StartInfo.FileName = "Application.exe"p.Startp.WaitForExit

// C#Process p = new Process();p.StartInfo.FileName = "Application.exe";p.Start();p.WaitForExit();

<Correct>

2. ' VBDim p As Process = New Process("Application.exe")p.Startp.WaitForExit(10000)

// C#Process p = new Process("Application.exe");p.Start();p.WaitForExit(10000);

3. ' VBDim p As Process = New Process("Application.exe")p.Startp.WaitForExit

// C#Process p = new Process("Application.exe");p.Start();p.WaitForExit();

4. ' VBDim p As Process = New Processp.StartInfo.FileName = "Application.exe"p.Startp.WaitForExit(10000)

// C#Process p = new Process();p.StartInfo.FileName = "Application.exe";p.Start();p.WaitForExit(10000);

Explanation :To launch a new process, first create an instance of the Process class, and then specify the Process.StartInfo.FileName property. Finally, call the Process.Start method. To stop processing until the application closes, call the Process.WaitForExit method without specifying a time.

You cannot specify an application filename in the Process constructor.

Specifying a time for the Process.WaitForExit method causes the runtime to continue execution after the specified time even if the application hasn't closed.

You cannot specify an application filename in the Process constructor. Additionally, specifying a time for the Process.WaitForExit method causes the runtime to continue execution after the specified time even if the application hasn't closed.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Manage system processes and monitor the performance of a .NET Framework application by using the diagnostics functionality of the .NET Framework 2.0. (Refer System.Diagnostics namespace) Start a process both by using and by not using command-line arguments.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 3

Process ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.process.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 256 (536P_6.4.4_01)

_________________________________________________________________________________________________________________

Which of the following can you use to add an attachment to a System.Net.Mail.MailMessage object? (Choose all that apply.)

1. An object that can be serialized using XmlSerializer

2. A stream object for a readable file <Correct>

3. A string containing a filename <Correct>

4. An object that can be serialized using the BinaryFormatter

5. A MemoryBuffer object

Explanation :Attachments can only be files on a disk. You can specify the file using the filename or by opening a stream.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery from a .NET Framework application. (Refer System.Net.Mail namespace) Attachment class, AttachmentBase class, and AttachmentCollection class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 15 - Lesson 1

Attachment ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.net.mail.attachment(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 257 (536P_3.2.1_04)

_________________________________________________________________________________________________________________

You have created a custom installer class. If the user cancels an installation, you need to run special code to remove changes you have made. Which of the following Installer methods would you place the code in?

1. OnCommitting

2. Install

3. Rollback <Correct>

4. Commit

5. OnRollback

Explanation :Use the Rollback method to remove changes made during installation when install is cancelled.

The Install method performs the actual installation.

The Commit method finalizes installation changes.

The OnCommitting method runs immediately before the Commit method.

There is no OnRollback method.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Create a custom Microsoft Windows Installer for the .NET Framework components by using the System.Configuration.Install namespace, and configure the .NET Framework applications by using configuration files, environment variables, and the .NET Framework Configuration tool (Mscorcfg.msc).). Installer class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 2

Installer ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.configuration.install.installer(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 258 (536P_5.2.6_01)

_________________________________________________________________________________________________________________

You need to modify Microsoft Windows access control security for a named mutex.

From the list on the right, select the tasks that you should perform to modify Windows access control security for a named mutex. Place your selections in the list on the left in the order in which the tasks should be performed. Place your selections in the list on the left by clicking the items in the list on the right and clicking the arrow. You can also use the Up and Down buttons to rearrange items in the list on the left. You might not need to use all the items from the list on the right.

Explanation :To modify Windows access control security for a named mutex, use the Mutex.GetAccessControl method to get the MutexSecurity object. Modify the security object by adding and removing rules, and then use the Mutex.SetAccessControl method to reattach it.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement access control by using the System.Security.AccessControl classes. MutexSecurity class, ObjectSecurity class, and SemaphoreSecurity class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 2

MutexSecurity ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.accesscontrol.mutexsecurity.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 259 (536P_3.3.1_02)

_________________________________________________________________________________________________________________

You are writing an application that must perform event logging. When is the correct time to create an event source?

1. Before you write each event

2. After the computer is restarted

3. During installation <Correct>

4. Before you write the first event

Explanation :You should create a new event source during application installation. This will require the user to have administrative privileges.

You only need to create an event source once. Therefore, it is unnecessary to create it before each event.

You should create a new event source during application installation, rather than before you write the first event. Creating an event source requires administrative privileges, and users are more likely to have administrative privileges during application installation. Users should not run your application with administrative privileges.

You do not need to wait for the computer to be restarted to create an event source.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Manage an event log by using the System.Diagnostics namespace. Write to an event log.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 1

EventLog ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 260 (536P_5.6.7_01)

_________________________________________________________________________________________________________________

You need to create a custom trust manager to enable your organization to use custom logic when determining whether a .NET Framework application should be executed, and which permissions should be granted to the application. Which interface would you implement?

1. IIdentityPermissionFactory

2. IApplicationTrustManager <Correct>

3. IMembershipCondition

4. IIdentity

Explanation :Trust managers must implement the IApplicationTrustManager interface. The host calls the DetermineApplicationTrust method in the trust manager to determine whether an application should be executed and which permissions should be granted to the application.

IMembershipCondition defines the test to determine whether a code assembly is a member of a code group. While the function is similar, the scope of IMembershipCondition is smaller than that of IApplicationTrustManager.

By implementing IIdentityPermissionFactory for an evidence object, you provide an implementation of CreateIdentityPermission that the .NET Framework security system can call to get an identity permission that represents that piece of evidence. During policy resolution, the security system will call that method on all evidence objects that implement IIdentityPermissionFactory and grant the resulting identity permissions to the appropriate assembly. While the function is similar, the scope of IIdentityPermissionFactory is smaller than that of IApplicationTrustManager.

IIdentity is an identity object that represents the user. It might be provided as evidence; however, it cannot be used to create a custom trust manager.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Control code privileges by using System.Security.Policy classes. (Refer System.Security.Policy namespace) IApplicationTrustManager interface, IMembershipCondition interface, and IIdentityPermissionFactory interface

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 1

IApplicationTrustManager InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.policy.iapplicationtrustmanager.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 261 (536P_5.2.5_01)

_________________________________________________________________________________________________________________

You need to have an event written to the event log if someone modifies one of your application's registry keys. Which of the following classes should you use? (Choose all that apply.)

1. RegistryKey <Correct>

2. RegistryPermissionAccess

3. RegistryPermission

4. AuditRule

5. RegistryAuditRule <Correct>

6. RegistrySecurity <Correct>

Explanation :To specify auditing on a registry key, you need three classes: RegistryAuditRule, RegistrySecurity, and RegistryKey.

AuditRule is the base class for RegistryAuditRule and is not required.

RegistryPermissionAccess is an enumeration and is not required to configure auditing.

RegistryPermission controls access, not auditing.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Implement access control by using the System.Security.AccessControl classes. AuditRule class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 2

ACL Technology ScenariosMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms229925(VS.80).aspx

RegistryAuditRule ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.accesscontrol.registryauditrule(VS.80).aspx

RegistrySecurity ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.accesscontrol.registrysecurity(VS.80).aspx

RegistryKey ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/microsoft.win32.registrykey.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 262 (536P_4.4.1_04)

_________________________________________________________________________________________________________________

Which of the following code samples does not result in an exception being thrown if "text.txt" does not exist? (Choose all that apply.)

1. ' VBDim fn As String = "Text.txt"Dim fi As FileInfo = New FileInfo(fn)If fi.Exists Then Dim sr As StreamReader = New StreamReader(fn) Console.WriteLine(sr.ReadToEnd)End If

// C#String fn = "Text.txt";FileInfo fi = new FileInfo(fn);if (fi.Exists){ StreamReader sr = new StreamReader(fn); Console.WriteLine(sr.ReadToEnd());} <Correct>

2. ' VBDim fn As String = "Text.txt"If File.Exists(fn) Then Dim sr As StreamReader = New StreamReader(fn) Console.WriteLine(sr.ReadToEnd)End If

// C#String fn = "Text.txt";if (File.Exists(fn)){ StreamReader sr = new StreamReader(fn); Console.WriteLine(sr.ReadToEnd());} <Correct>

3. ' VBDim fn As String = "Text.txt"Dim fi As FileInfo = New FileInfo(fn)If fi.Exists Then Dim sr As StreamReader = New StreamReader(fi) Console.WriteLine(sr.ReadToEnd)End If

// C#String fn = "Text.txt";FileInfo fi = new FileInfo(fn);if (fi.Exists){ StreamReader sr = new StreamReader(fi); Console.WriteLine(sr.ReadToEnd());}

4. ' VBDim fn As String = "Text.txt"If FileInfo.Exists(fn) Then Dim sr As StreamReader = New StreamReader(fn) Console.WriteLine(sr.ReadToEnd)End If

// C#String fn = "Text.txt";if (FileInfo.Exists(fn)){ StreamReader sr = new StreamReader(fn); Console.WriteLine(sr.ReadToEnd());}

Explanation :

To check whether a file exists, you can call the static File.Exists method, or you can create a FileInfo object and call FileInfo.Exists.

The StreamReader constructor cannot take an instance of the class FileInfo.

FileInfo.Exists is not a static method. You must first create an instance of FileInfo to call this method.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Access files and folders by using the File System classes. (Refer System.IO namespace) File class and FileInfo class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 1

FileInfo ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/library/akth6b1k(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 263 (536P_3.2.1_02)

_________________________________________________________________________________________________________________

In the Installer class, which of the following methods is called last in a successful installation?

1. Rollback

2. Uninstall

3. OnAfterInstall

4. Install

5. Commit <Correct>

6. OnAfterRollback

Explanation :During a successful installation, Installer.Commit is the last method called. Commit finalizes all changes made during the installation.

Installer.Install performs the actual installation, but changes are not finalized until Installer.Commit is called.

Installer.Rollback is called only if an error occurs during installation and changes must be undone.

Installer.Uninstall is called only when uninstalling an application.

Installer.OnAfterRollback is called only if an error occurs during installation and changes must be undone.

Installer.OnAfterInstall is called immediately before Installer.Commit.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Create a custom Microsoft Windows Installer for the .NET Framework components by using the System.Configuration.Install namespace, and configure the .NET Framework applications by using configuration files, environment variables, and the .NET Framework Configuration tool (Mscorcfg.msc).). Installer class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 9 - Lesson 2

Installer ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.configuration.install.installer(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 264 (536P_6.2.9_02)

_________________________________________________________________________________________________________________

When marshaling data with COM interop, to which of the following types will the .NET Framework convert a VARIANT COM type?

1. Guid

2. Boolean

3. Object <Correct>

4. IntPtr

Explanation :The COM value type VARIANT is converted to System.Object.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Call unmanaged DLL functions in a .NET Framework application, and control the marshaling of data in a .NET Framework application. (Refer System.Runtime.InteropServices namespace) Marshal data with COM Interop

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 13 - Lesson 3

COM Data TypesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/sak564ww(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 265 (536P_4.7.4_01)

_________________________________________________________________________________________________________________

You need to implement a custom compression algorithm in a custom class. How can you create the custom class? (Choose all that apply.)

1. Implement DeflateStream

2. Implement GZipStream

3. Derive from GZipStream <Correct>

4. Create an instance of GZipStream and set the Algorithm property

5. Create an instance of DeflateStream and set the Algorithm property

6. Derive from DeflateStream <Correct>

Explanation :You can derive from GZipStream or DeflateStream. GZipStream is based on the GZip algorithm, while DeflateStream is based on the Deflate algorithm. Alternatively, you could create an entirely unique compression algorithm by implementing the Stream interface.

GZipStream and DeflateStream are not interfaces and cannot be implemented.

GZipStream and DeflateStream do not have an Algorithm property.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Compress or decompress stream information in a .NET Framework application (refer System.IO.Compression namespace), and improve the security of application data by using isolated storage. (Refer System.IO.IsolatedStorage namespace) GZipStream class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 3

GZipStream ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.io.compression.gzipstream(VS.80).aspx

DeflateStream ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.io.compression.deflatestream(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 266 (536P_4.7.2_02)

_________________________________________________________________________________________________________________

You are working with your IT department to deploy an application that you wrote. The IT department asks if your application needs access to any folders on the local hard disk. Your application only uses isolated storage. Your application will be deployed only to Microsoft new computers running Windows XP. Your IT department does not use roaming profiles.

To which folder does your application require access?

1. <systemroot>\Application Data

2. <systemroot>\Documents and Settings\<user>\Application Data

3. <systemroot>\Profiles\<user>\Application Data

4. <systemdrive>\Documents and Settings\<user>\ Local Settings\Application Data <Correct>

Explanation :On Windows XP computers that were not upgraded and do not use roaming profiles, isolated storage is physically located in the <systemdrive>\Documents and Settings\<user>\ Local Settings\Application Data folder.

The <systemroot>\Profiles\<user>\Application Data folder is used by Windows 2000, Windows XP, and Windows Server 2003 when upgraded from Windows NT 4.0 in environments that use roaming profiles.

The <systemroot>\Application Data folder is used by Microsoft Windows 98 and Windows ME without user profiles.

The <systemroot>\Documents and Settings\<user>\Application Data folder is used by Windows XP and Windows Server 2003, when upgraded from Windows 2000 and Windows 98, or when not upgraded in environments that use roaming profiles.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Compress or decompress stream information in a .NET Framework application (refer System.IO.Compression namespace), and improve the security of application data by using isolated storage. (Refer System.IO.IsolatedStorage namespace) IsolatedStorageFileStream class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 4

Introduction to Isolated StorageMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/3ak841sy.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 267 (536P_5.4.11_01)

_________________________________________________________________________________________________________________

What output does the following console application display?

' VBDim rc2 As RC2CryptoServiceProvider = New RC2CryptoServiceProviderConsole.WriteLine(rc2.Mode.ToString())

// C#RC2CryptoServiceProvider rc2 = new RC2CryptoServiceProvider();Console.WriteLine(rc2.Mode);

1. ECB

2. CBC<Correct>

3. CTS

4. OFB

5. CFB

Explanation :By default, all encryption classes use Cipher Block Chaining (CBC) as the cipher mode.

Cipher Feedback (CFB) is not the default cipher mode.

Cipher Text Stealing (CTS) is not the default cipher mode.

Electronic Cookbook (ECB) is not the default cipher mode.

Output Feedback (OFB) is not the default cipher mode.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace) RC2 class and RC2CryptoServiceProvider class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 3

CipherMode EnumerationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.cryptography.ciphermode.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 268 (536P_2.1.1_02)

_________________________________________________________________________________________________________________

What is the preferred way for a service to interact with a user?

1. By opening a dialog box

2. By opening a Web browser

3. By writing an event to the event log <Correct>

4. By writing a message to a text file

Explanation :Services do not have a user interface. Therefore, they cannot directly interact with the user by opening a dialog box or Web browser. Instead, you should write events to the event log. Although you could write messages to a text file, the event log is easier to manage, especially in enterprise environments.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Implement, install, and control a service. (Refer System.ServiceProcess namespace) Inherit from ServiceBase class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 8 - Lesson 3

ServiceController ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.aspx

Introduction to Windows Service ApplicationsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/d56de412.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 269 (536P_5.5.11_02)

_________________________________________________________________________________________________________________

You are writing an internal application and need to determine whether the user is logged into your organization's domain. Which of the following values could you evaluate to determine whether the user was authenticated against your domain, their local computer, or a different domain? (Choose all that apply.)

1. System.Environment.UserName

2. System.Environment.GetEnvironmentVariable("authentication")

3. System.Environment.UserDomainName <Correct>

4. System.Environment.GetEnvironmentVariable("username")

5. System.Environment.GetEnvironmentVariable("userdomain") <Correct>

Explanation :System.Environment.UserDomainName and System.Environment.GetEnvironmentVariable("userdomain") both identify the domain the computer used to authenticate. If the user authenticated to the local user database, the values would contain the computer name. Of those two, you should choose System.Environment.UserDomainName whenever possible.

System.Environment.UserName and System.Environment.GetEnvironmentVariable("username") retrieve only the user name.

System.Environment.GetEnvironmentVariable("authentication") would not work because there is no authentication environment variable.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Control permissions for resources by using the System.Security.Permission classes. (Refer System.Security.Permission namespace) EnvironmentPermission class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 3

Environment ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.environment.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 270 (536P_6.4.2_01)

_________________________________________________________________________________________________________________

You are writing an application that sends outgoing e-mail messages. After testing the application, you notice that e-mail addresses appear in the mail client without the recipient's full name. For example, instead of showing "Allen Michael", it shows "[email protected]". You would like to show the user's name in the message, instead. Which of the following code fragments accomplishes this by correctly specifying the display name?

1. ' VBDim myMail As MailMessage = New MailMessagemyMail.From = "[email protected]; Administrator"myMail.To = "[email protected]; Allen Michael

// C#MailMessage myMail = new MailMessage();myMail.From = "[email protected]; Administrator";myMail.To = "[email protected]; Allen Michael";

2. ' VBDim myMail As MailMessage = _New MailMessage(New MailAddress("[email protected]", "Administrator"), _New MailAddress("[email protected]", "Allen Michael"))

// C#MailMessage myMail = new MailMessage(new MailAddress("[email protected]", "Administrator"), new MailAddress("[email protected]", "Allen Michael"));

<Correct>

3. ' VBDim myMail As MailMessage = _New MailMessage("[email protected]", "Administrator", _"[email protected]", "Allen Michael")

// C#MailMessage myMail = new MailMessage("[email protected]", "Administrator","[email protected]", "Allen Michael");

4. ' VBDim myMail As MailMessage = New MailMessagemyMail.From = "[email protected]"myMail.FromName = "Administrator"myMail.To = "[email protected]"myMail.ToName = "Allen Michael"

// C#MailMessage myMail = new MailMessage();myMail.From = "[email protected]";myMail.FromName = "Administrator";myMail.To = "[email protected]";myMail.ToName = "Allen Michael";

Explanation :The only way to specify the display name for an e-mail address is to create an instance of the MailAddress class.

You cannot specify the display name in the MailMessage constructor.

There is no MailMessage.ToName or MailMessage.FromName properties.

You cannot specify the display name by separating the name from the e-mail address using a semi-colon.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery from a .NET Framework application. (Refer System.Net.Mail namespace) MailAddress class and MailAddressCollection class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 15 - Lesson 1

System.Net.Mail NamespaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.net.mail(VS.80).aspx

MailAddress ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.net.mail.mailaddress(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 271 (536P_1.1.5_01)

_________________________________________________________________________________________________________________

Which of the following is an accurate description of an exception?

1. An error condition or unexpected behavior encountered by an executing program that causes normal execution to be halted. <Correct>

2. A type from one assembly that is moved into another assembly so that it is not necessary to recompile clients that consume the first assembly.

3. A type that stores a pointer to the data, rather than the actual data.

4. A class that uses placeholders for one or more of the types it uses.

Explanation :Exceptions are error conditions that cause normal execution to be halted.

Generics use placeholders for their types, which allow multiple types of objects to be used as a parameter.

Type forwarding enables moving a type from one assembly into another assembly without requiring recompiling.

Reference types store a pointer to the data, rather than the actual data.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Exception classes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

Exceptions OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/6kzk0czb.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 272 (536P_5.5.1_01)

_________________________________________________________________________________________________________________

Your IT department has requested your assistance. They have asked you to write a console application that analyzes the C:\Boot.ini file to determine whether it is properly configured. The IT department will deploy your tool with administrative privileges, and you want to minimize the risk that the application will be abused to perform another task. Which of the following attributes would you use to minimize the security risk by limiting the assembly's privileges so that it can only access the C:\Boot.ini file?

1. ' VB<Assembly: FileIOPermissionAttribute(SecurityAction.RequestOptional, Read := "C:\boot.ini")>

// C#[assembly:FileIOPermissionAttribute(SecurityAction.RequestOptional, Read=@"C:\boot.ini")]

<Correct>

2. ' VB<Assembly: FileIOPermissionAttribute(SecurityAction.PermitOnly, Read := "C:\boot.ini")>

// C#[assembly:FileIOPermissionAttribute(SecurityAction.PermitOnly, Read=@"C:\boot.ini")]

3. ' VB<Assembly: FileIOPermissionAttribute(SecurityAction.RequestMinimum, Read := "C:\boot.ini")>

// C#[assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum, Read=@"C:\boot.ini")]

4. ' VB<Assembly: FileIOPermissionAttribute(SecurityAction.RequestMinimum)>

// C#[assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum)]

Explanation :For declarative security attributes, use SecurityAction.RequestOptional to list only CAS permissions your application should have. Additionally, you might want to use SecurityAction.RequestMinimum to cause the runtime to throw an exception if the assembly lacks the required permission.

SecurityAction.PermitOnly cannot be used in declarative attributes.

SecurityAction.RequestMinimum causes the runtime to throw an exception if the runtime lacks the listed permissions. However, it does not cause the runtime to reduce the assembly's permissions.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Control permissions for resources by using the System.Security.Permission classes. (Refer System.Security.Permission namespace) SecurityPermission class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 3

Assemblies should declare minimum securityMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms182325.aspx

SecurityAction EnumerationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.permissions.securityaction.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 273 (536P_1.1.1_02)

_________________________________________________________________________________________________________________

Which of the following methods do all classes have as members? (Choose all that apply.)

1. ToString() <Correct>

2. Equals() <Correct>

3. CompareTo()

4. Clone()

5. Dispose()

6. GetType() <Correct>

Explanation :All classes inherit the ToString(), Equals(), and GetType() methods from the base Object class.

The CompareTo() method is a member of the IComparable interface.

The Dispose() method is a member of the IDisposable interface.

The Clone() method is a member of the ICloneable interface.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Value types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 1

Object ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.object.aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 274 (536P_5.6.6_01)

_________________________________________________________________________________________________________________

One month ago, you released a .NET Framework application, and your IT department deployed it to the users shortly thereafter. Recently, the IT department made some changes to security policies, and now some users are complaining that certain features of your application do not work as expected.

In which order are the security policies applied to your assembly?

From the list on the right, select the security policies. Place your selections in the list on the left in the order in which the runtime evaluates them. Place your selections in the list on the left by clicking the items in the list on the right and clicking the arrow. You can also use the Up and Down buttons to rearrange items in the list on the left.

Explanation :The Enterprise level is the highest security policy level, describing security policy for an entire enterprise. Enterprise security policy can be configured by using the Active Directory directory service. Machine policy, the second security policy level, applies to all code run on a particular computer. User policy is the third level, and it defines permissions on a per-user basis. The runtime evaluates the Enterprise, Machine, and User levels separately, and it grants an assembly the minimum set of permissions granted by any of the levels (known as the intersection of the permission sets). Finally, the runtime evaluates the Application Domain security policy.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Control code privileges by using System.Security.Policy classes. (Refer System.Security.Policy namespace) PolicyLevel class and PolicyStatement class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 1

Security Policy LevelsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/628s5x1x.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 275 (536P_1.1.1_07)

_________________________________________________________________________________________________________________

Which of the following values could be stored in an instance of the short type? (Choose all that apply.)

1. 16,633 <Correct>

2. 127,236

3. -76,234

4. -12 <Correct>

5. -48,000

6. 34,210

Explanation :The short type can only store values between -32,768 and 32,767.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Value types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 1

.NET Framework Class Library OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/hfa3fa08.aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 276 (536P_5.4.3_02)

_________________________________________________________________________________________________________________

You are writing an application that manages inventory, orders, and shipping for a distribution company. When an item must be shipped, your application must send a message from the central office to a remote shipping facility. Which class can you use to sign a message with a digital signature and prove that the message originated from the central office?

1. DSACryptoServiceProvider <Correct>

2. SHA256

3. RSACryptoServiceProvider

4. DES

5. TripleDES

6. MD5

7. RijndaelManaged

8. RC2

Explanation :DSACryptoServiceProvider provides asymmetric digital signatures, which is the best way to prove that a message is genuine.

MD5 and SHA256 are hashing algorithms, which you can use to generate a unique key based on the contents of a file.

RijndaelManaged, DES, RC2, and TripleDES are all symmetric encryption classes.

RSACryptoServiceProvider provides asymmetric encryption; it cannot be used to sign messages.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace) DSA class and DSACryptoServiceProvider class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 3

Cryptography OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/92f9ye3s.aspx

DSACryptoServiceProvider ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.cryptography.dsacryptoserviceprovider.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 277 (536P_5.6.5_01)

_________________________________________________________________________________________________________________

Which class would you use to test whether an assembly was located in a specific folder?

1. SiteMembershipCondition

2. GacMembershipCondition

3. ApplicationDirectoryMembershipCondition <Correct>

4. UrlMembershipCondition

Explanation :The ApplicationDirectoryMembershipCondition class determines whether an assembly belongs to a code group by testing its application directory.

The GacMembershipCondition class determines whether an assembly belongs to a code group by testing its global assembly cache membership.

The SiteMembershipCondition class determines whether an assembly belongs to a code group by testing the site from which it originated.

The UrlMembershipCondition class determines whether an assembly belongs to a code group by testing its URL. While the function is very similar, use UrlMembershipCondition for assemblies retrieved using HTTP.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Control code privileges by using System.Security.Policy classes. (Refer System.Security.Policy namespace) Condition classes

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 1

ApplicationDirectoryMembershipCondition ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.policy.applicationdirectorymembershipcondition(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 278 (536P_5.7.2_03)

_________________________________________________________________________________________________________________

You are writing a method for internal use within your organization. Per instructions from your IT department, only users who are members of the local Administrators group should be able to run your method. Which of the following code samples would prevent users who are not members of the local Administrators group from running your method?

1. ' VBDim i As WindowsIdentity = WindowsIdentity.GetCurrent If Not i.IsInRole("Administrators") Then Throw New SecurityException("You must be an Administrator")End If

// C#WindowsIdentity i = WindowsIdentity.GetCurrent();if (!i.IsInRole("Administrators")) throw new SecurityException("You must be an Administrator");

2. ' VBDim i As WindowsIdentity = WindowsIdentity.GetCurrent Dim currentPrincipal As WindowsPrincipal = New WindowsPrincipal(i)If Not currentPrincipal.IsInRole("Administrators") Then Throw New SecurityException("You must be an Administrator")End If

// C#WindowsIdentity i = WindowsIdentity.GetCurrent();WindowsPrincipal currentPrincipal = new WindowsPrincipal(i);if (!currentPrincipal.IsInRole("Administrators")) throw new SecurityException("You must be an Administrator");

<Correct>

3. ' VBDim i As WindowsIdentity = WindowsIdentity.GetCurrent If Not i.IsInRole("LOCAL\Administrators") Then Throw New SecurityException("You must be an Administrator")End If

// C#WindowsIdentity i = WindowsIdentity.GetCurrent();if (!i.IsInRole(@"LOCAL\Administrators")) throw new SecurityException("You must be an Administrator");

4. ' VBDim i As WindowsIdentity = WindowsIdentity.GetCurrent Dim currentPrincipal As WindowsPrincipal = New WindowsPrincipal(i)If Not currentPrincipal.IsInRole("LOCAL\Administrators") Then Throw New SecurityException("You must be an Administrator")End If

// C#WindowsIdentity i = WindowsIdentity.GetCurrent();WindowsPrincipal currentPrincipal = new WindowsPrincipal(i);if (!currentPrincipal.IsInRole(@"LOCAL\Administrators")) throw new SecurityException("You must be an Administrator");

Explanation :To check which groups a user is in, create a WindowsPrincipal object based on WindowsIdentity.GetCurrent(). Then check WindowsPrincipal.IsInRole using just the group name. When testing for built-in roles, use WindowsBuiltInRole.

WindowsIdentity does not have an IsInRole method. Instead, you should create a WindowsPrincipal object. Additionally, you should not prepend LOCAL\ to the group name when using WindowsPrincipal.IsInRole.

Objective:

Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Access and modify identity information by using the System.Security.Principal classes. (Refer System.Security.Principal namespace) WindowsIdentity class and WindowsPrincipal class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 1

WindowsIdentity ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.principal.windowsidentity.aspx

WindowsPrincipal ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.principal.windowsprincipal.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 279 (536P_6.4.1_02)

_________________________________________________________________________________________________________________

You are writing an application that sends e-mail messages. One of your users reports an unhandled exception. The user writes the description down: "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first 10sm4347nzo."

Which of the following System.Net.Mail.MailMessage properties should you define to resolve the problem?

1. ReplyTo

2. Priority

3. Headers

4. Sender

5. Credentials <Correct>

6. Bcc

Explanation :This common exception indicates that the SMTP server requires authentication, and the client did not provide correct credentials. Therefore, you must define the MailMessage.Credentials property using a username and password provided by the user.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery from a .NET Framework application. (Refer System.Net.Mail namespace) MailMessage class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 15 - Lesson 1

MailMessage PropertiesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/45ddcb0d(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 280 (536P_3.4.1_01)

_________________________________________________________________________________________________________________

As part of a troubleshooting tool for the systems administrators at your organization, you are writing a command-line tool that automatically kills any unresponsive applications. Which of the following code samples accomplishes this?

1. ' VBFor Each p As Process In Process.GetProcesses If Not p.Responding Then p.Kill End IfNext

// C#foreach (Process p in Process.GetProcesses()) if (!p.Responding) p.Kill();

<Correct>

2. ' VBFor Each p As Process In Process.GetUnresponsiveProcesses p.KillNext

// C#foreach (Process p in Process.GetUnresponsiveProcesses()) p.Kill();

3. ' VBFor Each p As Process In Process.GetUnresponsiveProcesses Process.Kill(p.Id)Next

// C#foreach (Process p in Process.GetUnresponsiveProcesses()) Process.Kill(p.Id);

4. ' VBFor Each p As Process In Process.GetProcesses If Not p.Responding Then Process.Kill(p.Id) End IfNext

// C#foreach (Process p in Process.GetProcesses()) if (!p.Responding) Process.Kill(p.Id);

Explanation :First, you must retrieve an array of all processes by calling Process.GetProcesses. Then you should call Process.Kill for each process that you need to terminate.

There is no Process.GetUnresponsiveProcesses method, and Process.Kill is not a static method.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Manage system processes and monitor the performance of a .NET Framework application by using the diagnostics functionality of the .NET Framework 2.0. (Refer System.Diagnostics namespace) Get a list of all running processes.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 3

Process ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.diagnostics.process.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 281 (536P_3.6.2_02)

_________________________________________________________________________________________________________________

You are creating a tool for the IT department that displays the MAC address and description of every network adapter on a remote computer with the IP address 192.168.1.200. Which of the following code samples does this correctly?

1. ' VBDim ms As ManagementScope = New ManagementScope("\\192.168.1.200\root\cimv2")Dim oq As ObjectQuery = New ObjectQuery("SELECT * FROM Win32_NetworkAdapterConfiguration")Dim mos As ManagementObjectSearcher = New ManagementObjectSearcher(ms, oq)Dim moc As ManagementObjectCollection = mos.GetFor Each mo As ManagementObject In moc Console.WriteLine(mo("MacAddress") + ": " + mo("Description"))Next

// C#ManagementScope ms = new ManagementScope(@"\\192.168.1.200\root\cimv2");ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");

ManagementObjectSearcher mos = new ManagementObjectSearcher(ms, oq);ManagementObjectCollection moc = mos.Get();

foreach (ManagementObject mo in moc) Console.WriteLine(mo["MacAddress"] + ": " + mo["Description"]);

<Correct>

2. ' VBDim ms As ManagementScope = New ManagementScope("\\192.168.1.200")Dim oq As ObjectQuery = New ObjectQuery("SELECT * FROM Win32_NetworkAdapterConfiguration")Dim mos As ManagementObjectSearcher = New ManagementObjectSearcher(ms, oq)Dim moc As ManagementObjectCollection = mos.GetFor Each mo As ManagementObject In moc Console.WriteLine(mo("MacAddress") + ": " + mo("Description"))Next

// C#ManagementScope ms = new ManagementScope(@"\\192.168.1.200");ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");

ManagementObjectSearcher mos = new ManagementObjectSearcher(ms, oq);ManagementObjectCollection moc = mos.Get();

foreach (ManagementObject mo in moc) Console.WriteLine(mo["MacAddress"] + ": " + mo["Description"]);

3. ' VBDim co As ConnectionOptions = New ConnectionOptions("\\192.168.1.200 ")Dim oq As ObjectQuery = New ObjectQuery("SELECT * FROM Win32_NetworkAdapterConfiguration")Dim mos As ManagementObjectSearcher = New ManagementObjectSearcher(co, oq)Dim moc As ManagementObjectCollection = mos.GetFor Each mo As ManagementObject In moc Console.WriteLine(mo("MacAddress") + ": " + mo("Description"))Next

// C#ConnectionOptions co = new ConnectionOptions(@"\\192.168.1.200");ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");

ManagementObjectSearcher mos = new ManagementObjectSearcher(co, oq);ManagementObjectCollection moc = mos.Get();

foreach (ManagementObject mo in moc) Console.WriteLine(mo["MacAddress"] + ": " + mo["Description"]);

4. ' VBDim co As ConnectionOptions = New ConnectionOptions("\\192.168.1.200\root\cimv2")Dim oq As ObjectQuery = New ObjectQuery("SELECT * FROM Win32_NetworkAdapterConfiguration")Dim mos As ManagementObjectSearcher = New ManagementObjectSearcher(co, oq)

Dim moc As ManagementObjectCollection = mos.GetFor Each mo As ManagementObject In moc Console.WriteLine(mo("MacAddress") + ": " + mo("Description"))Next

// C#ConnectionOptions co = new ConnectionOptions(@"\\192.168.1.200\root\cimv2");ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");

ManagementObjectSearcher mos = new ManagementObjectSearcher(co, oq);ManagementObjectCollection moc = mos.Get();

foreach (ManagementObject mo in moc) Console.WriteLine(mo["MacAddress"] + ": " + mo["Description"]);

Explanation :To query running network adapters on a remote computer:

1. Create a ManagementScope object to define the remote computer. The scope is not simply the computer name, however. It must be in the form "\\computername\root\cim2".2. Create an instance of ObjectQuery using a Windows Management Instrumentation (WMI) query. The WMI query must be in the form "SELECT fields FROM Win32_NetworkAdapterConfiguration".3. Create an instance of ManagementObjectSearcher by providing both the scope and the query.4. Create an instance of ManagementObjectCollection by calling the ManagementObjectSearcher.Get method.

You can then iterate through the ManagementObjects in the ManagementObjectCollection to examine individual network adapters.

You can create a ConnectionsOptions object if you want to specify a username and password. However, you cannot use a ConnectionsOptions object in place of a ManagementScope object.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Embed management information and events into a NET Framework application. (Refer System.Management namespace) ManagementQuery class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 4

ManagementObjectSearcher ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.management.managementobjectsearcher.aspx

ObjectQuery ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.management.objectquery(VS.80).aspx

ManagementObjectCollection ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.management.managementobjectcollection.aspx

WMI .NET OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ms257340(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 282 (536P_3.3.2_01)

_________________________________________________________________________________________________________________

Which of the following code samples successfully writes the entire contents of the Application log to the console?

1. ' VBDim el As New EventLog()For Each ele As EventLogEntry In el.Entries Console.WriteLine(ele.Source + ": " + ele.Message)Next

// C#EventLog el = new EventLog();foreach (EventLogEntry ele in el.Entries) Console.WriteLine(ele.Source + ":" + ele.Message);

2. ' VBDim el As New EventLog()For Each ele As EventLog In el.Entries Console.WriteLine(ele.Source + ": " + ele.Message)Next

// C#EventLog el = new EventLog();foreach (EventLog ele in el.Entries) Console.WriteLine(ele.Source + ":" + ele.Message);

3. ' VBDim el As New EventLog()el.Log = "Application"For Each ele As EventLogEntry In el.Entries Console.WriteLine(ele.Source + ": " + ele.Message)Next

// C#EventLog el = new EventLog();el.Log = "Application";foreach (EventLogEntry ele in el.Entries) Console.WriteLine(ele.Source + ":" + ele.Message);

<Correct>

4. ' VBDim el As New EventLog()el.Log = "Application"For Each ele As EventLog In el.Entries Console.WriteLine(ele.Source + ": " + ele.Message)Next

// C#EventLog el = new EventLog();el.Log = "Application";foreach (EventLog ele in el.Entries) Console.WriteLine(ele.Source + ":" + ele.Message);

Explanation :To read an entire log file, create an instance of the EventLog class, specify the EventLog.Log property, and then iterate through EventLog.Entries. EventLog.Entries is an EventLogEntryCollection property containing EventLogEntry objects.

Objective:Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

Sub Objective(s):Manage an event log by using the System.Diagnostics namespace. Read from an event log.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 10 - Lesson 1

EventLog ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-US/library/system.diagnostics.eventlog(VS.80).aspx

Logging Application, Server, and Security EventsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-US/library/e6t4tk09.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 283 (536P_4.2.1_03)

_________________________________________________________________________________________________________________

Which of the following code samples correctly serializes the current date and time to an XML file?

1. ' VBDim fs As FileStream = New FileStream("SerializedDate.XML", FileMode.Create)fs.Write(XmlSerializer(System.DateTime.Now))

// C#FileStream fs = new FileStream("SerializedDate.XML", FileMode.Create);fs.Write(XmlSerializer(System.DateTime.Now));

2. ' VBDim fs As FileStream = New FileStream("SerializedDate.XML", FileMode.Create)Dim xs As XmlSerializer = New XmlSerializer(GetType(DateTime))xs.Serialize(fs, System.DateTime.Now)

// C#FileStream fs = new FileStream("SerializedDate.XML", FileMode.Create);XmlSerializer xs = new XmlSerializer(typeof(DateTime));xs.Serialize(fs, System.DateTime.Now);

<Correct>

3. ' VBDim fs As FileStream = New FileStream("SerializedDate.XML", FileMode.Create)Dim xs As XmlSerializer = New XmlSerializer()xs.Serialize(fs, System.DateTime.Now)

// C#FileStream fs = new FileStream("SerializedDate.XML", FileMode.Create);XmlSerializer xs = new XmlSerializer();xs.Serialize(fs, System.DateTime.Now);

4. ' VBDim xs As XmlSerializer = New XmlSerializer("SerializedDate.XML")xs.Serialize(System.DateTime.Now)

// C#XmlSerializer xs = new XmlSerializer("SerializedDate.XML");xs.Serialize(System.DateTime.Now);

Explanation :To perform XML serialization, first create a FileStream, TextWriter, or XmlWriter object to hold the serialized output. Then create an XmlSerializer object (in the System.Xml.Serialization namespace) by passing it the type of object you plan to serialize. Finally, call the XmlSerializer.Serialize method to serialize the object and output the results to the stream.

No overload for the XmlSerializer constructor takes zero parameters.

You can only pass an array of bytes to the FileStream.Write method.

You cannot declare a filename in the XmlSerializer constructor--you must always pass a Type object.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Control the serialization of an object into XML format by using the System.Xml.Serialization namespace. Serialize and deserialize objects into XML format by using the XmlSerializer class.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 2

Basic SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/4abbf6k0.aspx

XmlSerializer ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx

Introducing XML SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/182eeyhh.aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 3

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 284 (536P_4.7.3_02)

_________________________________________________________________________________________________________________

You are writing a security tool that aggregates firewall logs from client computers in your organization. IT will distribute your application to the approximately 2,000 client computers. Then the client portion of the application will run nightly to compress the %windir%\pfirewall.log file and copy it to a shared folder. After the file has been stored on the server, a separate server application will decompress and process the log files.

Which of the following code samples correctly compresses and stores the logfile?

1. ' VBDim readpath As String = Path.Combine(System.Environment.GetEnvironmentVariable("windir"), "pfirewall.log")Dim writepath As String = "\\server\folder"

Dim reader As FileStream = New FileStream(readpath, FileMode.Open)Dim writer As FileStream = New FileStream(writepath, FileMode.Create)Dim compress As DeflateStream = New DeflateStream(writer, CompressionMode.Compress)

compress.Write(reader.ReadToEnd())reader.Closecompress.Close

// C#string readpath = Path.Combine(System.Environment.GetEnvironmentVariable("windir"), "pfirewall.log");string writepath = @"\\server\folder";

FileStream reader = new FileStream(readpath, FileMode.Open);FileStream writer = new FileStream(writepath, FileMode.Create);DeflateStream compress = new DeflateStream(writer, CompressionMode.Compress);

compress.Write(reader.ReadToEnd());reader.Close(); compress.Close();

2. ' VBDim readpath As String = Path.Combine(System.Environment.GetEnvironmentVariable("windir"), "pfirewall.log")Dim writepath As String = "\\server\folder"

Dim reader As FileStream = New FileStream(readpath, FileMode.Open)Dim compress As DeflateStream = New DeflateStream(writepath, FileMode.Create, CompressionMode.Compress)Dim b(reader.Length) As Byte

reader.Read(b, 0, CType(reader.Length, Integer))reader.Close

compress.Write(b, 0, CType(b.Length, Integer))compress.Close

// C#string readpath = Path.Combine(System.Environment.GetEnvironmentVariable("windir"), "pfirewall.log");string writepath = @"\\server\folder";

FileStream reader = new FileStream(readpath, FileMode.Open);DeflateStream compress = new DeflateStream(writepath, FileMode.Create, CompressionMode.Compress);byte[] b = new byte[reader.Length];

reader.Read(b, 0, (int)reader.Length);reader.Close();

compress.Write(b, 0, (int)b.Length);compress.Close();

3. ' VBDim readpath As String = Path.Combine(System.Environment.GetEnvironmentVariable("windir"), "pfirewall.log")

Dim writepath As String = "\\server\folder"

Dim reader As FileStream = New FileStream(readpath, FileMode.Open)Dim writer As FileStream = New FileStream(writepath, FileMode.Create)Dim compress As DeflateStream = New DeflateStream(writer, CompressionMode.Compress)Dim b(reader.Length) As Byte

reader.Read(b, 0, CType(reader.Length, Integer))reader.Close

compress.Write(b, 0, CType(b.Length, Integer))compress.Close

// C#string readpath = Path.Combine(System.Environment.GetEnvironmentVariable("windir"), "pfirewall.log");string writepath = @"\\server\folder";

FileStream reader = new FileStream(readpath, FileMode.Open);FileStream writer = new FileStream(writepath, FileMode.Create);DeflateStream compress = new DeflateStream(writer, CompressionMode.Compress);byte[] b = new byte[reader.Length];

reader.Read(b, 0, (int)reader.Length);reader.Close();

compress.Write(b, 0, (int)b.Length);compress.Close();

<Correct>

4. ' VBDim readpath As String = Path.Combine(System.Environment.GetEnvironmentVariable("windir"), "pfirewall.log")Dim writepath As String = "\\server\folder"

Dim reader As FileStream = New FileStream(readpath, FileMode.Open)Dim compress As DeflateStream = New DeflateStream(writepath, FileMode.Create, CompressionMode.Compress)

compress.Write(reader.ReadToEnd())reader.Closecompress.Close

// C#string readpath = Path.Combine(System.Environment.GetEnvironmentVariable("windir"), "pfirewall.log");string writepath = @"\\server\folder";

FileStream reader = new FileStream(readpath, FileMode.Open);DeflateStream compress = new DeflateStream(writepath, FileMode.Create, CompressionMode.Compress);

compress.Write(reader.ReadToEnd());reader.Close(); compress.Close();

Explanation :To accomplish this task, you must create streams for both reading and writing the file. Then, based on the stream for writing the file, you can create a DeflateStream instance. Because DeflateStream requires a byte array, you must first read the contents of the file to be compressed into the byte array.

The FileStream class does not have a ReadToEnd method. Additionally, the DeflateStream.Write() method can only accept a byte array. Finally, you cannot provide a file path to the DeflateStream constructor. You must first construct a stream object.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Compress or decompress stream information in a .NET Framework application (refer System.IO.Compression namespace), and improve the security of application data by using isolated storage. (Refer System.IO.IsolatedStorage namespace) DeflateStream class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 3

DeflateStream ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.io.compression.deflatestream.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 285 (536P_2.3.5_03)

_________________________________________________________________________________________________________________

Which of the following creates an application domain in which all assemblies would have only the permissions the runtime has been configured to provide applications launched from the Internet zone?

1. ' VBDim z As Zone = New Zone(SecurityZone.Internet)Dim e As Evidence = New Evidence (z, Nothing)Dim d As AppDomain = AppDomain.CreateDomain("MyDomain", z)

// C#Zone z = {new Zone(SecurityZone.Internet)};Evidence e = new Evidence(z, null);AppDomain d = AppDomain.CreateDomain("MyDomain", z);

2. ' VBDim z As Zone = New Zone(SecurityZone.Internet)Dim d As AppDomain = AppDomain.CreateDomain("MyDomain", z)

// C#Zone z = {new Zone(SecurityZone.Internet)};AppDomain d = AppDomain.CreateDomain("MyDomain", z);

3. ' VBDim z As Object() = {New Zone (SecurityZone.Trusted)}Dim d As AppDomain = New AppDomain("MyDomain", z)

// C#object [] z = {new Zone(SecurityZone.Trusted)};AppDomain d = New AppDomain("MyDomain", z);

4. ' VBDim z As Object() = {New Zone (SecurityZone.Internet)}Dim e As Evidence = New Evidence (z, Nothing)Dim d As AppDomain = AppDomain.CreateDomain("MyDomain", e)

// C#object [] z = {new Zone(SecurityZone.Internet)};Evidence e = new Evidence(z, null);AppDomain d = AppDomain.CreateDomain("MyDomain", e);

<Correct>

Explanation :First, you must create an object array that includes a list of evidence. In this case, the only evidence you need to provide is a Zone object. Then create an Evidence object based on the object array. Finally, call the AppDomain.CreateDomain static method using the name of the new application domain and the evidence.

You cannot pass a Zone object to the AppDomain.CreateDomain static method. First, you must place the Zone object in an object array, and then create an Evidence object.

You cannot create an Evidence object using a Zone object. All evidence must be placed within an object array before calling the Evidence constructor.

You cannot pass an object array to the AppDomain.CreateDomain static method. First, you must create an Evidence object.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Create a unit of isolation for common language runtime in a .NET Framework application by using application domains. (Refer System namespace) Load assemblies into an application domain.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 8 - Lesson 1

EvidenceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/7y5x1hcd.aspx

AppDomain ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.appdomain.aspx

SecurityZone EnumerationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-US/library/system.security.securityzone.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 286 (536P_4.2.2_02)

_________________________________________________________________________________________________________________

Given the following class, which of the following files represents how an instance of that class would be serialized using the XmlSerializer class?

' VBPublic Class ShoppingCartItem <XmlAttribute()> Public productId As Int32 Public price As Decimal Public quantity As Int32 Public total As Decimal

Public Sub New() MyBase.New End SubEnd Class

// C#public class ShoppingCartItem { [XmlAttribute] public Int32 productId; public decimal price; public Int32 quantity; public decimal total;

public ShoppingCartItem() { }}

1. <?xml version="1.0" ?> <ShoppingCartItem productId="100" price="10.25" quantity="2" total="20.50"></ShoppingCartItem>

2. <?xml version="1.0" ?> <ShoppingCartItem productId="100"> <price>10.25</price> <quantity>2</quantity> <total>20.50</total> </ShoppingCartItem>

<Correct>

3. <?xml version="1.0" ?> <ShoppingCartItem> <price>10.25</price> <quantity>2</quantity> <total>20.50</total> </ShoppingCartItem>

4. <?xml version="1.0" ?> <ShoppingCartItem> <productId>100</productId> <price>10.25</price> <quantity>2</quantity> <total>20.50</total> </ShoppingCartItem>

Explanation :By default, XmlSerializer serializes all members as XML elements. The productId member has the XmlAttribute attribute, which causes it to be serialized as an attribute.

XmlSerializer serializes members as attributes only if each member has the XmlAttribute attribute.

XmlSerializer would ignore the productId member only if it had the XmlIgnore attribute.

The productId member has the XmlAttribute attribute, which causes it to be serialized as an attribute.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Control the serialization of an object into XML format by using the System.Xml.Serialization namespace. Control serialization by using serialization attributes.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 2

Basic SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/4abbf6k0.aspx

XmlSerializer ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx

How to: Qualify XML Element and XML Attribute NamesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/xzys86e8.aspx

Introducing XML SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/182eeyhh.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 287 (536P_7.2.1_04)

_________________________________________________________________________________________________________________

Which of the following code samples draws this graphic?

1. ' VBDim p As New Pen(Color.Red, 7)p.DashStyle = DashStyle.DotDim bm As Bitmap = New Bitmap(400, 400)Dim g As Graphics = Graphics.FromImage(bm)g.DrawPie(p, 0, 0, 350, 350, 290, 90)

// C#Pen p = new Pen(Color.Red, 7);p.DashStyle = DashStyle.Dot;Bitmap bm = new Bitmap(400, 400);Graphics g = Graphics.FromImage(bm);g.DrawPie(p, 0, 0, 350,350, 290, 90);

<Correct>

2. ' VBDim p As New Pen(Color.Red, 7)p.DashStyle = DashStyle.DashDim bm As Bitmap = New Bitmap(400, 400)Dim g As Graphics = Graphics.FromImage(bm)g.DrawPie(p, 0, 0, 350, 350, 290, 90)

// C#Pen p = new Pen(Color.Red, 7);p.DashStyle = DashStyle.Dash;Bitmap bm = new Bitmap(400, 400);Graphics g = Graphics.FromImage(bm);g.DrawPie(p, 0, 0, 350,350, 290, 90);

3. ' VBDim p As New Pen(Color.Red, 7)p.DashStyle = DashStyle.DotDim bm As Bitmap = New Bitmap(400, 400)Dim g As Graphics = Graphics.FromImage(bm)g.DrawArc(p, 0, 0, 350, 350, 290, 90)

// C#Pen p = new Pen(Color.Red, 7);p.DashStyle = DashStyle.Dot;Bitmap bm = new Bitmap(400, 400);Graphics g = Graphics.FromImage(bm);g.DrawArc(p, 0, 0, 350,350, 290, 90);

4. ' VBDim p As New Pen(Color.Red, 7)p.DashStyle = DashStyle.DashDim bm As Bitmap = New Bitmap(400, 400)Dim g As Graphics = Graphics.FromImage(bm)g.DrawArc(p, 0, 0, 350, 350, 290, 90)

// C#Pen p = new Pen(Color.Red, 7);p.DashStyle = DashStyle.Dash;Bitmap bm = new Bitmap(400, 400);Graphics g = Graphics.FromImage(bm);g.DrawArc(p, 0, 0, 350,350, 290, 90);

Explanation :To create the graphic, you must use a Pen object with the Pen.DashStyle property set to DashStyle.Dot. The shape shown is a pie, and it must be created with the Graphics.DrawPie method.

Using DashStyle.Dash creates a different pattern, one with dashes instead of dots.

Graphics.DrawArc creates only an arc shape, not a pie shape.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the user interface of a .NET Framework application by using the System.Drawing namespace. Enhance the user interface of a .NET Framework application by using brushes, pens, colors, and fonts.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 6 - Lesson 1

GDI+ Pen SampleMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/1z5bhdx7.aspx

DashStyle EnumerationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.drawing.drawing2d.dashstyle.aspx

Pen.DashPattern PropertyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/library/w4x62se4(en-us,vs.80).aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 6 - Lesson 3

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 288 (536P_5.4.6_01)

_________________________________________________________________________________________________________________

You are writing an assembly that verifies files have not been modified since they were initially scanned. Which classes could you use to create a unique identifier for a file? (Choose all that apply.)

1. DES

2. SHA256 <Correct>

3. TripleDES

4. RSACryptoServiceProvider

5. RC2

6. DSACryptoServiceProvider

7. MD5<Correct>

8. RijndaelManaged

Explanation :MD5 and SHA256 are hashing algorithms, which you can use to generate a unique key based on the contents of a file.

RijndaelManaged, DES, RC2, and TripleDES are all symmetric encryption classes.

DSACryptoServiceProvider provides asymmetric digital signatures.

RSACryptoServiceProvider provides asymmetric encryption.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Encrypt, decrypt, and hash data by using the System.Security.Cryptography classes. (Refer System.Security.Cryptography namespace) MD5 class and MD5CryptoServiceProvider class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 12 - Lesson 3

CryptoConfig ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.cryptography.cryptoconfig.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 289 (536P_1.2.10_01)

_________________________________________________________________________________________________________________

Which of the following collections can be accessed by an index? (Choose all that apply.)

1. An implementation of IList <Correct>

2. SortedList <Correct>

3. BitArray <Correct>

4. An implementation of IDictionary

Explanation :SortedList, an implemention of IList, and BitArray can all be accessed by using an index.

To access elements in an implementation of IDictionary, use a key.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage a group of associated data in a .NET Framework application by using collections. (Refer System.Collections namespace) BitArray class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 4 - Lesson 4

BitArray ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/x3we7ff2(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 290 (536P_7.3.5_04)

_________________________________________________________________________________________________________________

Which of the following code samples would produce the largest text file?

1. ' VBDim swUtf16 As StreamWriter = New StreamWriter("utf16.txt", False, Encoding.Unicode)swUtf16.WriteLine("Hello, World!")swUtf16.Close

// C#StreamWriter swUtf16 = new StreamWriter("utf16.txt", false, Encoding.Unicode);swUtf16.WriteLine("Hello, World!");swUtf16.Close();

2. ' VBDim swUtf32 As StreamWriter = New StreamWriter("utf32.txt", False, Encoding.UTF32)swUtf32.WriteLine("Hello, World!")swUtf32.Close

// C#StreamWriter swUtf32 = new StreamWriter("utf32.txt", false, Encoding.UTF32);swUtf32.WriteLine("Hello, World!");swUtf32.Close();

<Correct>

3. ' VBDim swUtf8 As StreamWriter = New StreamWriter("utf8.txt", False, Encoding.UTF8)swUtf8.WriteLine("Hello, World!")swUtf8.Close

// C#StreamWriter swUtf8 = new StreamWriter("utf8.txt", false, Encoding.UTF8);swUtf8.WriteLine("Hello, World!");swUtf8.Close();

4. ' VBDim swUtf7 As StreamWriter = New StreamWriter("utf7.txt", False, Encoding.UTF7)swUtf7.WriteLine("Hello, World!")swUtf7.Close

// C#StreamWriter swUtf7 = new StreamWriter("utf7.txt", false, Encoding.UTF7);swUtf7.WriteLine("Hello, World!");swUtf7.Close();

Explanation :The UTF-32 encoding format creates the largest file sizes because it uses 32-bit characters.

UTF-16 uses 16-bit characters.

UTF-8 uses 8-bit characters.

UTF-7 uses 7-bit characters.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.RegularExpressions namespace) Encode text by using Encoding classes.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development

Foundation, MicrosoftChapter 3 - Lesson 2

Encoding.UTF32 PropertyMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-US/library/system.text.encoding.utf32.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 291 (536P_7.2.3_01)

_________________________________________________________________________________________________________________

Which of the following points is closest to the upper-right corner in a 100-by-100 pixel graphic?

1. New Point(90, 10) <Correct>

2. New Point(10, 10)

3. New Point(10, 90)

4. New Point(90, 90)

Explanation :90, 10 is near the upper-right corner. The first coordinate describes the horizontal position relative to the upper-left corner. The second coordinate describes the vertical position relative to the upper-left corner.

10, 90 is near the lower-left corner.

10, 10 is near the upper-left corner.

90, 90 is near the lower-right corner.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the user interface of a .NET Framework application by using the System.Drawing namespace. Enhance the user interface of a .NET Framework application by using shapes and sizes.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 6 - Lesson 1

Point StructureMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.drawing.point.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 292 (536P_4.2.1_02)

_________________________________________________________________________________________________________________

You are responsible for an internal database application. Your organization would now like to selectively send information from the database to external customers using XML documents. Currently, you have custom classes that store this information. Which class should you use to write the XML documents?

1. TextWriter

2. StreamWriter

3. XmlSerializer <Correct>

4. BinaryFormatter

Explanation :XmlSerializer is the most efficient way to write an object to an XML document.

BinaryFormatter would write the object to disk, but it would not use XML.

TextWriter and StreamWriter could be used to create XML documents, but it would be very inefficient because you would have to create the XML formatting manually.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Control the serialization of an object into XML format by using the System.Xml.Serialization namespace. Serialize and deserialize objects into XML format by using the XmlSerializer class.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 2

Introducing XML SerializationMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/182eeyhh.aspx

XmlSerializer ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 5 - Lesson 3

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 293 (536P_7.3.2_01)

_________________________________________________________________________________________________________________

You need to reformat phone numbers typed by users into a standard format. What is the most efficient way to reformat phone numbers?

1. String.Format

2. String.Replace

3. Regex.Replace <Correct>

4. StringBuilder.Replace

Explanation :Regular expressions are the most efficient way to reformat data.

Although you could use String.Replace, StringBuilder.Replace, or String.Format to reformat a phone number, it would require many lines of code and would be very error-prone.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Enhance the text handling capabilities of a .NET Framework application (refer System.Text namespace), and search, modify, and control text in a .NET Framework application by using regular expressions. (Refer System.RegularExpressions namespace) Regex class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 3 - Lesson 1

Regular Expression ClassesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/30wbz966.aspx

Regex ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 294 (536P_4.7.2_01)

_________________________________________________________________________________________________________________

How would you rewrite the following piece of code to store the information in isolated storage, isolated by user, domain, and assembly? Assume all code samples use the System.IO and System.IO.IsolatedStorage namespaces.

' VBDim sw As StreamWriter = File.CreateText("mytemp.txt")sw.WriteLine("Hello, world!")sw.Close()

// C#StreamWriter sw = File.CreateText("mytemp.txt");sw.WriteLine("Hello, world!");sw.Close();

1. ' VBDim sw As StreamWriter = File.CreateText(New IsolatedStorage("mytemp.txt"))sw.WriteLine("Hello, world!")sw.Close()

// C#StreamWriter sw = File.CreateText(new IsolatedStorage("mytemp.txt"));sw.WriteLine("Hello, world!");sw.Close();

2. ' VBDim sw As StreamWriter = New StreamWriter(New IsolatedStorageFileStream("mytemp.txt",FileMode.CreateNew))sw.WriteLine("Hello, world!")sw.Close()

// C#StreamWriter sw = new StreamWriter(new IsolatedStorageFileStream("mytemp.txt", FileMode.CreateNew));sw.WriteLine("Hello, world!");sw.Close();

<Correct>

3. ' VBDim sw As StreamWriter = File.CreateIsolatedStorageText("mytemp.txt")sw.WriteLine("Hello, world!")sw.Close()

// C#StreamWriter sw = File.CreateIsolatedStorageText("mytemp.txt");sw.WriteLine("Hello, world!");sw.Close();

4. ' VBDim sw As IsolatedStorageFileStream = New IsolatedStorageFileStream("mytemp.txt",FileMode.CreateNew)sw.WriteLine("Hello, world!")sw.Close()

// C#IsolatedStorageFileStream sw = new IsolatedStorageFileStream("mytemp.txt", FileMode.CreateNew);sw.WriteLine("Hello, world!");sw.Close();

Explanation :The easiest way to rewrite code that uses StreamWriter objects to use isolated storage is to use the overloaded StreamWriter constructor that accepts an IsolatedStorageFileSystem object.

IsolatedStorageFileSystem does not have a WriteLine method.

You cannot pass an IsolatedStorage object to the StreamWriter constructor.

The File class does not have a static CreateIsolatedStorageText method.

Objective:Implementing serialization and input/output functionality in a .NET Framework application

Sub Objective(s):Compress or decompress stream information in a .NET Framework application (refer System.IO.Compression namespace), and improve the security of application data by using isolated storage. (Refer System.IO.IsolatedStorage namespace) IsolatedStorageFileStream class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 2 - Lesson 4

IsolatedStorageFileStream ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/zx8yhe22(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 295 (536P_1.2.11_01)

_________________________________________________________________________________________________________________

Which of the following is a last-in, first-out collection?

1. Queue

2. Hashtable

3. Stack <Correct>

4. List

Explanation :The Stack collection is a last-in, first-out collection.

The Queue class is a first-in, first-out collection.

The List class does not support ordered retrieval.

The Hashtable class does not support ordered retrieval.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage a group of associated data in a .NET Framework application by using collections. (Refer System.Collections namespace) Stack class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 4 - Lesson 2

Stack Generic ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/3278tedw.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 296 (536P_6.3.4_01)

_________________________________________________________________________________________________________________

You need to perform late binding to an assembly that you cannot identify at compile time. How can you provide custom control of member selection and invocation?

1. Implement the System.Reflection.IReflect interface.

2. Create a custom class that inherits from System.Reflection.Binder. <Correct>

3. Create a custom class that inherits from System.Reflection.Module.

4. Implement the System.Reflection.ICustomAttributeProvider interface.

Explanation :You can have custom control of member selection and invocation using the System.Reflection.Binder class. This gives you the ability to perform highly-customized late-binding, which is useful if you do not know an object's type at compile time. This typically only happens when the user is providing a type library.

The IReflect interface allows objects to return MemberInfo objects that represent an object, and it does not facilitate late binding.

The ICustomAttributeProvider interface provides custom attributes for reflection objects that support them, and it does not facilitate late binding.

The Module class performs reflection on a module, but inheriting from it does not facilitate late binding.

Objective:Implementing interoperability, reflection, and mailing functionality in a .NET Framework application

Sub Objective(s):Implement reflection functionality in a .NET Framework application (refer System.Reflection namespace), and create metadata, Microsoft intermediate language (MSIL), and a PE file by using the System.Reflection.Emit namespace. Binder class and BindingFlags

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 14 - Lesson 3

Dynamically Loading and Using TypesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/k3a58006.aspx

Binder ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.reflection.binder.aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 14 - Lesson 4

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 297 (536P_1.1.1_05)

_________________________________________________________________________________________________________________

Which of the following types could store the numeric value -5? (Choose all that apply.)

1. float <Correct>

2. uint

3. double <Correct>

4. int <Correct>

5. decimal <Correct>

6. long <Correct>

7. ulong

Explanation :The types decimal, double, float, int, and long can all store negative integers.

The types uint and ulong are unsigned, and therefore can only store zero and positive numbers.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Value types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 1

.NET Framework Class Library OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/hfa3fa08.aspx

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 3

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 298 (536P_5.5.2_02)

_________________________________________________________________________________________________________________

You are a developer working as part of a team to develop an internal application. Another developer has created a custom authentication and authorization system for the application, and implemented a database to store users and roles.

You are responsible for writing a single method for the application. Only users with the name Bob (who must be in the Manager role) or Louise (who must be in the Supervisor role) should be able to run the method. Which of the following meets this requirement?

1. ' VBDim p1 As New PrincipalPermission("Bob", "Manager")Dim p2 As New PrincipalPermission("Louise", "Supervisor")p1.Intersect()p2.Intersect()

// C#PrincipalPermission p1 = new PrincipalPermission("Bob", "Manager");PrincipalPermission p2 = new PrincipalPermission("Louise", "Supervisor");p1.Intersect();p2.Intersect();

2. ' VBDim p1 As New PrincipalPermission("Bob", "Manager")Dim p2 As New PrincipalPermission("Louise", "Supervisor")p1.Intersect(p2).Demand()

// C#PrincipalPermission p1 = new PrincipalPermission("Bob", "Manager");PrincipalPermission p2 = new PrincipalPermission("Louise", "Supervisor");(p1.Intersect(p2)).Demand();

3. ' VBDim p1 As New PrincipalPermission("Bob", "Manager")Dim p2 As New PrincipalPermission("Louise", "Supervisor")p1.Demand()p2.Demand()

// C#PrincipalPermission p1 = new PrincipalPermission("Bob", "Manager");PrincipalPermission p2 = new PrincipalPermission("Louise", "Supervisor");p1.Demand();p2.Demand();

4. ' VBDim p1 As New PrincipalPermission("Bob", "Manager")Dim p2 As New PrincipalPermission("Louise", "Supervisor")p1.Union(p2).Demand()

// C#PrincipalPermission p1 = new PrincipalPermission("Bob", "Manager");PrincipalPermission p2 = new PrincipalPermission("Louise", "Supervisor");(p1.Union(p2)).Demand();

<Correct>

Explanation :To demand the current user meet one of multiple permission requirements, create multiple PrincipalPermission objects, call the PrincipalPermission.Union method to combine the requirements, and then call PrincipalPermission.Demand.

Calling PrincipalPermission.Demand for multiple sets of credentials would require users to meet all the requirements. Because a single user could not be both "Bob" and "Louise", the security check would always fail.

PrincipalPermission.Intersect creates a PrincipalPermission object that contains only the security requirements that both PrincipalPermission objects have in common. Because a single user could not be both "Bob" and "Louise", the security check would always fail.

PrincipalPermission.Intersect requires another PrincipalPermission object as a parameter, so this code sample would not compile properly.

Objective:Improving the security of the .NET Framework applications by using the .NET Framework 2.0 security features

Sub Objective(s):Control permissions for resources by using the System.Security.Permission classes. (Refer System.Security.Permission namespace) PrincipalPermission class

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 11 - Lesson 3

PrincipalPermission ClassMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/system.security.permissions.principalpermission.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 299 (536P_7.1.3_04)

_________________________________________________________________________________________________________________

You are creating a Windows Service. Which of the following security contexts should you specify for the Account property to reduce security risks by running as a nonprivileged user while presenting anonymous credentials to network resources?

1. NetworkService

2. LocalSystem

3. LocalService <Correct>

4. User

Explanation :LocalService runs in the context of an account that acts as a nonprivileged user on the local computer, and it presents anonymous credentials to any remote server.

User causes the system to prompt for a valid user name and password when the service is installed, and it runs in the context of an account specified by a single user on the network.

LocalSystem runs in the context of an account that provides extensive local privileges, and it presents the computer's credentials to any remote server.

NetworkService runs in the context of an account that acts as a nonprivileged user on the local computer, and it presents the computer's credentials (not a specific user's credentials) to any remote server.

Objective:Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application

Sub Objective(s):Format data based on culture information. (Refer System.Globalization namespace) Format number values based on the culture.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 16 - Lesson 1

How to: Specify the Security Context for ServicesMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/0x72fzyf(VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 300 (536P_1.2.2_03)

_________________________________________________________________________________________________________________

You are creating a new collection type that must be iterated using a for-each loop. Which of the following interfaces should you implement? (Choose all that apply.)

1. IEnumerable <Correct>

2. ICollection

3. IDictionaryEnumerator <Correct>

4. IDictionary

5. IEqualityComparer

Explanation :You must implement IEnumerable or IDictionaryEnumerator when creating a collection for use in a for-each loop.

The ICollection interface is the base interface for classes in the System.Collections namespace. It does not support for-each loops.

The IDictionary interface is the base interface for nongeneric collections of key/value pairs. It does not support for-each loops.

The IEqualityComparer interface supports only equality comparisons and cannot be used in for-each loops.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage a group of associated data in a .NET Framework application by using collections. (Refer System.Collections namespace) Collection interfaces

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 4 - Lesson 3

IEnumerable InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/h1x9x1b1(en-US,VS.80).aspx

IDictionaryEnumerator InterfaceMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/ebe1zk2c(en-US,VS.80).aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 301 (536P_1.1.2_03)

_________________________________________________________________________________________________________________

What is the output of the following code?

' VBDim s1 As String = "Hello" Dim s2 As String = s1 Console.WriteLine(s1 = s2) Console.WriteLine(CType(s1, Object) = CType(s2, Object))

// C#string s1 = "Hello";string s2 = s1;Console.WriteLine(s1 == s2);Console.WriteLine((object)s1 == (object)s2);

1. TrueTrue

<Correct>

2. TrueFalse

3. FalseTrue

4. FalseFalse

Explanation :The first comparison is true because the values in both s1 and s2 are equal. The second comparison is true because string is a reference type, and creating a copy of a reference type creates two equal references.

Objective:Developing applications that use system types and collections

Sub Objective(s):Manage data in a .NET Framework application by using the .NET Framework 2.0 system types. (Refer System namespace) Reference types

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 1 - Lesson 2

Common Type System OverviewMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/2hf02550.aspx

Microsoft .NET Framework 2.0-Application Development FoundationQuestion Number (ID) : 302 (536P_2.3.5_01)

_________________________________________________________________________________________________________________

Which of the following creates an application domain and launches a process that has already been referenced within the project? (Choose all that apply.)

1. ' VBDim d As AppDomain = AppDomain.CreateDomain("Domain")Dim an As AssemblyName = New AssemblyName("Assembly")d.ExecuteAssembly(an, Nothing, Nothing)

// C#AppDomain d = AppDomain.CreateDomain("Domain");AssemblyName an = new AssemblyName("Assembly");d.ExecuteAssembly (an, null, null);

2. ' VBDim d As AppDomain = AppDomain.CreateDomain("Domain")d.ExecuteAssembly("Assembly")

// C#AppDomain d = AppDomain.CreateDomain("Domain");d.ExecuteAssembly("Assembly");

3. ' VBDim d As AppDomain = AppDomain.CreateDomain("Domain")d.ExecuteAssemblyByName("Assembly")

// C#AppDomain d = AppDomain.CreateDomain("Domain");d.ExecuteAssemblyByName("Assembly");

<Correct>

4. ' VBDim d As AppDomain = AppDomain.CreateDomain("Domain")Dim an As AssemblyName = New AssemblyName("Assembly")d.ExecuteAssemblyByName(an, Nothing, Nothing)

// C#AppDomain d = AppDomain.CreateDomain("Domain");AssemblyName an = new AssemblyName("Assembly");d.ExecuteAssemblyByName(an, null, null);

<Correct>

Explanation :To launch an assembly that is referenced within a project inside a new application domain, you must first create an instance of the AppDomain class, and then call that object's ExecuteAssemblyByName method to launch the assembly. ExecuteAssemblyByName accepts either a string with the name of the assembly or an AssemblyName object.

The AppDomain.ExecuteAssembly method launches an assembly based on the assembly's file name. It should be used only when the assembly is not referenced in a project.

Objective:Implementing service processes, threading, and application domains in a .NET Framework application

Sub Objective(s):Create a unit of isolation for common language runtime in a .NET Framework application by using application domains. (Refer System namespace) Load assemblies into an application domain.

References :

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0--Application Development Foundation, MicrosoftChapter 8 - Lesson 1

Creating and Configuring Application DomainsMSDN Library, Microsoft

Link: http://msdn2.microsoft.com/en-us/library/wxtzfyw3.aspx

Programming with Application DomainsMSDN Library, MicrosoftLink: http://msdn2.microsoft.com/en-us/library/yk22e11a.aspx