catch (Exception e)
{
e.Data["SourceFile"] = "Client.cs";
e.Data["MethodName"] = "Send_CommandToServer";
e.Data["ExceptionType"] = "Exception";
object[] exceptionArgs = new object[8] { null, e.InnerException,
e.Message, null, e.Source, e.StackTrace,
e.TargetSite, e.Data };
ExceptionError.Show(exceptionArgs);
}
以下是抛出InvalidCastException异常的ExceptionError类中的代码行:
Dictionary<string,string> data = (Dictionary<string, string>)exceptionArgs[7];
// exceptionArgs[7] is Exception.Data
以下是我收到的实际错误信息:
无法将类型为 'System.Collections.ListDictionaryInternal' 的对象强制转换为类型 'System.Collections.Generic.Dictionary`2[System.String,System.String]'。
我找不到任何关于ListDictionaryInternal的信息,我所做的大多数谷歌搜索都指向System.Collections.Specialized.ListDictionary,它本身也会产生一些问题。 有人知道有关ListDictionaryInternal的任何信息吗?还是您可以帮助我将 e.Data 传递到我的 ExceptionError 类中吗?