[英]XmlSerializer throws exception when serializing dynamically loaded type
[英]Serializing datatable throws strange exception
我想序列化一個Datatable
,其中包含其他幾個Datatable
。 過去,我從來沒有遇到過以下代碼的問題:
System.IO.FileStream file = new System.IO.FileStream(fName, System.IO.FileMode.CreateNew);
System.IO.StreamWriter writer = new System.IO.StreamWriter(file);
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
try{
bf.Serialize(writer.BaseStream, dt);
}catch(System.Exception ex){throw new System.Exception("Error serializing data stack!" + System.Environment.NewLine + "Error details: " + ex.Message);}
writer.Close();
writer.Dispose();
file.Close();
file.Dispose();
但是這次,我收到了一個奇怪的文本異常(抱歉-只是用德語):
序列化數據堆棧時出錯! 錯誤詳細信息:Das Ersatzzeichenpaar(0xDB8C,0xAD3)和ungültig。 Ein hohes Ersatzzeichen(0xD800-0xDBFF)Muss stets mit einem niedrigen Ersatzzeichen(0xDC00-0xDFFF)ein Paar bilden。
您可以使用以下方法進行翻譯:
替代字符(0xDB8C,0xAD3)無效。 高替代字符始終必須與低替代字符(0xDC00-0xDFFF)配對。
我真的不知道使用binare格式化程序意味着什么。
數據表中的記錄之一在文本字段中具有無效的Unicode字符。 嘗試通過一張一張地過濾掉記錄來隔離它。
循環中,為數據表中的每個記錄創建一個只有一個記錄的新數據表。 嘗試序列化單記錄DT。 查看它將失敗的記錄。 然后檢查記錄,看看有什么問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.