BUG: You receive an "identifier out of scope" error message while evaluating expressions that contain Visual C# keywords (814828)



The information in this article applies to:

  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual C# .NET (2002)

SYMPTOMS

When you try to evaluate some of the Visual C# expressions in the debugger, you may receive the following error message:
error: identifier <visual c# keyword> out of scope
The Visual C# keywords that display this error are base, sizeof and typeof.

CAUSE

The problem occurs because the expression evaluator of the debugger cannot evaluate the expressions that contain some of the Visual C# keywords.

STATUS

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

MORE INFORMATION

Steps to Reproduce the Problem

  1. In Visual Studio .NET, create a new Visual C# .NET Console Application. Class1 is created.
  2. Replace the existing code in Class1.cs with the following code:
    
    // Using the sizeof operator
    using System;
    class SizeClass 
    {
       unsafe public static void SizesOf() 
       {
          Console.WriteLine("The size of short is {0}.", sizeof(short));
          Console.WriteLine("The size of int is {0}.", sizeof(int));
          Console.WriteLine("The size of long is {0}.", sizeof(long));
       }
    }
    
    class MainClass 
    {
       public static void Main() 
       {
          SizeClass.SizesOf();
       }
    }
    
  3. Add a breakpoint on the last statement of the Sizeof method in the SizeClass class.
  4. In Solution Explorer, right-click Project, and then click Properties.
  5. In the left pane of the Property Pages dialog box, click Build under Configuration Properties.
  6. Set the Allow unsafe code blocks property in the right pane to True.
  7. Build and run the application.
  8. The application stops at the breakpoint.
  9. Select the expression sizeof(short), and then drag the expression to the Name field of the Watch window.
  10. In the Value field of the Watch window corresponding the row where you have dropped the expression, you receive the error message that is described in the "Symptoms" section of this article.

Modification Type:MinorLast Reviewed:1/19/2006
Keywords:kberrmsg kbDebug kbBug KB814828 kbAudDeveloper