Tuesday, 17 January 2012

Solved: Visual Studio 2010: ASP.NET project - can't add web reference

I hadn't worked on a project for a while (since upgrading to Visual Studio 2010), and I needed to add a web reference to get it to compile. The normal method is just to right-click on your project name in Solution Explorer and click Add Web Reference.

But I had no option to Add Web Reference, only an option to 'Add Service Reference' which seems to be designed for WCF references.

It's a legacy project though, so I needed to add the reference in the legacy format - adding a service reference creates different components in your project than a web reference.

I got round it by:

1. Change the target framework to .NET 2.0
2. Close and reopen the solution - you should see the option to Add Web Reference.
3. Add the web reference.
4. Change the target framework back to whatever you had before.
5. Close and reopen the project.
6. Continue upon your way.

This might not work for everyone since I don't really know why the option to add web reference disappeared in the first place - but it worked for me.

0 comments: