StackTrace是错误的受害者

StackTrace是错误的受害者

本文介绍了System.Diagnostics.StackTrace是错误的受害者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用System.Diagnostics.StackTrace获取

当前函数的堆栈跟踪,将函数的名称打印到日志中,并且

有时候它会显示一个甚至不写入日志的函数

就是写入日志的内容。这不可能,所以

System.Diagnostics.StackTrace必须返回错误的信息

(从另一个线程,我猜)。


这是正常的还是预期的?它可靠吗?


Zytan

I use System.Diagnostics.StackTrace to get the stack trace of the
current function, to print out the function''s name to the log, and
sometimes it shows that a function that doesn''t even write to the log
is what is writing to the log. This just can''t be, so
System.Diagnostics.StackTrace must be returning the wrong information
(from another thread, i suppose).

Is this normal, or expected? Can it be reliable?

Zytan

推荐答案





我怀疑StackTrace也是错误的。然而,Zytan的观点是

函数名称会在日志中结束,而这些日志应该*永远不会出现在日志中。它不是因为他们的顺序错误而是
。这就是他们应该永远不会出现



为此,我没有解释。


Zytan,如果你能提供一个简洁的代码示例,可以有效地再现问题,那将会有所帮助。


Pete

I doubt that the StackTrace is wrong too. However, Zytan''s point is that
function names wind up in the log that should *never* be in the log. It''s
not that they''re in the wrong order. It''s that they should just never
appear at all.

For that, I have no explanation.

Zytan, if you can provide a concise example of code that reliably reproduces
the problem, that would be helpful.

Pete




很可能。我正在使用TextWriter,它是同步的,但是如果

我对我的LogWrite函数进行了两次调用,那么它们可以混合起来

up。问题是我可以看到这样的事情何时发生,而且我的问题经常发生,它必须是别的东西。虽然,你的

点已经被拿走了,但是我会解决这个问题,即使它很难发生,也可以将它作为一种可能性删除。


我会回复Peter的帖子,我认为这是真正的问题...


谢谢,

Zytan

That is likely. I am using TextWriter, which is synchronized, but if
I make two calls to my LogWrite function, then they could get mixed
up. The problem is that I can see when such a thing happens, and my
issues occur so often, it must be something else. Although, your
point is taken, and I''ll solve this issue ANYWAY, even though it
hardly happens, to remove that as a possibility.

I''ll reply to Peter''s post with what I think is the real issue...

thanks,
Zytan


这篇关于System.Diagnostics.StackTrace是错误的受害者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 00:14