views:

428

answers:

2

Occasionally I have a problem when I attempt to update a web reference in Visual Studio 2008 (this also happened in VS2005). It has happened in several different solutions. When I have a solution with a (.NET 2.0) web service and a project that references the web service I get "There was an error downloading 'http://localhost:3890/MyWebService.asmx' Unable to connect to the remote server.". Obviously, the port number in the example is an example only, it could be any port number.

The web reference is set to 'Dynamic URL' and the web service is using the ASP.NET Development Server web server rather than IIS. When the error occurs the icon for the service never shows up in the system tray.

I have found two workarounds. The more drastic workaround is to delete the web reference and recreate it. This has worked for me everytime, but has caused some confusion for Subversion and AnkhSVN.

Recently it occurred to me to set the web service as the startup project, start it, and mouse over the ASP.NET Development Server icon on the system tray to find out the port number that it has chosen. Then, edit the port number in the WebReferenceUrl property of the web reference. After doing this I can update the web reference.

While this works I feel that there must be a better way. It seems that VS and Cassini should be able to resolve this without manual intervention. Am I missing something, or is this another case of Microsoft getting the difficult things right and the simple basics wrong?

I have attempted to search an answer for this issue and have found several threads describing the problem. But, no one has identified a real solution.

Thanks, Jim

A: 

Right-click the service in Solution Explorer, and choose "View in Browser". That will cause the service to start, and you'll be able to use "Add Web Reference".

John Saunders
worked well, when combined with answer from 'u07ch' it resolved everything
Jim Reineri
A: 

You can force the port of the test web site in visual studio.

Open the properties window in visual studio it with "F4" or via the toolbar - "View" -> "Properties Window". Left click on your web site in the "Solution Explorer" window. Notice the drop down list for the "Use dynamic ports" setting. If you set this to "False", you'll then be able to specify a fixed port in the "Port number" field.
Set this to your desired port value.
Launch your web site. You'll see the port used matches the value you specified.

u07ch
worked well, when combined with answer from 'John Saunders' it worked great.
Jim Reineri