[CollectionDataContract(Namespace = "CISICPD")]
[KnownType(typeof(List<CISICPD.LeeDictionary>))]
public class LeeDictionary : Dictionary<string, object>
{
}
[DataContract(Namespace = "CISICPD")]
[KnownType(typeof(List<CISICPD.LeeDictionary>))]
public class TestResponse
{
[DataMember]
public List<LeeDictionary> Results;
public TestResponse() { Results = new List<LeeDictionary>(); }
[OnDeserializing]
private void OnDeserialize(StreamingContext c) { Results = new List<LeeDictionary>(); }
}
上記がサービス参照で使用される場合、生成されたものはreference.cs
上記で指定された既知のタイプを単に無視します。
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="TestResponse", Namespace="CISICPD")]
[System.SerializableAttribute()]
public partial class TestResponse : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
自分の名前空間を設定できるように指定しましたLeeDictionary
(名前空間の問題である可能性があります)。変更Dictionary<string,object>
はまったく同じです。問題は、辞書自体に別の辞書が含まれていて、タイプが不明であると文句を言うときに発生します。
既知のタイプの行を追加するreference.cs
と、すべて機能しますが、参照を生成するときになぜそれが挿入されないのかわかりませんか?