Build error: “The process cannot access the file because it is being used by another process”

后端 未结 30 1839
青春惊慌失措
青春惊慌失措 2020-12-13 03:08

I\'ve got a C# webforms app, that until today had been working just swimmingly.

Now today, all of a sudden, every time I try run the app, I get a file l

相关标签:
30条回答
  • 2020-12-13 03:42

    Recently ran into this problem when attempting to build a solution I am working on (not just a winforms proj).
    In addition to build failure, I noticed that cleaning projects would quietly fail (checking the bin folder showed that the files had not actually been erased) and closing the Visual Studio did not end the devenv process - rather, it caused it to crash. Windows recovery process would then restart the Visual Studio.

    After some trial and error, I found the problems only happened to me when I opened the solution from the "Recent" menu on starting up VS.
    Opening the solution from File >> Open >> Project/Solution found it working as per usually.

    Currently no idea why - will keep looking into this but for now, at least I can work!

    0 讨论(0)
  • 2020-12-13 03:43

    Well, I solved the problem myself - though I still have no clue why. I decided to isolate the problem by removing all files from the project, then re-adding them and determining that way which file was the source of my trouble. So, one by one I reintroduced files to the project, compiled & cleaned each step of the way... until... I added the last one...

    ... and everything still worked fine.

    I did a compare to the source control of my original .csproj; no real differences. And even when I tried reverting to the previous version of the .csproj, it still worked.

    Black magic. If it works, sometimes it's better not to ask why - just accept it and move on...

    EDIT: The problem is a recurring one, and I believe I've isolated it to when I have the form designer open of an abstract/generic form at compile time.

    Lesson learned: Make sure the Form Designer of any abstract or generic forms or controls is closed before you compile! If not, you have to close VS and reopen!

    0 讨论(0)
  • 2020-12-13 03:43

    What worked for me was restarting IIS

    0 讨论(0)
  • 2020-12-13 03:43

    Same error, solved by updating Google Nuget support packages

    0 讨论(0)
  • 2020-12-13 03:44

    I solved this by deleting the folder bin\Debug and, possibly, restarting VS

    0 讨论(0)
  • 2020-12-13 03:44

    I recently ran into the issue when deploying to Service Fabric. The error is implying a 'file' is in use, however, I found that the port was being used by another IDE. By stopping a running service which was already hosting on the port, I was able to stop this exception from occurring.

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