Under what circumstances would a .NET program just terminate?
I have a WPF application written for the .NET 4 Full Framework. The
application uses SQL Anywhere as its database. My application has an
unhandled exception handler, which always logs errors to a custom event
log for the program. It then displays the error message to the user. The
program also sends messages to the event log whenever it's about to do
something in order too make debugging it easier.
The application is installed on a user's laptop, which is running Windows
7 and has 8 GB of RAM. When it is started on this machine, the splash
screen is displayed and then the program's main window is displayed. Less
than a second after being drawn, the program dies. There are no error
messages displayed.
Checking the event log shows that the program's last message written was
that it was doing a check for the existence of a user in the database.
There are no error messages.
The code that follows the last message that was displayed is a call to a
method that does some parameter checking and then executes the following
EF query:
LPRCore.CarSystem.User user = null;
IQueryable<User> query = from u in context.Users
from m in context.Members.Where( m => m.UserId ==
u.UserId )
.DefaultIfEmpty()
where u.LoweredUserName == userName.ToLower() &&
m == null
select u;
try {
user = query.SingleOrDefault();
} catch ( Exception ex ) {
....
}
I can't tell if the code in the catch block is ever called. My suspicion
is that it is getting called and an exception is occurring in there.
My question is, if an exception occurs in a catch block, won't that
exception be caught by the Unhandled Exception handler at the upper level,
if there is no other exception handler to catch the error? Or would it
cause the program to die without reporting anything?
No comments:
Post a Comment