IE中又缺少编辑器控件..。根据这个主题Simple C# Data Algorithms Question - Populate class from Exception class,在底部有人建议我使用.NET SOAPFormatter来序列化嵌套的异常树。多么?有人能告诉我一些代码来做这件事(尤其是遍历嵌套的内部异常列表)吗?我需要看到实际的代码,而不仅仅是API建议。
我似乎无法响应答案,也无法在锁定的IE8中获得编辑器控件,但我希望通过遍历InnerException属性和添加的异常,在代码中看到嵌套的异常。我希望看到使用的MemoryStream和SOAPformatter。
发布于 2010-12-13 20:50:59
这应说明以下几点:
private static void BinaryFormatterDemo()
{
// serialise
Exception ex = new Exception("Some message",
new Exception("Another message"));
Console.WriteLine(ex);
BinaryFormatter bf = new BinaryFormatter();
FileStream fs = new FileStream("ex.bin", FileMode.Create);
bf.Serialize(fs, ex);
fs.Close();
// deserialise
fs = new FileStream("ex.bin", FileMode.Open);
Exception loadedEx = (Exception) bf.Deserialize(fs);
Console.WriteLine(loadedEx);
fs.Close();
}SoapFormatter没有什么不同,只需用SoapFormatter更改BinaryFormatter即可。
https://stackoverflow.com/questions/4433204
复制相似问题