To debug the client proxy class that sits between the client and the Web service, you need to modify the proxy class so that you can step into it with the debugger. Visual Studio creates this proxy class automatically for you when you add a Web reference to a Web service. If you take the option to Show All Files in the Solution Explorer window, you can find the proxy class shown in the TimeServer project under the localhost ’ Reference.map ’ Reference.vb node. If you double-click the class to open it, you should see a class attribute called System.Diagnostics.DebuggerStepthroughAttribute at the top of the class. This attribute tells the debugger to ignore this class when stepping through the client code. The benefit of hiding the proxy code in this way is that developers aren't confused by having to step through code that they didn't write. The drawback is that it can be very useful to see and debug this proxy code in the event of Web service problems.
If you remove this attribute from the class, you'll find that you can step into and through the proxy code without a problem. To test this, remove the attribute, recompile the solution, and start it by pressing F5. Now click the Demo proxy debugging button, and the debugger should display a message about the unhandled SoapException thrown by the Web service. If you click the Break button, you can see that the debugger has stopped on the client proxy call to the Web service rather than on the client call. The method where the debugger breaks into the proxy class code is called ThrowExceptionRaw , just like its Web service counterpart . This proxy method is the one that the client is actually calling when it looks as though it's calling directly into the Web service method. If you step from the client into the Web service without removing this attribute, the debugger never steps into this proxy method, even though it's being executed.
You do need to bear in mind that whenever you need to update the Web reference because the Web service has changed, this attribute will be automatically regenerated and you'll need to remove it again if you want to continue debugging the proxy class.
You should stop the solution and add Debugger-StepthroughAttribute back at the beginning of the proxy class before continuing with the chapter.