Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need to handle the exception and creating the crash report with log and dmp file with an best approach will you please suggest me the topics or methods to do in WPF&c#.

What I have tried:

i tried try and catch the exception to prevent from crash.
Posted
Updated 22-Mar-21 7:20am
Comments
PIEBALDconsult 22-Mar-21 10:52am    
Show your code (Improve Question) and maybe we can make suggestions.
[no name] 22-Mar-21 13:09pm    
"Log" is a broad term. You can start by hooking up an exception handler. You could write to the Windows app log. This handler allows one to continue (e.Handled).

https://docs.microsoft.com/en-us/dotnet/api/system.windows.application.dispatcherunhandledexception?view=net-5.0

1 solution

Capture the exact method and its location where the exception occurs. Log the base exception, as this will be the exception that caused any subsequent exceptions. Serialize the information using the JSON serialier to a JSON file. This will persist the information. Then you can deserialize the JSON file and present it as a HTML report.

Alternatively, save the exception as XML and use XSLT to transform the XML content into a HTML report.

See:
Displaying XML Files with CSS/XSLT


See:
Displaying HTML in a WPF RichTextBox


See:
Working with JSON in C# & VB
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900