I have designed a custom silverlight control that extends the standard datagrid. This control provides a method to populate the grid which accepts an instance of a custom class I have created. The control is housed in a number of different silverlight pages each of which call a web service to obtain an instance of the custom class and pass it off to the datagrid control to populate itself.
My problem is when the silverlight container page receives the object back from the webservice, the object's type is tied to the service reference for that silverlight application. So, for example, if the "SilverlightContainer" page calls the webservice, the type of the object returned will be "SilverlightContainer.ServiceReference1.CustomDataObject". This gets passed to the data grid, but because the data grid is in it's own class library, it is not part of the "SilverlightContainer.ServiceReference1" namespace. It, therefore, does not know what to do with the object.
I have tried importing an identical service reference into the class library and casting as shown below, but receiving a casting exception.
ClassLibrary.ServiceReference1.CustomDataObject obj = (ClassLibrary.ServiceReference1.CustomDataObject)ObjectPassedFromContainerPage;
Does anyone have any ideas on how to solve this?