Derik Whittaker

Syndication

News


Help my DataContracts do not show up in my WCF Services

The other day I refreshed one of our WCF services (right click the service and do a Update Service Reference) and all of a sudden I got a metric crap-ton of build errors. In each place I received the error it told me that the type was not found.  At first I could not understand what was going on, in fact I was sure the compiler was playing tricks on me (cause we all the compiler has a devilish sense of humor) because how could it be possible that all of my types went missing.

Just to be sure I took a look at the generated code in the Reference.cs class and sure enough all my types were missing.

Now that I know the compiler is not just playing tricks on me it was time to find out what happened.

The first thing I did was to try recompiling the service and updating my references again, but as you could have guessed this did not solve my problem.  Next I decided to try to create a duplicate reference to the service to see if maybe my original reference was screwed up, and as you may have guess the new reference also was missing my types (shocking I know).  At this point I was a bit stumped, and did not know exactly what could have caused the issue.  I next decided to take a look at the service configuration so I right clicked on the service and selected ‘Configure Service Reference’.  When I did this the screen below appeared

image

 

After looking at this for a few minutes it dawned on me what had happened.  The check box (one circled in red) was selected (and is by default) and someone on the team had added direct reference to the assembly which contained my Models that were provided via the web service.  I decided to uncheck that check box and give that a whirl and sure enough my Models came pack.  Now that I was back up and running, it was time to remove the direct reference from my project to the assembly which hosts my WCF service as there is no point in both referring to it locally as well as hitting it via a service.

Long story short, if you refresh your WCF reference and all your Data Contract Models disappear there are 2 things you need to look for.

  1. Are you referencing the service assembly locally (if so why?)
  2. Do you have the ‘reuse types’ check box selected in the WCF configuration screen?

If either (or both) of the above are set then you should have your solution.

Till next time,


Posted 02-09-2010 5:28 AM by Derik Whittaker
Filed under: ,

[Advertisement]

Comments

Sanjeev Agarwal wrote Daily tech links for .net and related technologies - Feb 10-12, 2010
on 02-10-2010 2:00 AM

Daily tech links for .net and related technologies - Feb 10-12, 2010 Web Development 'Unobtrusive' asynchronous

Alon Kogan wrote re: Help my DataContracts do not show up in my WCF Services
on 04-14-2010 10:20 AM

Hello  Derik Whittaker,

Thanx for the guidance, but it seems that there is still a problem with referencing to a wcf service.

My problem is that i've updated my wcf reference, and since that moment i couldn't see my DataContract objects, therefore many vicious errors appeared.

I've added the service reference time and time again, and by your guidance, I did managed to see my datacontract objects, but without the OperationContract methods. do I need to use two references?! Everything was working perfectly untill that moment... do you have any idea what happend??

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)