Microsoft KB Archive/316569

= FIX: You cannot step into a stored procedure from ASP.NET code on Windows Server 2003 =

Article ID: 316569

Article Last Modified on 7/10/2006

-

APPLIES TO


 * Microsoft Visual Basic .NET 2002 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition
 * Microsoft .NET Framework 1.1 Service Pack 1
 * Microsoft Windows Server 2003, Standard Edition (32-bit x86)

-



This article was previously published under Q316569



SYMPTOMS
On Windows Server 2003, if Microsoft Internet Information Services (IIS) 6.0 runs in Worker Process Isolation Mode (WPIM) mode, you cannot step from managed code into a Microsoft SQL Server stored procedure while you debug in the Visual Studio .NET integrated development environment (IDE).

You do not receive any error messages. However, the stored procedure window does not appear while you step through the ASP.NET code.



CAUSE
When you invoke SQL debugging, the debugger creates a shared memory segment of debugging information. Multiple processes that are involved in debugging stored procedures can use this debugging information.

However, only local administrators and the SYSTEM account have permission to access this shared memory segment. The client process that is being debugged (IIS 6.0 [W3WP.exe]), which runs in the security context of the NETWORK_SERVICE account, cannot access this shared memory segment and therefore cannot enable SQL debugging.



RESOLUTION
Use one of the following methods to work around this problem:  Run IIS 6.0 in IIS 5.0 isolation mode. When IIS 6.0 runs in IIS 5.0 isolation mode, IIS runs in the security context of the SYSTEM account. This gives IIS access to the shared memory segment so that IIS can enable SQL debugging. By default, IIS 6.0 is installed to run in Worker Process Isolation Mode (WPIM) mode. To change this setting, follow these steps:  Open the IIS manager. Right-click Web Sites, and then click Properties. Click the Service tab, and then click to select the Run WWW service in IIS 5.0 isolation mode check box.

Note that when you change this setting, you must restart IIS. Change permissions. In a secure testing environment, you can add the NETWORK_SERVICE account to the local administrators group to give this account access to the shared memory segment. However, Microsoft strongly discourages this approach for security reasons.</li></ul>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section. This bug was corrected in Microsoft Visual Basic .NET 2003, Microsoft Visual C# .NET 2003, and ADO.NET (included with the .NET Framework 1.1).

<div class="moreinformation_section">

Steps to reproduce the behavior
 On a Windows Server 2003-based computer, make sure that IIS is configured to run in non-legacy mode.</li> In Microsoft Visual Studio .NET, on the File menu, point to New, and then click Project.</li> In the New Project dialog box, click Visual Basic Projects under Project Types, and then click ASP.NET Web Application under Templates.</li> Add a Button control from the toolbox to WebForm1.</li>  Add the following code to the top of the code window: Imports System.Data.SqlClient </li>  Add the following code to the Click event of the button:

Note You must change User ID= and password = to the correct values before you run this code. Make sure that User ID has the appropriate permissions to perform this operation on the database. Dim cn As SqlConnection Dim strCn As String Dim cmd As SqlCommand Dim prm As SqlParameter strCn = &quot;Data Source=(local);Initial Catalog=Northwind;&quot; & _ &quot;User ID= ;Password= &quot; cn = New SqlConnection(strCn) cmd = New SqlCommand(&quot;CustOrderHist&quot;, cn) cmd.CommandType = CommandType.StoredProcedure prm = New SqlParameter(&quot;@CustomerID&quot;, SqlDbType.Char, 5) prm.Direction = ParameterDirection.Input cmd.Parameters.Add(prm) cmd.Parameters(&quot;@CustomerID&quot;).Value = &quot;ALFKI&quot; cn.Open Dim dr As SqlDataReader = cmd.ExecuteReader While dr.Read Response.Write(&quot;Product ordered: &quot; & dr.GetSqlString(0).ToString & &quot;<BR>&quot;) End While dr.Close cn.Close </li> Modify the SQL Server connection string as necessary for your environment.</li> In the Project Explorer window, right-click on the project (not the solution), and then click Properties. Click Configuration Properties, and then click to select the SQL Server Debugging check box on the Debugging page to enable stored procedure debugging.</li>  Set a breakpoint on the following line of code: Dim dr As SqlDataReader = cmd.ExecuteReader </li> In Server Explorer, locate the CustOrderHist stored procedure. Right-click the stored procedure, and then click Edit Stored Procedure.</li> Set a breakpoint in the stored procedure on the SELECT statement, which appears as one line of executable code.</li> Press the F5 key to run the Visual Basic project, and then click the command button. The code runs until it hits the breakpoint that you set before the stored procedure is called.</li> Press the F11 key. You expect to step into the code of the stored procedure. Instead, the debugger skips the stored procedure and continues with the next line of Visual Basic code.</li></ol>

Keywords: kbbug kbfix kbnofix kbstoredproc kbtsql kbdebug kbvs2002sp1sweep KB316569

-

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

© Microsoft Corporation. All rights reserved.