I want to populate a Datagrid with some items from database through WCF Service when window is loaded or user click a button, but I receive the following message:
What is wrong ?
here is my code from WCF :
public IEnumerable<sesizari> getSesizari()
{
try
{
IEnumerable<sesizari> query = from sel in dataP.sesizaris select sel;
return query;
}
catch(FaultException ex)
{
throw ex;
}
}
Client code :
private void Service_Window_Loaded(object sender, RoutedEventArgs e)
{
try {
GridView gridView = new GridView();
SesizariList.View = gridView;
gridView.Columns.Add(new GridViewColumn
{
Header = "Id Sesizare",
DisplayMemberBinding = new Binding("id_sesizare")
});
gridView.Columns.Add(new GridViewColumn
{
Header = "Titlu",
DisplayMemberBinding = new Binding("titlu"),
});
gridView.Columns.Add(new GridViewColumn
{
Header = "Client",
DisplayMemberBinding = new Binding("client"),
});
SesizariList.ItemsSource = client.getSesizari();
SesizariList.Items.Refresh();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
I've enabled trace logging and the problem is at getSesizari() method, but I don't know what is wrong...
There was an error while trying to serialize parameter http://tempuri.org/:getSesizariResult.
The InnerException message was 'Type 'System.Data.Entity.DynamicProxies.sesizari_3A8E1D8187ED0306632025D5E2C490F13F4A3E7EF93AFE8F6B9C7DE55AFA8511'
with data contract name sesizari_3A8E1D8187ED0306632025D5E2C490F13F4A3E7EF93AFE8F6B9C7DE55AFA8511:http://schemas.datacontract.org/2004/07/System.Data.Entity.DynamicProxies'
is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example,
by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.
Please see InnerException for more details.