J
jd_ie
Hi all,
We have written an application for Windows CE .NET whose data will be
very important and cannot be lost. During on-the-road testing, we had a
couple of unhandled exceptions occur, and the exception did not happen
every time the same operation was carried out, so it is difficult to
know why it happened, especially as it was a user relaying the
information through someone else to me, and one cannot be sure of the
reliability of the information.
The problem is that if an unhandheld exception occurs, there is no
information about the exception shown.
I was thinking of using log files to log exception error messages and
types (even though the line number is not accessible in the Compact
Framework), whenever an exception occurs. I could enclose try blocks
around all SQL operations, as these seem to be a likely place for
exceptions to occur. In this case I could also write the SQL statement
to the log file, which would do a good job of identifying the possible
location of the error. The problem is how to catch the other
exceptions.
In Visual Basic (which I used to program in) in every function one
could put a "On Error Goto ErrHandler" statement at the top, and then
at the end put error handling code where code for writing the error
details to a log could be put. I suppose that to at least find the
function in which the error occurred, I could in every function enclose
the code in one big try block, and put the catch at the end, but would
this in any way affect performance? Also I feel that this is not good
programming style, is this correct? I have not been programming in C#
long.
Are these the only options open to me? What is the best way to use try
blocks to catch exceptions when you want to be able to catch all
exceptions and find out where they occurred?
I understand that there may be a bug in the code that will only
manifest itself when in the complex working environment, but I would
feel better about it if I could be relatively sure that the first time
an exception occurrs, that I could be reasonably sure about having
enough information to fix it.
It worries me that we might be in the dark and helpless to effectively
fix these problems. Is anyone else in this situation; does anyone know
the best way to approach this? I would sincerely appreciate your help.
Best regards,
Jonathan Dudley
We have written an application for Windows CE .NET whose data will be
very important and cannot be lost. During on-the-road testing, we had a
couple of unhandled exceptions occur, and the exception did not happen
every time the same operation was carried out, so it is difficult to
know why it happened, especially as it was a user relaying the
information through someone else to me, and one cannot be sure of the
reliability of the information.
The problem is that if an unhandheld exception occurs, there is no
information about the exception shown.
I was thinking of using log files to log exception error messages and
types (even though the line number is not accessible in the Compact
Framework), whenever an exception occurs. I could enclose try blocks
around all SQL operations, as these seem to be a likely place for
exceptions to occur. In this case I could also write the SQL statement
to the log file, which would do a good job of identifying the possible
location of the error. The problem is how to catch the other
exceptions.
In Visual Basic (which I used to program in) in every function one
could put a "On Error Goto ErrHandler" statement at the top, and then
at the end put error handling code where code for writing the error
details to a log could be put. I suppose that to at least find the
function in which the error occurred, I could in every function enclose
the code in one big try block, and put the catch at the end, but would
this in any way affect performance? Also I feel that this is not good
programming style, is this correct? I have not been programming in C#
long.
Are these the only options open to me? What is the best way to use try
blocks to catch exceptions when you want to be able to catch all
exceptions and find out where they occurred?
I understand that there may be a bug in the code that will only
manifest itself when in the complex working environment, but I would
feel better about it if I could be relatively sure that the first time
an exception occurrs, that I could be reasonably sure about having
enough information to fix it.
It worries me that we might be in the dark and helpless to effectively
fix these problems. Is anyone else in this situation; does anyone know
the best way to approach this? I would sincerely appreciate your help.
Best regards,
Jonathan Dudley