PC Review


Reply
Thread Tools Rate Thread

Custom Exception Getting the Stack Trace

 
 
Dave Anson
Guest
Posts: n/a
 
      2nd Dec 2007
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
 
Reply With Quote
 
 
 
 
Peter Duniho
Guest
Posts: n/a
 
      2nd Dec 2007
On Sat, 01 Dec 2007 22:18:46 -0800, Dave Anson
<daveN0SP%(E-Mail Removed)> wrote:

> 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
 
Reply With Quote
 
Dave Anson
Guest
Posts: n/a
 
      2nd Dec 2007
"Peter Duniho" <(E-Mail Removed)> wrote in
news(E-Mail Removed):

> On Sat, 01 Dec 2007 22:18:46 -0800, Dave Anson
> <daveN0SP%(E-Mail Removed)> wrote:
>
>> 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.
 
Reply With Quote
 
Dave Anson
Guest
Posts: n/a
 
      4th Dec 2007
"Peter Duniho" <(E-Mail Removed)> wrote in
news(E-Mail Removed):

> On Sat, 01 Dec 2007 22:18:46 -0800, Dave Anson
> <daveN0SP%(E-Mail Removed)> wrote:
>
>> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stack trace missing with custom exception Chris Fellows Microsoft C# .NET 2 23rd Feb 2009 09:07 PM
Stack trace from an exception in a native C++ method barker7@yahoo.com Microsoft C# .NET 3 30th Oct 2006 01:44 PM
Exception stack trace Raj Chudasama Microsoft C# .NET 1 26th Oct 2005 04:49 PM
getting a stack trace from a c++ exception Chuck Bohling Microsoft VC .NET 1 9th Nov 2004 07:47 AM
+Number in the exception stack trace MeDhanush Microsoft C# .NET 0 22nd Sep 2003 10:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:14 PM.