I have a Web Service project and a WinForm project in the same solution. The WinForms project has a web reference to the Web Service. When I first created the web reference I then went through and customized the code in reference.vb (I wanted it to use classes for the return types from another referenced dll, and not regenerate dummy classes inside reference.vb).
Whenever I make a change to the web service code it re-creates a new reference.vb overwriting all my changes. Is there a way to prevent this

Can I prevent Web Reference Auto-Generation?
bong2x
I was using some web service extensions, and turning them on and off at the method level which would get overwritten with each new generation of the proxy file.
It is wizard generated code after all, and does warn you that it will result in loss of code upon regeneration.
I just wrote a tool that would parse through the proxy file and insert my code back at the appropriate places. I know it is not the answer you want, but it is probably your only option.
Good Luck.
--MikeH
flynng
I tried something that I thought/hoped would work, but its giving me issues.
I generated the web reference, and made my changes to reference.vb (tried running the project like this to ensure it worked - it does). Then I copied the code from reference.vb into another vb file in my project. Deleted the web reference, then added back the project setting that identifies the web service address (this is in VS 2005 btw).
But this gives me a WebException saying the web server can't be reached, and its actively denying my connection. What am I missing here, shouldn't this work Isn't it doing the exact same thing as a web reference What piece of the puzzle am I missing
mrbopalop1
Yeah, it looks like there is some port magic happening when you run uner a file system instead of IIS.
I think there is a way to set the port for this case.
1. In Visual Studio, go to the Properties window (by pressing F4) of the Web project to get the port number. Note that this is not the project's Property Pages dialog box, but rather a docked window within Visual Studio 2005. The Use Dynamic Ports value defaults to True.
2. To prevent Visual Studio from selecting a different port number, change the Use Dynamic Ports option to False.
quicksun
HelenZHOU
I dont actually use a web reference, but use the WSDL tool to generate the proxy file and then just reference this .vb or .cs class like you would any other class file in your project.
If you run
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\WSDL" /l:vb http://localhost/MyProject/MyProject.asmx wsdl
at the command line it will generate a file named MyProject.vb
You can then include this vb file in your project just like any other vb file.
This would actually help solve your problem of auto-regeneration, because there is no webreference anymore. However, any time you make a change to the webservice (new methods or something like that) you will need to re-run this command to generate a new .vb file.
Let me know if I am barking up the right tree for your question.
--MikeH
M. Hassan Raza
But I believe that visual studio can change the port used by the web service whenever it feels like it. When you use a Web Reference I believe VS automagically takes care of keeping the project setting updated to point to the proper port (the web service is in the same solution if that has anything to do with this). Is there any way to do this without having to manually change the setting every time VS decides to switch ports