Microsoft KB Archive/316175

= BUG: Cannot step into Web method when you debug the ASP.NET Web service =

Article ID: 316175

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Visual Basic 2005 Express Edition
 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition

-



This article was previously published under Q316175



SYMPTOMS
When you debug a Microsoft ASP.NET Web Service that is developed with Visual Basic .NET or Visual Basic 2005, you cannot step into a Web method. The debugger steps over the method call instead of into it.



CAUSE
This problem occurs because the signature of the Web method contains a String argument that is declared with the ByRef keyword.



RESOLUTION
Use one of the following methods to work around this problem:
 * Use the ByVal keyword in the method signature.

Redefine the signature of the Web method to accept the String argument by value rather than by reference. To do this, use the ByVal keyword rather than the ByRef keyword when you define the String argument.
 * Insert a breakpoint in the Web method signature.

Open the Web Service project in Microsoft Visual Studio .NET or in Microsoft Visual Studio 2005, and then add a breakpoint on the signature of the Web method. This causes the project to stop running whenever the Web method is called.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
This problem occurs when the Web method contains a String argument that is passed by reference. If you pass other data types, or if you pass the String argument by value, this problem does not occur. Additionally, this problem does not occur if you develop the ASP.NET Web Service in Microsoft Visual C# .NET or in Microsoft Visual C# 2005.

Steps to Reproduce Behavior
 Start Visual Studio .NET or Visual Studio 2005. Create a new ASP.NET Web Service in Visual Basic .NET or in Visual Basic 2005.  Open the Code window, and then add the following Web methods to the module:  Public Function PassByRef(ByRef s As String) As String s = &quot;Goodbye&quot; Return s End Function

 Public Function PassByVal(ByVal s As String) As String s = &quot;Goodbye&quot; Return s End Function  On the Build menu, click Build Solution to build the Web Service.</li> On the File menu, point to Add Project, and then click New Project.</li> Create a new Windows Application project in Visual Basic .NET or in Visual Basic 2005.</li> On the Project menu, click Add Web Reference.</li> Set a Web reference to the Web Service that you created in step 2, and then click Add Reference.</li>  Add a Button control to the form, double-click the button to create an event handler for its Click event, and then add the following code in the Button1_Click event handler: Private Sub Button1_Click(ByVal sender As System.Object, _   ByVal e As System.EventArgs) Handles Button1.Click

'This code assumes that you referenced the localhost server 'for your Web Service. Replace the line to follow with 'the correct namespace and service name. Dim ws As New localhost.Service1 Dim s As String = &quot;Hello&quot; ws.PassByVal(s) ws.PassByRef(s) End Sub </li>  Insert a breakpoint on the following line of code: ws.PassByVal(s) </li> In the Solution Explorer window, right-click the Windows Application project name, and then click Set as Startup Project.</li> Press F5 to run the application.</li> After the form loads, click the button. Notice that the debugger stops on the breakpoint that you set.</li> On the Debug menu, click Step Into. Notice that the debugger steps into the Web method in the ASP.NET Web Service project.</li>  Step through the code in the Web method so that control returns to the Windows Application project. Notice that the debugger stops on the following line of code in the Form class: ws.PassByRef(s) </li> On the Debug menu, click Step Into. Notice that the debugger steps over the call to the Web method instead of stepping into the Web method.</li></ol>

Additional query words: ref val

Keywords: kbvs2005swept kbvs2005applies kbvs2002sp1sweep kbbug kbnofix KB316175

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.