【发布时间】:2010-11-29 23:10:47
【问题描述】:
我需要重新抛出一个被捕获并存储在其他地方的异常而不丢失有关何时首次捕获/存储异常的堆栈跟踪信息。我的代码如下所示:
public void Test()
{
int someParameter = 12;
ExecuteSomeAsyncMethod(someParameter, CallbackMethod);
}
public void CallbackMethod(object result, Exception error)
{
//Check for exceptions that were previously caught and passed to us
if(error != null)
//Throwing like this will lose the stack trace already in Exception
//We'd like to be able to rethrow it without overwriting the stack trace
throw error;
//Success case: Process 'result'...etc...
}
我已经看到使用反射(例如 here 和 here)或使用序列化(例如 here)的解决方案,但在 Silverlight 中这些都不适合我(私有反射不是允许并且序列化方法中使用的类/方法在 Silverlight 中不存在)。
有什么方法可以保留 Silverlight 中的堆栈跟踪吗?
【问题讨论】:
标签: c# .net silverlight exception