exam questions

Exam 70-486 All Questions

View all questions & answers for the 70-486 exam

Exam 70-486 topic 1 question 105 discussion

Actual exam question from Microsoft's 70-486
Question #: 105
Topic #: 1
[All 70-486 Questions]

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:

Show Suggested Answer Hide Answer
Suggested Answer:
Note: Example code with 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);
}
Reference:
https://docs.microsoft.com/en-us/dotnet/framework/app-domains/how-to-receive-first-chance-exception-notifications

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
tanujgyan
5 years, 2 months ago
Reference: https://docs.microsoft.com/en-us/dotnet/api/system.appdomain.firstchanceexception?view=netcore-3.1
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...