Unable to copy a file from obj\Debug to bin\Debug

后端 未结 30 1211
清歌不尽
清歌不尽 2020-12-02 12:04

I have a project in C# and I get this error every time I try to compile the project:

(Unable to copy file \"obj\\Debug\\Project1.exe\" to \"bin\\Debug

相关标签:
30条回答
  • 2020-12-02 12:35

    A very simple solution is to open the Task Manager (CTRL + ALT + DELETE), go to Processes tab and search by name the processes with your project name that are still running. Kill all the processes and go on ! :)

    0 讨论(0)
  • 2020-12-02 12:36

    I too had the same issue. I resolved it

    Closed my VS, then in Task Manager, End tasks like Microsoft VisualStudio WCF Tools, MSBuild.exe

    Then open VS and clean and rebuild.

    0 讨论(0)
  • 2020-12-02 12:37

    after day with search and build and rebuild i found that you just need to turn off turn on the visual studio its look like it catch the service in different thread

    0 讨论(0)
  • 2020-12-02 12:40

    Not a direct answer to your question..

    One scenario when this can come is listed below -

    If your application is under Debugging process - say by "Attach to Process" debugging, this error may come

    0 讨论(0)
  • 2020-12-02 12:41

    @Udpate: Since the time I was first posting this 'answer', I tend to another explanation to the problem. The issue since than happened more and more often outside of Visual Studio also - while trying to copy an .exe file from one folder to another. While in the first place Windows did not allow to copy(!) an .exe file (it was first asking me for administrative rights but refused to copy it afterwards anyway) it still showed up in the explorer. But after a while - without any further action taken, it disappeared magically. Just like the problem in the question always seems to solve itself after a while. So i assume, the problem is more related to a delayed deletion of the project output file and less a buggy VS. I apologize for any unjustified suspicion. :|

    This gives the search for a solution a complete different direction, I guess. Did find that link and will update on any progress:

    https://superuser.com/questions/234569/windows-7-delayed-file-delete

    ========================================================================

    This is a known bug in VS. I discovered it very often - mostly in VS2010 (with/without SP1). Several "solutions" are recommended. Some of them, which kind of helped for me:

    1. Delete the .suo file in your project dir. Eventually need to create your whole solution from scratch.
    2. Close any Windows Form Designers may remain open.
    3. Use a prebuild script, which deletes the target from the output dir.
    4. Disable the VS hosting process.

    None of these really fixes the bug. But it may brings the VS back to a usable state - until a true solution is provided by MS (if ever will).

    http://social.msdn.microsoft.com/Forums/en/vsdebug/thread/cea5e4b2-5b33-453c-bffb-8da9f1a1fa4a

    http://social.msdn.microsoft.com/Forums/en/vbide/thread/cd12f3c7-de96-4353-adce-23975e30933f

    0 讨论(0)
  • 2020-12-02 12:41

    I found that ending all msbuild.exe tasks (in Task Manager) fixed the issue with VS2012.

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