BUG: Cannot step into Web method when you debug the ASP.NET Web service (316175)



The information in this article applies to:

  • Microsoft Visual Basic 2005 Express Edition
  • Microsoft Visual Basic .NET (2003)
  • Microsoft Visual Basic .NET (2002)

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

  1. Start Visual Studio .NET or Visual Studio 2005.
  2. Create a new ASP.NET Web Service in Visual Basic .NET or in Visual Basic 2005.
  3. Open the Code window, and then add the following Web methods to the module:
    <WebMethod()> Public Function PassByRef(ByRef s As String) As String
        s = "Goodbye"
        Return s
    End Function
    
    <WebMethod()> Public Function PassByVal(ByVal s As String) As String
        s = "Goodbye"
        Return s
    End Function
    					
  4. On the Build menu, click Build Solution to build the Web Service.
  5. On the File menu, point to Add Project, and then click New Project.
  6. Create a new Windows Application project in Visual Basic .NET or in Visual Basic 2005.
  7. On the Project menu, click Add Web Reference.
  8. Set a Web reference to the Web Service that you created in step 2, and then click Add Reference.
  9. 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 = "Hello"
            ws.PassByVal(s)
            ws.PassByRef(s)
        End Sub
    					
  10. Insert a breakpoint on the following line of code:
            ws.PassByVal(s)
    					
  11. In the Solution Explorer window, right-click the Windows Application project name, and then click Set as Startup Project.
  12. Press F5 to run the application.
  13. After the form loads, click the button. Notice that the debugger stops on the breakpoint that you set.
  14. On the Debug menu, click Step Into. Notice that the debugger steps into the Web method in the ASP.NET Web Service project.
  15. 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)
    					
  16. 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.

Modification Type:MajorLast Reviewed:3/3/2006
Keywords:kbvs2005swept kbvs2005applies kbvs2002sp1sweep kbbug kbnofix KB316175