VisualStudio2010 Debugging - The process cannot ac

2019-01-13 01:36发布

I'm unable to debug a WinForms C# application using the released version of Visual Studio 2010 Prof.

I get the following error message after the second debugging run.

Error 9 Unable to copy file "obj\x86\Debug\Arrowgrass Reports.exe" to "bin\Debug\Arrowgrass Reports.exe". The process cannot access the file 'bin\Debug\Arrowgrass Reports.exe' because it is being used by another process.

I've tried a pre-build script to attempt to delete this file, but it's locked by Visual Studio.

There are a few references to this on the net so it is a know problem. Does anyone have a hotfix or effective work-around?

30条回答
走好不送
2楼-- · 2019-01-13 01:49

Check Task Manager for the specified process and End the process explicitly. This solution worked for me.

查看更多
Bombasti
3楼-- · 2019-01-13 01:49

Please try uninstalling Windows Live SYNC. Does it still happen?

查看更多
Emotional °昔
4楼-- · 2019-01-13 01:49

Try deleting .exe file in debug or release folder (whatever you working on) Windows will prompt that the process X has opened this and you can't delete it after that go to task manager and in details tab end task X process

查看更多
我只想做你的唯一
5楼-- · 2019-01-13 01:51

Disabling windows search did not fix for me. However disabling Antivirus did (our Antivirus is Symantec Endpoint Protection 11)

As such, I was able to fix this for myself by changing the Debug settings in the project to point the working folder to a path on the C: drive, and then excepting that path from the antivirus auto-protect scan settings.

I hope this helps someone.

查看更多
唯我独甜
6楼-- · 2019-01-13 01:51

For me the solution was to change the startup project to a dll (problem only occurs in debug mode when having an application as the startup project). If your solution contains several projects (and it will, and it will contain a .dll, else you would not get the problem), switch to that .dll, no .vshost.exe, no problem.

Also, killing .vshost.exe did not work for me, since immediately after starting again, it had locked the .dll.

Also, make sure to have your references clean, especially in more complex projects, and also prefer project references to assembly references, and so on. I suppose bad references (circular and similar) are bound to cause problems, at least so I have read.

A short article by me on this problem (and my solution)

How to "clean up" your references in a solution

查看更多
【Aperson】
7楼-- · 2019-01-13 01:53

I posted this answer in a similar question but figured I'd also say it here:

Alright... this might sound pretty crazy.

I've had this problem in VS2010 for the last couple of years. The workaround mentioned here works for me, but a lot of times I forgot to close all my forms/usercontrols first.

I've discovered that merely going to view the open files via:

Computer Management (compmgmt.msc)->Shared Folders->Open Files

will "Free up" whichever file is being locked. Very strange, but it works for me!

查看更多
登录 后发表回答