X

Subscribe To Our Mailing List

P.S I will never spam you...100% GUARANTEED!

Sunday, June 8, 2014

DataContracts are not generated in Client side after adding Service Reference !!

Hi All,
Back to boring WCF but this time with a different issue :-):-)
This time my client wanted to have an smart client application using .NET technology. So here is my list of layers created for this project -
1) DataAccess Layer – Contains my Classes with DataContracts and library references which are used to connect to my SQL database.
2) Service Layer – which is used for calling the methods which are in DataAccess Layer. We have used WCF service with SOAP in this case.
3) Client Library – which takes the reference of the service and calls up the methods in service layer.
After giving an reference of the WCF service to my client library i was not getting the classes generated in the client side.
I made sure that i have added “DataContract” and “DataMember” attributes are added on my Class and Property level respectively.
1 full day i was scratching my head but of no use :-):-)
Next day some forum answers provoked me to find the root cause of it. I got following answers in forums -
1. Try remove the entire service reference and add again, instead of update.
2. Please check if project settings are same – like – platform, framework and other settings are same – any assembly keys you are using?
3. Also check if there are any predefined assembly references are missing on your destination project.
So finally i found the solution – That was because My Service Library was in Framework 4.5 and my Client Library was in Framework 3.5.
So after changing my Service Library to Framework 3.5 it solved the issue.
Note : In my case client wanted the client library to be in Framework 3.5 so i changed my Service Library to Framework 3.5. You can do it vice versa too. (Client and Service libraries to be in framework 4.5)
Other reason also i found by googling is “If DataContracts are not been used in any of your Service Methods
(Operation Contracts) then also you would not get that in Client side”.
In my case DataContract was of type class. Same thing is true for other types like structures, or enumerations too.
Hope this is helpful to others.


No comments:

Post a Comment

Comments Section