乙個C xml 序列化錯誤

2021-05-21 20:19:46 字數 536 閱讀 6482

乙個c# xml 序列化錯誤

事發現場:

xml序列化的資料中儲存的節點資料是

536870912  (xml檔案中)

對應的類屬性是

public short module   (c#類中)

序列化的**:

除錯時會彈出異常資訊:

an unhandled exception of type 'system.invalidoperationexception' occurred in fmtimeseriesdefinition.exe

additional information: there is an error in xml document (293, 8).

找到xml檔案的293行第8列:

292:      536870912

293:      1

294:      0

是乙個"<"標記符,看不出問題,再看前乙個節點,突然發現536870912 存入short中,資料溢位。

將short改為int,問題解決。

c XML序列化與反序列化

序列化物件 public class people xmlattribute age public int age xmlroot root public class student people xmlelement number public int number void main strin...

C xml檔案操作 序列化

給乙個c 程式新增乙個xml檔案,右擊專案新增,選擇xml檔案 這樣建立的xml檔案不能建立到debug資料夾下面 需要在xml屬性中設定 複製到輸出目錄 始終複製 xml 內容所有的關鍵字根據要求來設定,在獲取的時必須與建立時一致 xml version 1.0 encoding utf 8 張大...

c XML反序列化 修改字首

物件類 xml命名空間,可用於與反序列化方法中指定當前節點的字首,需要注意的是,此方法指定命名空間所修改的字首對當前節點包含的所有子節點生效,對當前節點本身不生效,當前節點的字首繼承父節點 xmlroot namespace http 這是乙個aaa的 public class aaa xmlroo...