- A process is an executing application, with a unique identifier to differentiate it from other processes. Processes are mechanisms that allow applications to run safely isolated from other applications.
- The two primary classes for directing output from an application are Debug and Trace. The Trace class listener object is enabled by default in .NET applications. Listener objects are the mechanisms by which Debug and Trace output can be handled. The XmlTextWriterListener allows Debug and Trace output to be written with detailed information stored in predefined Xml attributes. The Assert method of both the Debug and Trace classes forces an examination of a condition, and based on the evaluation, it will let the application continue to run or break into the debugger. The Break method of the Debugger class causes an application's execution to stop at a specific breakpoint.
- The Start method of the Process class allows applications to be started programmatically. The GetProcesses method of the Process class returns information about all running processes on a machine. If information about a specific process is needed (as opposed to general information about all processes), the GetProcessByName or GetProcessById methods should be used.
- To pass values into the constructor of the Main method, command-line arguments can be specified.
- The StackTrace object provides detailed information about the state of execution for a given application. StackFrame objects make up the StackTrace object. However, they are intended to support the .NET Framework and should not be used directly.
- Because String objects are reference types, they pose a potential security vulnerability when used to store passwords. In the current version of the .NET Framework, the SecureString class is provided to manage sensitive data.
- PerformanceCounter objects are mechanisms that allow specific measurement of an application's resource utilization.
Questiosn and Answers
1.
Which method will start an instance of Internet Explorer and specify the URL "http://www.microsoft.com" for it to navigate to?
1.
Process.Start("iexplore.exe");
2.
Process.Start("InternetExplorer, http://www.microsoft.com");
3.
Process.Start("iexplore.exe", "http://www.microsoft.com");
4.
Process.Run("iexplore.exe", "http://www.microsoft.com");
Image from book
2.
Assume that the following code was just run. Which answer illustrates how to specifically output the current StackTrace to the console window?
' VB
Try
Dim x as Int32 = 1
x = x - 1
Dim i as Int32 = 10 / x
Catch Problem as DivideByZeroException
'This is the code to fill in
End Try
// C#
try
{
Int32 x = 1;
x--;
Int32 i = 10 / x;
}
catch (DivideByZeroException Problem)
{
//This is the code to fill in
}
1.
Debug.Assert(Problem.Message);
2.
Debug.Assert(false, Problem.ToString();
3.
Console.WriteLine(Problem.ToString());
4.
Console.WriteLine(Problem.StackTrace.ToString());
Image from book
3.
Which method is appropriate to specify a password when starting a process?
1.
Use a String variable that contains the password.
2.
Use an Array of type Char
3.
Use an Array of type String coupled with an Integer reference to the password's index in the array.
4.
Use a SecureString object.
Image from book
Answers
1.
Correct Answer: C
1.
Incorrect: Although this method will start an instance of Internet Explorer, it will not navigate to any specific page.
2.
Incorrect: This will treat all of the input as one value and result in an error.
3.
Correct: This method specifies the application name as the first parameter and the correct URL as the only command-line argument.
4.
Incorrect: Process.Run is not a method of the Process class.
2.
Correct Answer: D
1.
Incorrect: Debug.Assert takes an expression to evaluate, not a String.
2.
Incorrect: This method will cause the assertion to fail but will not output the StackTrace. Instead, it will output the entire exception. Furthermore, it will not direct the output to the console window.
3.
Incorrect: This call will output the StackTrace to the console window, but it will output the entire exception as well.
4.
Correct: This method specifically outputs the StackTrace and nothing else, and it writes the output only to the console window.
3.
Correct Answer: D
1.
Incorrect: For security reasons, a String object should not be used for passwords.
2.
Incorrect: A Char array, although different from a String, fails to provide an optimal level of security..
3.
Incorrect: Using one value of a String array has the same effect as using an individual string.
4.
Correct: A System.Security.SecureString is the correct type for the ProcessStartInfo object's Password property. It affords the highest level of security of the methods listed.
Publish Post
No comments:
Post a Comment