Which two actions should you perform?

An application is throwing unhandled NullReferenceException and FormatException errors. The
stack trace shows that the exceptions occur in the GetWebResult() method.
The application includes the following code to parse XML data retrieved from a web service. (Line
numbers are included for reference only.)

You need to handle the exceptions without interfering with the existing error-handling
infrastructure.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose
two.)

An application is throwing unhandled NullReferenceException and FormatException errors. The
stack trace shows that the exceptions occur in the GetWebResult() method.
The application includes the following code to parse XML data retrieved from a web service. (Line
numbers are included for reference only.)

You need to handle the exceptions without interfering with the existing error-handling
infrastructure.
Which two actions should you perform? (Each correct answer presents part of the solution. Choose
two.)

A.
Option A

B.
Option B

C.
Option C

D.
Option D

Explanation:
A: The TryParse method is like the Parse method, except the TryParse method does not throw an
exception if the conversion fails. It eliminates the need to use exception handling to test for a
FormatException in the event that s is invalid and cannot be successfully parsed.
C: UnhandledException event handler
If the UnhandledException event is handled in the default application domain, it is raised there for
any unhandled exception in any thread, no matter what application domain the thread started in. If
the thread started in an application domain that has an event handler for UnhandledException, the
event is raised in that application domain.



Leave a Reply 7

Your email address will not be published. Required fields are marked *


Lord Vader

Lord Vader

D would do it by itself but it is requesting 2 actions.
B no overload of the int class exists called parseoptions

so A and C as they are both complement each other

abc

abc

read the requirement – You need to handle the exceptions without interfering with the existing error-handling infrastructure.

Wrapping in the try catch would invalidate that requirement.

Miroslav

Miroslav

What about NullReferenceException? What if result or result.Element(“response”) is null?

abc

abc

For that we register the event handler.

AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnExceptionThrown);

when an exception is thrown that isn’t handled it will come here.

Andrii

Andrii

Subscribing to UnhandledException is not interfering with exciting error handling infrastructure? What a stupid question.