Silverlight 无法序列化System.Collections.IDictionary类型的成员System.Exception.Data,因为它实现了IDictionary。
我正在使用Silverlight制作一个应用程序。在该应用程序中,我添加了一个web服务,在该web服务中,我有一个web方法作为Silverlight 无法序列化System.Collections.IDictionary类型的成员System.Exception.Data,因为它实现了IDictionary。,silverlight,visual-studio-2010,web-services,Silverlight,Visual Studio 2010,Web Services,我正在使用Silverlight制作一个应用程序。在该应用程序中,我添加了一个web服务,在该web服务中,我有一个web方法作为 [WebMethod(Description = "Write buffer log")] public bool WriteLog(System.Collections.ObjectModel.ObservableCollection<LogBuffer> buffer) { bool
[WebMethod(Description = "Write buffer log")]
public bool WriteLog(System.Collections.ObjectModel.ObservableCollection<LogBuffer> buffer)
{
bool result = true;
.//Some code here
return result;
}
请帮助我。提前谢谢。Silverlight版本的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));
}
}
}
用法
[运营合同]
公共列表GetInstrumentData(字符串browserid,长勾号)
{
//这里有一些代码
}
感谢您的回复,但我使用的是System.Collections.ObjectModel.ObservableCollection,而不是System.Collections.Generic.List,但仍然出现相同的错误。请记住,Silverlight不喜欢普通的Web服务等。有一个选项添加>>新建>>Silverlight Web服务我没有使用Silverlight Web服务(WCF服务)。我正在silverlight应用程序中使用正常的web服务。您在自找麻烦。。。祝你好运
[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
}