C# Catching exception which is occuring on ThreadPool -



C# Catching exception which is occuring on ThreadPool -

i investigating crashes in application caused win32 exception, , have narrowed downwards must occuring in threadpool taking care of eventlog.entrywritteneventhandler event handler in application. set this:

// create event log monitor eventlog.log = "application"; eventlog.enableraisingevents = true; eventlog.entrywritten += new entrywritteneventhandler(eventlogmonitor);

eventlogmonitor handler event. wondering have ideas find out whats causing exception. seems hear events threadpoolwaitortimercallback beingness set up, wouldn't have of code on it, , if exception occuring on cant see how deal problem. help appreciated!!

here output of !clrstack in windbg:

0:008> !clrstack os thread id: 0x106c (8) esp eip 049df1c8 7756f871 [helpermethodframe: 049df1c8] 049df26c 73ce6fa0 system.diagnostics.eventlog.get_oldestentrynumber() 049df27c 73bf24ed system.diagnostics.eventlog.completioncallback(system.object) 049df2c4 73bf0fe4 system.diagnostics.eventlog.staticcompletioncallback(system.object, boolean) 049df2f4 744fc3b8 system.threading._threadpoolwaitortimercallback.waitortimercallback_context(system.object, boolean) 049df300 744fc373 system.threading._threadpoolwaitortimercallback.waitortimercallback_context_f(system.object) 049df304 7400027f system.threading.executioncontext.run(system.threading.executioncontext, system.threading.contextcallback, system.object) 049df31c 744fc477 system.threading._threadpoolwaitortimercallback.performwaitortimercallback(system.object, boolean) 049df4ac 74991b5c [gcframe: 049df4ac]

in case helps, application checking event id of every entry written event log, , if matches 1 of set of id's log it. crashes happen quiet rarely, , exception system.componentmodel.win32 exception message 'access denied'. sounds permissions issue why work ok period , crash this.

if understand correctly (it help if pass stacktrace leads conclusion exception happening within threadpool thread), wrap code of eventlogmonitor in try/catch block.

example:

void eventloghandler(object sender, eventargs args) { seek { // original code. } grab (exception ex) { // log or write "ex" console. set breakpoint, whatever. throw; } }

update: after update looks if exception indeed not raised within handler, before called within eventlog class.

you seek registering handler appdomain.unhandledexception event , logging/handling in there. note not allow suppress or "change" or wrap exception, simply log somewhere diagnostic purposes.

if want inspect exception 1 time (or on occasion), should seek using sos-extension's !printexception command in windbg.

update 2: after farther investigation find rather unusual exception bubbles all. stacktrace suggests you're using .net 3.5 (or earlier, not 4.) , looking @ eventlog class in reflector can see whole handling of eventwrittenhandler, including preamble code seems cause exception, wrapped in 1 big "try/catch(exception)/catch" block. funny.

c# exception threadpool

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -