You have the following code (line numbers are included for reference only):
You need to ensure that if an exception occurs, the exception will be logged.
Which code should you insert at line 28?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Explanation:
* XmlWriterTraceListener
Directs tracing or debugging output as XML-encoded data to a TextWriter or to a Stream, such as a
FileStream.
* TraceListener.TraceEvent Method (TraceEventCache, String, TraceEventType, Int32) Writes trace and event
information to the listener specific output.
Syntax:
[ComVisibleAttribute(false)]
public virtual void TraceEvent(
TraceEventCache eventCache,
string source,
TraceEventType eventType,
int id
)
Same as https://www.aiotestking.com/microsoft/which-code-should-you-insert-at-line-28-2/
The correct answer seems to be C
Answer B produces the following:
===========================
0
3
0
8
BARHOOOOM
Attempted to divide by zero.
===========================
Answer C produces the following:
===========================
2147614738
3
0
2
BARHOOOOM
===========================
0
7
B –> Information
C –> Error
0
1
here B is correct. In above link, C is correct
3
0
yes, C gives HResult of -2146233088 it’s not valid for EventInstance(ex.HResult
0
0
A – incorrect – missing listener
B – works but can fail due to missing write permissions
C – incorrect – ArgumentOutOfRangeException, because EventInstance first argument is instanceId and -2146233088 is not a valid value
D – correct
3
0
not quite. D works only if application has permissions.
I believe that B is correct.
0
1