'Unable to set the next statement. The next statement cannot be changed at this time
I suddenly started experiencing this error in Visual Studio 2015 and 2017, when trying to move the yellow cursor (next statement) in debugmode.
The code I want to move over is nothing special (i.e does not include any try-catch and/or exception statements) and stepping through the code (F10, F11) works normally.
Here is a code sample:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ddlCountry.SelectedIndex = 0;
ddlCountry.DataSource = new List<string>() {"Germany", "Japan"};
ddlCountry.DataBind();
}
}
The solution contains multiple web projects and console projects, but the error does not occur in the console projects - only in the web projects. I.e in the console projects, I can move the yellow cursor with no problems.
When I try to do the same in any other solution, I have no problems, so it seems to be something related to my current solution.
These are the things I tried so far:
- Started Visual Studio as admin
- Tried to move the yellow cursor in both vs2015 and vs2017 (same project, same file) - same result
- Visual Studio 2015 repair installation
- Start Visual Studio, using the following command "devenv.exe /resetuserdata", in order to try to reset all userdata
- Tools --> Import and Export Settings --> Reset all settings
- Deleted the .suo file
All the suggestions I found on Google have not proved very helpful in solving this issue, so if anyone here can assist, I would be really glad.
Solution 1:[1]
Solution 2:[2]
I had it on vs2022, Restarting vs2022 solved it, Microsoft should fix it or at least give this solution in the error message at least.
Solution 3:[3]
Deleting bin and obj folders from project can fix a lot of issues
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | james murphy |
| Solution 2 | Ronen Festinger |
| Solution 3 | Simon H |


