Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Portable class library for shared [DataContract] class

Tags:

c#

wcf

This is probably a real simple one. I wished to create some code inside a [DataContract] class which is used to communicate information between a WCF service and consuming application.

I created a new Portable Class Library project and created inside it my [DataContract] class. It's really simple - it has a few easy attributes (strings mostly). I added a reference to the DLL in my WCF service and republished it. I then deleted the service reference from my consumer project and re-added it. It adds fine, no problems there.

The problem comes when I want to actually use it. See, the type is called 'Eval'. Some of the WCF methods return this 'Eval' type. So I have this serialized version of 'Eval' in the Reference.cs file within my service reference. Obviously this doesn't contain the method I'm looking for since it's just the serialized version. I can add the dll to the client project as well, but then I have two different Eval objects in two namespaces, and only the one from reference.cs is valid to be returned from the service calls.

So how do I ... erm... merge the two? So as the Eval objects that come back from the WCF service calls also have access to the method in question?

Thanks for reading, and stay safe on those roads.

like image 242
user738383 Avatar asked Nov 25 '11 14:11

user738383


1 Answers

When generating service reference you can specify what classes should be reused and what classes should be generated from service enter image description here

like image 177
Andrey Marchuk Avatar answered Sep 21 '22 13:09

Andrey Marchuk