Search code examples
c#visual-studiosaveloadwindows-forms-designer

I renamed form and forgot to save visual studio C# - How do I fix this error?


I renamed a form and forgot to save my Visual Studio Project. Now I am getting this error: The file does not support code parsing or generation because it is not contained within a project that supports code.

I can still see the original form name and when I double click the specific form this is the error I get: the item does not exist it may have been moved, renamed, or deleted

How do I fix my problem? I just want access to the form I renamed and I am guessing the project is not reading for the new one (but unsaved) and is searching for the original which does not exist anymore.


Solution

  • Solved this problem from @KingOfArrows 's comment, but I may as well post it here. I was able to solve the issue by editing every instance of the old version in the .csproj file by:

    1. Right clicking on the project and selecting unload project in the solution viewer
    2. Right clicking the project and clicking edit project file (if it hadn't already appeared automatically), and then changing every reference of the old name to the new name in the text
    3. I closed out of the entire visual studio application and when I reopened it, I right clicked again the project in the solution viewer and clicked reload project, causing everything to work properly.

    I hope this helps anyone if they run into the same issue.