在WCF中 - 在“故障”事件中 - 如何获取异常详细信息?

时间:2021-04-04 22:21:32

I have a WCF server and I'm tapping into the "Faulted" event which stupidly only gives me "object sender, EventArgs e". How can I get the current 'Exception' object in that event?

我有一个WCF服务器,我正在点击“Faulted”事件,这个事件只给我“对象发送者,EventArgs e”。如何在该事件中获取当前的“异常”对象?

Or, if there is some sort of global system way, like Environment.GetCurrentException(), that would be awesome, but I can't find it.

或者,如果存在某种全局系统方式,如Environment.GetCurrentException(),那将是非常棒的,但我找不到它。

EDIT: To help explain what I'm hoping for... in ASP.NET, you can do "Server.GetLastError()"... Is there such a thing, or anthing even remotely close in WCF? - OperationContext.Current.GetLastError() would be cool :)

编辑:为了帮助解释我希望...在ASP.NET中,您可以执行“Server.GetLastError()”...是否有这样的事情,或者甚至在WCF中远程关闭? - OperationContext.Current.GetLastError()会很酷:)

1 个解决方案

#1


OK, after some more googling with the right keywords, I've found my answer: http://www.steverb.com/post/Useful-WCF-Behaviors-IErrorHandler

好的,经过一些关于正确关键词的谷歌搜索后,我找到了答案:http://www.steverb.com/post/Useful-WCF-Behaviors-IErrorHandler

#1


OK, after some more googling with the right keywords, I've found my answer: http://www.steverb.com/post/Useful-WCF-Behaviors-IErrorHandler

好的,经过一些关于正确关键词的谷歌搜索后,我找到了答案:http://www.steverb.com/post/Useful-WCF-Behaviors-IErrorHandler