“Type not expected”, using DataContractSerializer - but it's just a simple class, no funny stuff?

前端 未结 7 1562
慢半拍i
慢半拍i 2020-11-30 11:10

I\'m refactoring my XML-serialization, and figured I\'d try the DataContractSerializer. Everything runs smoothly, until it needs to serialize this class:

         


        
7条回答
  •  暖寄归人
    2020-11-30 11:27

    Change this:

    [DataContract(Name="Konstant")]
    public class Konstant : DataFelt
    

    to this:

    [DataContract(Name="Konstant")]
    [KnownTypes(typeof(somenamespace.DataFelt))]
    public class Konstant : DataFelt
    

提交回复
热议问题