"Edits were made which cannot be compiled" . zero errors and Enable and edit and continue is checked in vs2010

Viewed 20485

I am able to edit my code in debug mode but then pop up shows the error that

Edits were made which cannot be compiled. Execution cannot continue until the compile errors are fixed

but error list is empty and i have checked enable edit and continue.

I am using vs2010.

Cleaning and restarting has not solved the problem.

11 Answers

In Visual Studio

Debug --> Options --> Debugging --> General --> uncheck Enable Edit and Continue

I had the same problem (VS2017), for me it was enough to menu item Build and click Clean Solution Then Rebuild Solution and everything worked fine again.

Potentially this is caused by Visual Studio's Edit & Continue feature.
A workaround is to disable this feature:

Debug --> Options --> Debugging --> General --> uncheck Enable Edit and Continue

Solution taken from here.

Also answered here.

I had this problem as well in a c# project. It turns out it was because I had recently enabled the "Enable native code debugging" option.

Turning it off restored the functionality.

There is another possible culprit:

It may be a problem with one of the projects that are included in the solution.

I had the exact same problem, as did a co-worker of mine, and the culprit was one of the projects in our .sln file; a WinForms application that was also started in connection with several other projects in the same solution file.

The remedy was simple:

Remove the WinForms project from the solution, and start a separate Visual Studio instance, where the WinForm project was separated from the rest. And then it worked. I think there is some file edited when the WinForms application was run, that changed the code, for some reason.

Sorry for a bit late answer but might be it can help out some other technologist. I had faced the same issue in my VS2019 & VS2022 and find 2 solutions.

Solution 01:

i. Tools/Debug => Options => Debugging => General --> Enable Edit and Continue [uncheck it]

ii. Rebuild Code

iii. Tools/Debug => Options => Debugging => General --> Enable Edit and Continue [check it again]

Solution 02:

i. Close your Visual Studio.

ii. Delete the .vs hidden-folder (For safe side, rename it instead to delete)

iii. Reopen your Visual Studio and run the project again.

Hope it'll work!

This type of error message could occur in three categories as I know so far:

  1. Visual Studio setting, like you have to set Visual Studio IDE environment properly
  2. Source control related
  3. Your method of code does have an interop related API that doesn't like to be edited in the debugging mode

Most people could fix their problem by going through #1. To make sure if your Studio setting is right, simply run a new and very small solution, and edit it in debugging mode. If that gives you the same error message, then your problem is with Bill Gates:), go fixing the configurations. If no error, shift focus to your own code.

Try to edit in debugging mode in a separate method in your solution. This error could be method dependent if the critical part is not in the global area. After narrowing down the problem to a method, well, you are close to a good luck. Commenting out most or all contents in the method, and gradually un-comment the lines. You will eventually ping down to the point where the problem gets triggered.

In my case, it is the Excel file application that caused the problem. The solution: I created the objects of Excel app, workbook, and worksheet as global variables, and open and defined them in one of my main method. Somehow, after doing so, Bill Gates doesn't like to me fool around the method any more in debugging mode. My trick to go around Bill is to write the workbook opening and worksheet definition in a small separate method, and just call that it from the original method. After that, I can happily edit any part in the big method during debugging run time! Still, I cannot do that in that small method that just contains the workbook and worksheet handling. Well, that is Bill's comfortable work place:) I don't need to.

Related