Reputation: 2197
I have a client app consuming a WCF service that is accepting and returning some complex type parameters. these complex types are held in a separate assembly that both the client app and the WCF service are referencing.. the problem is that when I add the service reference in the client app, the generated reference class builds its own versions of the complex parameter types and hence I cant pass in the types from the assembly that the original types are defined. not sure if that is at all understandable..
question is.. am I going to have to write some sort of reflective deep copy routine to effectively build up the service reference generated classes from the original types? or is there a better option
any help as ever very happily received
nat
Upvotes: 3
Views: 2497
Reputation: 6793
Unless I've misunderstood, by checking "Reuse types in referenced assemblies" in the Advanced settings within Add Service Reference, any data contracts which match those in a referenced assembly will be reused and not regenerated.
Upvotes: 0
Reputation: 41983
Nope, you can do it: see my question here:
WCF Service Reference generates its own contract interface, won't reuse mine
You can have a shared assembly with interfaces, types, and both the service and client(s) can reference it :)
The 'reuse referenced types..' option does cover complex types, but the answer above also covers reusing the interface type, which IMO is far better option and not covered by that VS option.
Upvotes: 5
Reputation: 61589
When you are adding a service reference to code, select Advanced
and you'll see an option Reuse types in referenced assemblies
. If you ensure that is checked, and the reference is added to the project, WCF won't generate the proxy types and use the referenced types instead.
If you've already added the service reference, reference your shared types first, and then right-click the Service Reference, and select Configure Service Reference
to get it to regenerate the client code using your referenced types.
Upvotes: 7