Restart an application after exception

LookitsPuck

Active member
Joined
Jan 23, 2007
Messages
37
Programming Experience
3-5
Is there a way through the AppDomain's UnexpectedExceptionHandler function to restart the application? I'd like to this rather than through a scheduled task.

Thanks,
-Steve
 
Well, it is a multithreaded application. But I'm in the same boat as you, I always thought one unhandled exception would kill it, but I'm logging it:

1/25/2007 8:50:12 PM - MSG : The given key was not present in the dictionary. - number of exceptions: 0
1/25/2007 8:50:12 PM - MSG : The given key was not present in the dictionary. - number of exceptions: 1
1/25/2007 8:50:12 PM - MSG : The given key was not present in the dictionary. - number of exceptions: 2

It's actually three. Counter was 0 based.

I know about catching the exception for it to survive. But I need to find where it's happening first. I know it's a synchronization issue, so it's not going to be fun to find. If it's not a synchronization issue, then colour me tickled!
 
You get problem with "key was not present in the dictionary", you know there is the Dictionary.ContainsKey method ? In some cases you don't use it because somehow you've implemented the logic in a way that a call by key can't fail. But here that is not the case, you are somewhere assuming a key is present in Dictionary, which it is not.

I know this is not what this thread topic is about, but it should still be usable for you to know since you made that error.
 
I can't find where it is, though. I think it's a synchronization issue. It checks the contains, then executes another thread, and something might change, then goes back, and the key is no longer in it. Not sure. Going to be a pain to find.
 
I see, that might be, but then you missed SyncLock on that object somewhere. Good luck.

..err.. or maybe not, as you describe, there may be a *long* time between checking if 'contains' and actually doing something with it.. When getting to doing something with it you again access by key, but this time does not check for 'contains'.
 
Back
Top