X

Subscribe To Our Mailing List

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

Showing posts with label WCF. Show all posts
Showing posts with label WCF. Show all posts

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.


Change base address wcf

Wow !!! today i had first vision towards WCF technology its seems to be very interesting. I was scratching my head from last 2 hours and got the solution and by seeing the solution i myself got ashamed…..

The funny thing started from here -


Change base address wcf
















Here I am trying to create a new WCF project and here I have the options
1)      WcfServiceLibrary
2)      WcfService Application
3)      Wcf Workflow Service Application
4)      Syndication Service Library
I am choosing “WcfServiceLibrary” because I wanted a dll to be created and I am hosting WCF in self-hosting method.
Now look at the app.config which is been created by default,
Change base address wcf














This is the config file generated and the default base address generated is
 Which is using Http binding, Now suppose I want to change the base address to
I tried this but I was getting this error
“Please try changing the HTTP port to 8732 or running as Administrator.”
Then after googling this I got some links which could help me to resolve this issue and finally it got solved by running visual studio in Administrator mode.
Change base address wcf

Running as administrator will allow you to run the service on any port.
After doing this automatically everything  worked !!!!
Isn’t  that funny.. yes it is….


Hope it helps…..