By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,669 Members | 1,689 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,669 IT Pros & Developers. It's quick & easy.

Custom Exception Getting the Stack Trace

P: n/a
I have a custom exception and I want to write the information to the event
log, including the Stack Trace. I can create the message and write to the
event log no problem, but the Stack Trace is empty.

How do I append the Stack Trace in the custom exception? I can get the
inner exception stack trace from the system exceptions, but how do I get my
own stack trace information.

Thanks in advance

Dave Anson
Dec 2 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Sat, 01 Dec 2007 22:18:46 -0800, Dave Anson
<da********@jazzthecat.co.ukwrote:
I have a custom exception and I want to write the information to the
event log, including the Stack Trace. I can create the message and write
to the event log no problem, but the Stack Trace is empty.
You need to post a concise-but-complete example of code that reliably
demonstrates the problem.

Assuming your exception inherits Exception, the stack trace property
should be correctly initialized. Normally, it would be. So either you
have some unusual scenario that for some reason causes the stack trace to
not be set, or you are misinterpreting the results of whatever code you're
running.

Only by showing us what exactly you're doing that fails can anyone tell
you how to fix it.

Pete
Dec 2 '07 #2

P: n/a
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in
news:op***************@petes-computer.local:
On Sat, 01 Dec 2007 22:18:46 -0800, Dave Anson
<da********@jazzthecat.co.ukwrote:
>I have a custom exception and I want to write the information to the
event log, including the Stack Trace. I can create the message and
write to the event log no problem, but the Stack Trace is empty.

You need to post a concise-but-complete example of code that reliably
demonstrates the problem.

Assuming your exception inherits Exception, the stack trace property
should be correctly initialized. Normally, it would be. So either
you have some unusual scenario that for some reason causes the stack
trace to not be set, or you are misinterpreting the results of
whatever code you're running.

Only by showing us what exactly you're doing that fails can anyone
tell you how to fix it.

Pete
Ok I'll take another look at my code. I expected, that it should display
the stack information I need, as it does inherit from System.Exception.

Either way I'll post the problem or solution if i find one. Thanks.
Dec 2 '07 #3

P: n/a
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in
news:op***************@petes-computer.local:
On Sat, 01 Dec 2007 22:18:46 -0800, Dave Anson
<da********@jazzthecat.co.ukwrote:
>I have a custom exception and I want to write the information to the
event log, including the Stack Trace. I can create the message and
write to the event log no problem, but the Stack Trace is empty.

You need to post a concise-but-complete example of code that reliably
demonstrates the problem.

Assuming your exception inherits Exception, the stack trace property
should be correctly initialized. Normally, it would be. So either
you have some unusual scenario that for some reason causes the stack
trace to not be set, or you are misinterpreting the results of
whatever code you're running.

Only by showing us what exactly you're doing that fails can anyone
tell you how to fix it.

Pete
OK. Looks like a schoolboy error. I was calling the StackTrace I'd added to
another my custom logging, but I hadn't set it in my constructor. Hence the
reason it was empty :( Sorry about that, and thanks for the reply.
Dec 4 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.