Picture, if you will, a Visual Studio 2008 WPF application with a single window containing a ListBox. This application contains a method, outlined below, that binds the ListBox to the contents of a database table.
This application also happens to implement a WFC service contract, hosting said WCF service.
The data binding method below is invoked in respose to both a button press on the window, and in response to a method being remotely invoked against the WCF service hosted by the application.
When invoked by the button press the binding works correctly and the list box reflects the content of the database table. I can insert some records into the underlying table, hit the button and the contents of the list box are refreshed to reflect the new records. However, when triggered remotely via the WCF service any changes to the database are not reflected in the list box. From stepping through the code the data set contains the correct view of the table, but the list box retains the previous view of the table and doesn't reflect the contents of the data set.
Initially I thought this sounded like a threading issue, so I tried making use of Dispatcher objects but to no avail. From my investigations both calls are received on the UI thread anyway.
Any suggestions appreciated - it's probably something blindingly obvious knowing my luck...
private void BindData()
{
SqlConnection connection;
using (connection = new SqlConnection(CONNECTION_STRING))
{
DataSet dtSet = new DataSet();
SqlCommand command = new SqlCommand("SELECT * FROM TheTableWithMyStuffIn", connection);
SqlDataAdapter adapter = new SqlDataAdapter();
connection.Open();
adapter.SelectCommand = command;
adapter.Fill(dtSet, "TheTableWithMyStuffIn");
listBox1.DataContext = dtSet;
}
}
UPDATE: I re-implemented the remote notification mechanism to use remoting rather than WCF, and the databinding now works when invoked both remotely and locally. There must be some contextual implication of using WCF?