How should you complete the relevant code?

DRAG DROP
You are developing an ASP.NET MVC application.
You must handle any first chance exceptions that the application throws. The exception handler has the
following requirements:
Catch any first chance exceptions thrown by the default app domain.
Display the name of the app domain that caused the exception.
Display the message for the exception.
You need to implement the exception handler.
How should you complete the relevant code? To answer, drag the appropriate code segment to the correct
location or locations. Each code segments 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.
Select and Place:

DRAG DROP
You are developing an ASP.NET MVC application.
You must handle any first chance exceptions that the application throws. The exception handler has the
following requirements:
Catch any first chance exceptions thrown by the default app domain.
Display the name of the app domain that caused the exception.
Display the message for the exception.
You need to implement the exception handler.
How should you complete the relevant code? To answer, drag the appropriate code segment to the correct
location or locations. Each code segments 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.
Select and Place:

Answer:

Explanation:
Note: Example codewith inline lambda expression for the handler:
class Example
{
static void Main()
{
AppDomain.CurrentDomain.FirstChanceException +=
(object source, FirstChanceExceptionEventArgs e) =>
{
Console.WriteLine(“FirstChanceException event raised in {0}: {1}”,
AppDomain.CurrentDomain.FriendlyName, e.Exception.Message);
};
Example with handler defined separately:
static void FirstChanceHandler(object source, FirstChanceExceptionEventArgs e)
{
Console.WriteLine(“FirstChanceException event raised in {0}: {1}”,
AppDomain.CurrentDomain.FriendlyName, e.Exception.Message);
}
https://docs.microsoft.com/en-us/dotnet/framework/app-domains/how-to-receive-first-chanceexception-notifications



Leave a Reply 3

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