2012-04-26 3 views
0

私はSilverlightを使用してアプリケーションを作成しています。そのアプリケーションでは私は1つのWebサービスを追加し、そのWebサービスでは、私はIDictionaryを実装しているため、System.Collections.IDictionary型のメンバーSystem.Exception.Dataをシリアル化できません。

[WebMethod(Description = "Write buffer log")]  
     public bool WriteLog(System.Collections.ObjectModel.ObservableCollection<LogBuffer> buffer) 
     { 
      bool result = true; 
      .//Some code here 
      return result; 
     } 

として1つのWebメソッドを持っているが、私はので、型System.Collections.IDictionaryのメンバーSystem.Exception.Dataをシリアル化することはできません」などのエラーを取得していますそれはIDictionaryをを実装しています。」

LogBufferクラスは、事前にme.Thanksを助けてください

namespace WriterLog 
{ 
    [DataContract] 
    public class LogBuffer 
    { 
     [DataMember] 
     public string Message 
     { 
      get; 
      set; 
     } 
     [DataMember] 
     public Exception Exception 
     { 
      get; 
      set; 
     } 
     [DataMember] 
     public LogType LogType 
     { 
      get; 
      set; 
     } 
     [DataMember] 
     public string MethodName 
     { 
      get; 
      set; 
     } 
     [DataMember] 
     public string DeclaringType 
     { 
      get; 
      set; 
     } 
     [DataMember] 
     public DateTime LogTime 
     { 
      get; 
      set; 
     } 
    } 
} 

ようです。

答えて

0

のObservableCollectionのSilverlightのバージョンでは、代わりに一般的なリストを使用してみてください http://msdn.microsoft.com/en-us/library/ms668604(v=vs.95).aspx

シリアライズではありません。ここで私が使用して何かだとそれは私がSystem.Collections.Generic.List 使用しかし、それでもまだ、私は取得しています返信用ではなく、System.Collections.ObjectModel.ObservableCollection

[DataContractAttribute] 
public class InstrumentDataField : INotifyPropertyChanged 
    { 
    [DataMemberAttribute] 
    private string Value { get; set; } 

    [DataMemberAttribute] 
    public string Name { get; set; } 

    public InstrumentDataField(string field, string value) 
    { 
     this.Name = field; 
     this.Value = value; 
    } 

    public event PropertyChangedEventHandler PropertyChanged; 

    public void NotifyPropertyChanged(string propertyName) 
    { 
     if (PropertyChanged != null) 
     { 
      PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 
     } 
    } 
} 

使い方

[OperationContract] 
public List<InstrumentDataField> GetInstrumentData(string browserid, long tickCount) 
{ 
    //some code here 
} 
+0

おかげで動作します同じエラー。 – Dany

+0

そこに..サンプルを追加しました –

+0

Silverlightは通常のWebサービスなどが好きではないことを忘れないでください。Add >> New >> Silverlight Webservice –

関連する問題