Had to do a bit of head-scratching on this one. New projects created in Visual Studio 2008 did show the “Add Service Reference” when right-clicking on a project in Solution Explorer while some existing ones didn’t.
Using “Add Web Reference” instead of “Add Service Reference” has its own set of issues in that WCF services are meant to be used with DataContractSerializer. “Add Web Reference” utilizes XmlSerializer which might lead to some surprises when consuming WCF web-services. The way the two serializers handle WSDL is different. This article explains why you might find that property values of your complex types in web-services do not reach all the way to the web-service from the client.
Somebody logged a Microsoft Connect ticket on this but didn’t receive an answer because the issue couldn’t be reproduced.
Anyway, if you’re facing this issue – make sure that the target framework for your project is .NET 3.0 or later (you can do this in the Application tab of your project’s properties). You need to do this extra step if you upgrade your project to Visual Studio 2008 from older versions otherwise “Add Service Reference” wouldn’t appear. You can target .NET 2.0 from Visual Studio 2008 projects and that’s the default behavior during upgrade.
Update: This didn’t fix the issue for you? Check the comments for more alternatives.
Matt
July 24, 2008
I’ve run into some interesting issues regarding this as well, especially when doing WF or WCF projects. A lot of times it boils down to a missing line in the .csproj file, where it needs to have something like:
{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
Those GUIDs are defined inside Visual Studio and turn on/off certain features of Visual Studio. I think those two deal with workflow projects, so try and generate a brand new WCF project with Visual Studio and then open up the .csproj file in Notepad to see which GUIDs it uses.
If anyone runs across a list of GUIDs and what features they turn on/off, I’d like to see it. Right now it borders on an “undocumented feature”
Matt
July 24, 2008
Your comment system ate my tags. It should read:
<ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Gene
August 8, 2008
In your webproject properties Application section set Target Framework to 3.5.
Then you will see Add Service Reference.
GeneV
Dorchester Software
November 7, 2008
My project properties definitely are targeting framework 3.5, but Add Service Reference still does not appear on a particular project.
I’ll try working with the thing… maybe that will fix it.
Dorchester Software
November 7, 2008
Comment system ate my tags too!
What I said was “I’ll try working with the ProjectTypeGuids thing”
Dorchester Software
November 7, 2008
Hey thanks for that. THAT WORKED.
Switching the project Guids I had for the ones you listed above fixed it. I now have the “Add Service Reference” context menu item. The second ProjectTypeGuid I had was already the same but the first was different. Trying running the project and it doesn’t seem to have adversely effected anything else.
Like I say, I already had the project properties set to Target framework 3.5 so that by itself wasn’t enough. But manually editing the ProjectTypeGuids as Matt specified fixed it.
CHEERS!
Sid
November 7, 2008
Thanks Matt for mentioning the ProjectTypeGuid workaround. And thanks Andrew for confirming that it works.
Vaibhav Chawla
February 12, 2009
Very nice tip.
Thanks a lot.
Vaibhav
ben
July 7, 2009
Your the man!!!!!!!
Thanks
Ratan
August 28, 2009
go to project–>properties–>compile(second tab)–>Advanced Compile Options(set .net framework to 3.5)
popnadrian
September 7, 2009
I don’t see on my VS Add Web Reference …. only Add Service Reference; does anybody meet this problem?
Brian
December 9, 2009
On VS2008 when I switched to .NET 3.0 I lost the “Add Web Reference” and gained the “Add Service Reference”. When I switched back to .NET 2.0 I lost the “Add Service Reference” and gained the “Add Web Reference”.
Sid
December 9, 2009
Here’s how you can access the older “Add Web Reference” dialog in VS 2008:
Click on the “Advanced” button in the “Add Service Reference” dialog. That’ll pop the “Service Reference Settings” dialog where the “Add Web Reference” button now resides.
Brian
December 9, 2009
Excellent! Thanks for the info.
Brian
December 9, 2009
Oh you rock!! I have been looking for the solution to this problem for some time. Didn’t think to look if my my target framework was using .NET 3.0 or later. I was using .NET 2.0. After switching it to .NET 3.0 the “add Service Reference” shows. Thanks!!
MAШTAГИHEЦ
January 11, 2010
Очень даже любопытно. В особенности второе.
Dana Nurse
May 12, 2010
If you have a solution with a number of assemblies, and one of said assemblies needs to access a wcf service, simply changing the framework targeted can have undesirable results, including the solution not building.
There may also be the case that the solution you are building cannot be deployed as the target environment may only have 2.0
Fortunately I have found that you can change the target of the assembly to say 3.5. Add the ‘service’ reference. Then change the target back to 2.0
All builds ok and the service works
Explanations ? – don’t ask me!!
rig
July 19, 2010
Hi i have a problem.
My add Reference->PROJECT REFERENCE Tab is empty although i have a lot of projects.
How do i add projects in teh project reference tab.
Bradley Ward
October 13, 2010
In the first comment on this thread, Matt said if anyone ever ran across a list of project type GUIDs, to let him know. Here you go:
http://www.mztools.com/Articles/2008/MZ2008017.aspx
prabhakar
March 13, 2011
Hi ,
While adding a service reference, the service name comes under the service reference but it is not expandable though it contains some services, also the refernce.cs file is not adding in the solution, am i missing something??
any suggetions???
g2-902125243db7d5e697a20ae0137565ac
July 28, 2011
Hello
I amk able to see Add Web Reference but not Add Service Reference Why?
I am using BIDS … is it not available?
I need to load the SP List…
Thanks,
Dom
Dominique Duchemin
July 28, 2011
Hello,
I was able to load VS 2008 but still no Add Service Reference… Also I am not able to locate the Application tab of your project’s properties (Tool Bar > Project > Properties or Right Click oin Solution Explorer on the Top line > Properties) I see only Configuration Active (Development) with Build, Deployment utility, Debugging…
Am I looking at the wrong place?
Thanks,
Dom