我有一个Silverlight 4应用程序,它通过WCF Web服务检索数据。 WCF Web服务从.Net XML Web服务中提取数据。 XML Web Service在其他项目中使用时工作正常。应用程序能够直接检索数据,直到一些更改开始抛出此错误:
类型'System.ComponentModel.PropertyChangedEventHandler'无法序列化。请考虑使用DataContractAttribute属性对其进行标记,并使用DataMemberAttribute属性标记要序列化的所有成员。或者,您可以确保类型是公共的并且具有无参数构造函数 - 然后将序列化该类型的所有公共成员,并且不需要任何属性。
我没有用INotifyPropertyChanged标记任何内容或......更改。
我在托管Web应用程序项目中创建了一个测试网页,数据返回时没有错误。我可以单步执行WCF服务,看看数据是否已正确检索。
这是调用代码:
private void LoadJob()
{
this.busyIndicator.BusyContent = "Loading job...";
this.busyIndicator.IsBusy = true;
var client = new BOMViewerServiceReference.BOMViewerServiceClient();
client.GetJobCompleted += new EventHandler<BOMViewerServiceReference.GetJobCompletedEventArgs>(client_GetJobCompleted);
client.GetJobAsync(this.jobNumberTextBox.Text.Trim());
}
void client_GetJobCompleted(object sender, BOMViewerServiceReference.GetJobCompletedEventArgs e)
{
if (e.Error != null)
{
this.busyIndicator.BusyContent = "Busy...";
this.busyIndicator.IsBusy = false;
MessageBox.Show(e.Error.ToString());
return;
}
//Load your data here and assign the result to the CollectionViewSource.
var partViewSource = (CollectionViewSource)this.Resources["jobHeadViewSource"];
partViewSource.Source = e.Result;
this.busyIndicator.BusyContent = "Busy...";
this.busyIndicator.IsBusy = false;
}
private void LoadJob()
{
this.busyIndicator.BusyContent = "Loading job...";
this.busyIndicator.IsBusy = true;
var client = new BOMViewerServiceReference.BOMViewerServiceClient();
client.GetJobCompleted += new EventHandler<BOMViewerServiceReference.GetJobCompletedEventArgs>(client_GetJobCompleted);
client.GetJobAsync(this.jobNumberTextBox.Text.Trim());
}
void client_GetJobCompleted(object sender, BOMViewerServiceReference.GetJobCompletedEventArgs e)
{
if (e.Error != null)
{
this.busyIndicator.BusyContent = "Busy...";
this.busyIndicator.IsBusy = false;
MessageBox.Show(e.Error.ToString());
return;
}
//Load your data here and assign the result to the CollectionViewSource.
var partViewSource = (CollectionViewSource)this.Resources["jobHeadViewSource"];
partViewSource.Source = e.Result;
this.busyIndicator.BusyContent = "Busy...";
this.busyIndicator.IsBusy = false;
}