Microsoft KB Archive/814828

= BUG: You receive an &quot;identifier out of scope&quot; error message while evaluating expressions that contain Visual C# keywords =

Article ID: 814828

Article Last Modified on 1/19/2006

-

APPLIES TO


 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition

-



SYMPTOMS
When you try to evaluate some of the Visual C# expressions in the debugger, you may receive the following error message:

error: identifier  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.



Steps to Reproduce the Problem
 In Visual Studio .NET, create a new Visual C# .NET Console Application. Class1 is created.  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(&quot;The size of short is {0}.&quot;, sizeof(short)); Console.WriteLine(&quot;The size of int is {0}.&quot;, sizeof(int)); Console.WriteLine(&quot;The size of long is {0}.&quot;, sizeof(long)); } }

class MainClass {  public static void Main {     SizeClass.SizesOf; } }  Add a breakpoint on the last statement of the Sizeof method in the SizeClass class. In Solution Explorer, right-click Project, and then click Properties. In the left pane of the Property Pages dialog box, click Build under Configuration Properties. Set the Allow unsafe code blocks property in the right pane to True.</li> Build and run the application.</li> The application stops at the breakpoint.</li> Select the expression sizeof(short), and then drag the expression to the Name field of the Watch window.</li> 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 &quot;Symptoms&quot; section of this article.</li></ol>

Keywords: kberrmsg kbbug kbdebug KB814828

-

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

© Microsoft Corporation. All rights reserved.