views:

102

answers:

1

I am pretty sure this is a stupid question, but here goes anyway. I have a WCF Data Service exposing an object, let's say Person. This Person object is in the namespace Domain.Person. I have a client with a proxy to the WCF Data Service. This client has code that works with the referenced Domain.Person class. However, the proxy is returning a different type, Client.Person and it is complaining of being unable to convert between the two.

So, apart from me being stupid (likely), isn't the proxy supposed to return a type of Domain.Person? And if not, should the Client.Person not be the same? Sorry, bit confused.

+1  A: 

I have no experience with WCF Data Services, but it seems to me that the proxy generated it's own version of the Domain.Person class and is using this.
When adding a 'normal' wcf service reference, it is possible to specify assemblies from which types can be reused while generating the proxy. That's hidden under the 'Advanced' button on the dialog where you select your WCF service.
If you are sure that this is enabled, I'd try opening up the generated proxy (with show all files you can see the generated .cs file) and comparing the types to your Domain types. If there are any significant differences, add them to your Domain types, remove the service reference and add it again. Wash-rinse-repeat...

Again, my experience with WCF data services is non-existent, so maybe someone has a more to-the-point answer.

StephaneT
Ah, right, I checked the project that contained the service reference and noted that the project containing the actual domain object was not referenced. I then tried to add this as a reference to realise that the client is Sliverlight and it cannot reference the domain object project as this is not a Silverlight project. Obviously the domain object should be client agnostic, any futher ideas? Thanks a lot for your help.
Jon Archway
either isolate your domain objects in a silverlight class library and reference this in both your client and server (this works from silverlight 4 up - see http://msmvps.com/blogs/kevinmcneish/archive/2010/05/28/silverlight-4-101-using-silverlight-assemblies-in-your-non-silverlight-projects.aspx)Or create a silverlight classlibrary and link the files into it like explained here: http://stackoverflow.com/questions/3122169/add-reference-to-silverlight-project-from-other-non-silverlight-project
StephaneT