How should you complete the relevant code?

Posted by: Pdfprep Category: 70-483 Tags: , ,

DRAG DROP

You develop an application that displays information from log files when errors occur. The application will prompt the user to create an error report that sends details about the error and the session to the administrator.

When a user opens a log file by using the application, the application throws an exception and closes.

The application must preserve the original stack trace information when an exception occurs during this process.

You need to implement the method that reads the log files.

How should you complete the relevant code? (To answer, drag the appropriate code segments to the correct locations in the answer area. Each code segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.)

Answer:

Explanation:

StreamReader – Implements a TextReader that reads characters from a byte stream in a particular encoding.

Reference: http://msdn.microsoft.com/en-us/library/system.io.streamreader(v=vs.110).aspx

Once an exception is thrown, part of the information it carries is the stack trace. The stack trace is a list of the method call hierarchy that starts with the method that throws the exception and ends with the method that catches the exception. If an exception is re-thrown by specifying the exception in the throw statement, the stack trace is restarted at the current method and the list of method calls between the original method that threw the exception and the current method is lost. To keep the original stack trace information with the exception, use the throw statement without specifying the exception.

Reference: http://msdn.microsoft.com/en-us/library/ms182363(v=vs.110).aspx

Incorrect:

StringReader – Implements a TextReader that reads from a string.

Reference: http://msdn.microsoft.com/en-us/library/system.io.stringreader(v=vs.110).aspx

Leave a Reply

Your email address will not be published.