Editing code in Visual Studio 2008 in debug mode

后端 未结 7 603
别跟我提以往
别跟我提以往 2021-02-04 07:12

I am curious to know if there is a way to edit code in C# VS 2008 right when it has hit a breakpoint and I am walking thru the code... can I modify the code (such as the value i

相关标签:
7条回答
  • 2021-02-04 07:53

    To modify the value of a variable or set a property while in break mode go to the Immediate window, set the new value, and hit return e.g.

    strValue = "newValue"
    Calendar1.Enabled = true
    

    To retrieve a value you can just print it to the window e.e.

    ?strValue
    ?Calendar1.Enabled
    
    0 讨论(0)
  • 2021-02-04 07:55

    Yes, you can.
    This is called Edit and Continue.
    Note that it has some limitations.

    EDIT: You need to switch to a debug build.

    0 讨论(0)
  • 2021-02-04 08:06
    1. Stop running your app.
    2. Go to Tools > Options > Debugging > Edit and Continue
    3. Disable “Enable Edit and Continue”.
    0 讨论(0)
  • 2021-02-04 08:06

    Below answer worked for me :

    http://whyiamright.wordpress.com/2007/12/20/aspnet-edit-and-continue-in-visual-studio-2005/

    The second point says - project-properties-web-> enable edit and continue.

    thats it.

    0 讨论(0)
  • 2021-02-04 08:11

    To solve this problem I did the following...

    BUILD > CONFIGURATION MANAGER

    Active solution configuration: DEBUG project context configuration: DEBUG

    then TOOLS > OPTIONS > DEBUGGING > EDIT & CONTINUE make sure edit & continue is selected

    then BUILD > CLEAN SOLUTION then BUILD > REBUILD SOLUTION

    Then start debug, then pause, then your code should be editable

    0 讨论(0)
  • 2021-02-04 08:14

    In response to this question:

    can I modify the code (such as the value in a variable or if my stepthrough line is about to hit an if statement ... can I modify the if statement....etc)?

    You cannot pop a new value into a variable directly, but what you can do is this:

    1. Set a breakpoint
    2. When that breakpoint is hit, click on the arrow in the left margin and drag it up to a previous line
    3. Now you can add code to change the circumstances (for example, you can set a variable to a new value, add/remove items from a collection, etc.)

    See the other answers about enabling Edit & Continue -- in particular, make sure you're in Debug mode.

    0 讨论(0)
提交回复
热议问题