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
)
Answer D
… as simple as it gets
0
0
Answer B
(you’re not sure the Source=”Apllication” exists)
0
0
Correct!
0
0
Difference between 120 and 160?
0
0
Different methods are used. Check the input parameters on TraceEvent and WriteLine
https://msdn.microsoft.com/en-us/library/system.diagnostics.xmlwritertracelistener(v=vs.110).aspx
0
0
120,138 and 160 similar
0
0
A is wrong, because TraceSource must have listeners
(https://docs.microsoft.com/ru-ru/dotnet/api/system.diagnostics.tracesource?view=netframework-4.8)
C and D are wrong because “An event log source should not be created and immediately used.” and application reuquires admin permissions to use it
(https://docs.microsoft.com/ru-ru/dotnet/api/system.diagnostics.eventlog?view=netframework-4.8)
So the correct answer is B
https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.xmlwritertracelistener?redirectedfrom=MSDN&view=netframework-4.8
0
0