none
Unable to copy file "obj\Debug\MyProject.exe" to "bin\Debug\MyProject.exe". The process cannot access the file "bin\Debug\MyProject.exe" because it is being used by another process.

    Question

  • I am developing a winforms project using Visual Studio 2010, on a Windows 2007 computer.

    Like so many others, I get the referenced error frequently when building a project, and I have read most if not all of the forum posts.

    I work around this by renaming the .exe and .pdb files in bin\debug.

    My question is whether this is resolved in later versions of Visual Studio, or can I expect to have to deal with this feature when I upgrade.

    Thanks!

    

    bill


    • Edited by belgie Wednesday, January 11, 2017 4:03 PM
    Wednesday, January 11, 2017 3:41 PM

Answers

  • Hi Bill,

    Thanks for your feedback.

    Actually I also met this kind of issue before, but like Weiwei previous suggestion, many possible reasons will generated this issue. Actually one real issue is that I couldn't repro this issue even if I use the VS2010 in my side, so it is hard for me to report this issue to the VS product team and mark sure that it is the VS's feedback. So if possible, we'd better to narrow down this issue:)

    I also provide some suggestions about the similar issue I met before:

    (1) Please close all third party tools like the Anti-virus, the firewall or others. Sometimes certain security software will impact the debugging.

    (2) Run your project as the admin, so we could make sure that whether it is related to the permission.

    (3) Disable the property "Enable the Visual Studio hosting process" in the project property.

     

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, January 13, 2017 2:14 AM
    Moderator

All replies

  • Hi bill,

    >>> My question is whether this is resolved in later versions of Visual Studio, or can I expect to have to deal with this feature when I upgrade.

    There are many reasons cause this issue based the error message on your post, so we need to make sure this issue is relate to the visual studio or your winforms project first.

    Is this issue only occur on this specific project or on other projects? If other project also has this issue. I would like to provide you the troubleshootings as follows:

    1. Close the designer editor before debugging your WinForms application. Though it`s not inconvenient for you.
    2. Use Task Manager or Process Monitor to see whether the application is really finished, if not, please end it.
    3. You can create a pre-build action in your project by going to project properties (right-click on the project in the solution explorer, and select the Properties option), select the Build Events tab. Add this code:
    if exist "$(TargetPath).locked" del "$(TargetPath).locked"
    if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"

    If on this specific project, please create a new project and move original project files to the new project one by one, which could help us confirm which file causes this issue.

    In addition, I have not meet this same issue so far in the Visual Studio 2015 update 3, so I suggest you to update your visual studio to version 2015.

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, January 12, 2017 9:37 AM
    Moderator
  • Weiwei - thank you for taking the time to respond.

    This happens intermittently on different projects, as reported by many other users.

    My question is whether MS has addressed and resolved this issue in later versions of VS.

    I have tried all of your troubleshootings, and others.  The only workarounds I have found that work include restarting VS and, as I mentioned in my original post, rename the .exe and .pdb files, which is tedious but more convenient than restarting VS.

    To your knowledge, has Microsoft addressed and resolved this bug?

    Thanks!

    Bill


    bill



    • Edited by belgie Thursday, January 12, 2017 2:35 PM
    Thursday, January 12, 2017 2:34 PM
  • Hi Bill,

    Thanks for your feedback.

    Actually I also met this kind of issue before, but like Weiwei previous suggestion, many possible reasons will generated this issue. Actually one real issue is that I couldn't repro this issue even if I use the VS2010 in my side, so it is hard for me to report this issue to the VS product team and mark sure that it is the VS's feedback. So if possible, we'd better to narrow down this issue:)

    I also provide some suggestions about the similar issue I met before:

    (1) Please close all third party tools like the Anti-virus, the firewall or others. Sometimes certain security software will impact the debugging.

    (2) Run your project as the admin, so we could make sure that whether it is related to the permission.

    (3) Disable the property "Enable the Visual Studio hosting process" in the project property.

     

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, January 13, 2017 2:14 AM
    Moderator
  • Hi Jack -

    Suggestion #3 seems to work for me, so I marked your response as the answer.

    I have read about this option, and it appears to come with some lost functionality in debugging but it is worth it for now, anyway.

    Thanks!

    Bill


    bill

    Friday, January 13, 2017 1:34 PM
  • @ Bill,

    If the solution resolve your issue, please mark it as the answer, so it would help other community members who meet the same issue, and I could close this case for you.

    Have a nice day,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, January 27, 2017 6:17 AM
    Moderator
  • Jack -

    Just because you can't reproduce a bug doesn't mean it doesn't exist.  This has been reported numerous times, with workarounds presented as a resolution.

    If I used that excuse, I would lose my job in one minute.

    Thanks!

    Bill

    Jack-Zhai says: " I couldn't repro this issue even if I use the VS2010 in my side, so it is hard for me to report this issue to the VS product team and mark sure that it is the VS's feedback."


    bill

    Tuesday, February 7, 2017 7:21 PM