Error: Cannot access file bin/Debug/… because it i

2019-01-03 22:39发布

When I debug my project, I get following error:

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

Using Process Explorer, I see that MyApplication.exe was out but System process still uses it although I stopped debug before. Whenever I change my code and start debug it is going to happen. If I copy project to USB and debug, it runs OK.

Why? How can I fix this error?

I use Window 7 Professional. With Xp I have never got this error.

26条回答
Summer. ? 凉城
2楼-- · 2019-01-03 23:07

This is pure speculation, and not an answer.

However, I have been having this problem for a while.

I came after a time to suspect an interaction between VS and my AV precautions.

After some playing, it seems that it may have gone away when I modified my antivirus so that everything under the

C:\Users[username]\AppData\Local\Microsoft\VisualStudio\10.0\ProjectAssemblies

folder was not included in the real-time protection.

It looks as if the build actually writes the DLL here first, then copies it to the final build location.

查看更多
Root(大扎)
3楼-- · 2019-01-03 23:07

Another kludge, ugh, but it's easy and works for me in VS 2013. Click on the project. In the properties panel should be an entry named Project File with a value

(your project name).vbproj

Change the project name - such as adding an -01 to the end. The original .zip file that was locked is still there, but no longer referenced ... so your work can continue. Next time the computer is rebooted, that lock disappears and you can delete the errant file.

查看更多
不美不萌又怎样
4楼-- · 2019-01-03 23:10

Computer (right-click) -> manage -> Service & Application -> service -> Enable Application experience

Worked For me!

查看更多
Juvenile、少年°
5楼-- · 2019-01-03 23:10

Recently I've been in a trouble with Visual Studio 2012 with same error description: "The process cannot access the file because it is being used by another process..."

To fix this first of all you need to understand the application which still use it. I've shutdown all processes like "MSBuild" and "MSBuild host". But this is not enough. If you have installed "Code Contracts" and turned on then it sometimes takes your DLLs for checking and hanging up on this operation.

So, you need to stop all processes of "CCCheck.exe" and that's all.

Finally, to understand that process is using your DLL you always may try to just Delete "obj" folder in your File Manager and this operation will fail, you may see the "Message Window" with description of the hanging operation. Also, as a variant, you can try to use "Sys Internals Suite" application.

查看更多
Anthone
6楼-- · 2019-01-03 23:10

My problem was dotnet got hung up and whenever VS would try to make a new dll, or access an old one, the dotnet process would latch onto the dll and stop visual studio from cloning the dll. Solution is just to end all dotnet tasks in task manager(it will only actually remove the dead one, if you are trying to end one and it won't shut down, that means it's working).

查看更多
Viruses.
7楼-- · 2019-01-03 23:10

Run taskmanager.
Locate netcore and delete it.
You can then delete the file manually or by running Clean.

查看更多
登录 后发表回答