c# - Globally catch exceptions in a WPF application? -
We can throw exceptions at runtime in part of where we are applying a WPF, I can catch any unrestricted exceptions worldwide And want to log them in, but otherwise continue the program execution, as if nothing happened (like resuming the error of VB just like it)
Is it possible in C # And if so, do I need to put exception handling code?
Currently I can not get any number, where I can hold try / around and all the exceptions that may arise And yet I would have left anything that was executed because of the catch. Or am I thinking wrongly in the wrong directions here?
ETA: Due to the many people given below it has been told: This application is not meant to control nuclear power plants. If this crashes it is not a big deal, but random exceptions that are mostly UI-related, there is a nuisance in context where it will be used. Some of them (and probably still) were and since it uses a plugin architecture and can be extended by others (students in that case; therefore not experienced developers who Fully able to write error-free code).
To catch exceptions: I log in them to the log file, which also includes the entire stack trace. That was the whole point of exercise, just to counter those people who were really taking their resemblance to the OERN of VB.
I know that it is dangerous to ignore certain sections of errors irregularly and corrupt my application example. As stated earlier, this program is not important for anyone. Nobody in his right mind will believe in the existence of human civilization on it. It's just a little tool for some design approach to wrt approach software engineering.
- No exception handling - Although there is a possibility of any other topic. There is no error, which is unfortunate, which is unfortunate.
- General Exception Handling - Defective Error Has Been Trapped, No Damages Looking at all the errors during development, this should be a common case. There should be no immediate consequence of ignoring such errors; The main data structures are thoroughly tested so that they will easily survive.
- General Exception Handling - Fatal Error Trapped, Probably Crash At A Point Later It can rarely happen that we have not seen it till now, the error is logged anyway and an accident can be indispensable. So this is very similar to the case before it's too early. Except that we have a stack trace. And in most cases the user will not even notice.
For experiment data generated by the program: A serious error will be the worst because no data can be entered. The subtle changes that change the outcome of the experiment a bit, it is not very likely. And in that case, if the results seem suspicious, the error was logged; Anyone can still throw that data point if it is a total outair.
To summarize: Yes, I understand myself at least partially and I do not consider a global exception handling routine, the program is running, it is absolutely necessary to be as evil as two The time had been said earlier, on the basis of application, such a decision could be valid. In this case, it was decided that a valid decision was made and was not total and speaking nonsense any other application that the decision could look different. But please do not blame me or others who worked on the project to potentially blow the world because we are ignoring the errors.
Side note: There is absolutely no user for that app. It is not something Windows or Office that is used by millions, where users have already had the cost of exception in the bubble Will be very different.
See for a summary (see).
Keep in mind that there will be exceptions that prevent your application from starting successfully, like stack overflow, tired memory, or lost network connectivity when you are trying to save the database.
Comments
Post a Comment