Thread: Visual Studio - Can't see variables in Autos/Local window

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    18

    Visual Studio - Can't see variables in Autos/Local window

    Hi,

    I'm new to C# and Visual studio (2010).

    I have created a new C# Windows Form project.

    Inside of main() and have added two lines:

    Code:
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
    
                string stra = "aaa";//line 1
                string strb = "bbb";//line 2
                
    
            }
    My question is why I can't see the two string variables inside of the Autos/Locals watch window when I set a breakpoint straight after them and hit debug.

    When I create a console application I see them fine, but when it's a Windows Form application I cannot see them.

    I have found people in Google saying that code optimisation might be enabled in the IDE settings, but it isn't.

    Can anyone help me here?

    Thank you.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    They're likely being optimized out by the compiler. Make sure you're in Debug mode instead of Release and see if that makes them show up.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 02-03-2012, 09:58 PM
  2. Replies: 6
    Last Post: 12-02-2009, 08:47 AM
  3. Replies: 2
    Last Post: 07-08-2008, 03:45 AM
  4. Visual Studio C++ 2005 first task "Create a window"
    By csonx_p in forum Windows Programming
    Replies: 3
    Last Post: 04-15-2008, 05:49 AM
  5. visual studio 6 and visual studio.net difference
    By gemini_shooter in forum Tech Board
    Replies: 5
    Last Post: 02-04-2006, 01:32 AM