views:

23

answers:

2

I have a WCF Service which returns some custom objects to a desktop client application. Both projects share the same ObjectLibrary.dll, however when the WCF server return these objects it is returning

ClientApplication.ServerReference.ObjectType

instead of

ObjectLibrary.ObjectType

Is there a way to get the WCF server to return the ObjectLibrary's class type?

+3  A: 

When you configure the service reference, set the "Reuse types in referenced assemblies" checkbox, and ensure that either the "Reuse types in all referenced assemblies" radio button is checked, or else "Reuse types in specified referenced assemblies" is checked instead, and that all the shared assemblies have check marks next to them in the list below.

John Saunders
I have tried that and it doesn't seem to make a difference.
Rachel
@Rachel: it should work in general. If it doesn't work in your specific case, then you should try to narrow the problem down to a small example that illustrates the failure, then post the details here. A _small_ example, please.
John Saunders
I have a serialized Consumer object in ObjectLibrary.dll. The WCFService references this library, and one of its OperationContracts returns a new object of type Consumer. The Client app references the Service and the ObjectLibrary.dll. To test, I am creating a new object of type ObjectLibrary.Consumer trying to assign the value obtained from calling the WCF service method. It is telling me it can't convert ServerReference.Consumer to ObjectLibrary.Consumer, even with the ServiceReference configuration setup how you said.
Rachel
Not sure if it matters, but I'm using VS2010 Pro and a basic WCF Service Library with multiple endpoints configured in App.Config
Rachel
A: 

My mistake was that I was trying to reference the Service from the ObjectLibrary, and the Service contained a reference to the ObjectLibrary so it was creating a circular reference. I changed my solution so I had one project for object base classes, one for the service which referenced the base classes, and then defined the object methods in a third project which referenced the server and the base class dlls.

Rachel