Post

“Add Service Reference” option not appearing in Visual Studio 2008

In .NET, Tech/Hacks on July 22, 2008 by Sid Tagged: ,

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.


18 Responses to ““Add Service Reference” option not appearing in Visual Studio 2008”

  1. 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” :)

  2. Your comment system ate my tags. It should read:

    <ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

    :)

  3. In your webproject properties Application section set Target Framework to 3.5.
    Then you will see Add Service Reference.

    GeneV

  4. 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.

  5. Comment system ate my tags too!
    What I said was “I’ll try working with the ProjectTypeGuids thing”

  6. 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!

  7. Thanks Matt for mentioning the ProjectTypeGuid workaround. And thanks Andrew for confirming that it works.

  8. Very nice tip.
    Thanks a lot.

    Vaibhav

  9. Your the man!!!!!!!

    Thanks

  10. go to project–>properties–>compile(second tab)–>Advanced Compile Options(set .net framework to 3.5)

  11. I don’t see on my VS Add Web Reference …. only Add Service Reference; does anybody meet this problem?

    • 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”.

      • 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.

  12. 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!!

  13. Очень даже любопытно. В особенности второе.

  14. 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!!

  15. 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.

Leave a Reply