VisualStudio2010 Debugging - the process cannot access the file ... because it is being used by another process

I cannot debug a WinForms C # application using the released version of Visual Studio 2010 Prof.

After a second debug run, the following error message appears.

Error 9 Failed to copy the 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 tried to create a pre-build script to try to delete this file, but it is blocked by Visual Studio.

There are several links to this on the net, so this is a problem with the information. Anyone have a fix or work efficiently?

+49
debugging visual-studio visual-studio-2010
Apr 22 2018-10-22T00:
source share
30 answers

I found this problem to be very easy to reproduce, and the fix for me is a variant of Richard Force's answer. If I have an open UserControl in the designer, start the debugger and then edit the UserControl, the subsequent rebuild will fail. If I close the UserControl before running the debugger, I will never get this error, so I just close the designer window before pressing F5.

+29
Aug 02 '10 at
source share

As of October 2012, I still have this problem, so VS 2010 SP1 did not solve the problem. What I did and worked consistently was disabling the hosting process in the projects.

To disable the hosting process:

. Open a project in Visual Studio. . On the Project menu, click Properties. . Click the Debug tab. . Clear the Enable the Visual Studio hosting process check box. 

Source: http://msdn.microsoft.com/en-us/library/ms185330(v=vs.100).aspx

+27
30 Oct.
source share

You can try to kill the vshost.exe process:

 taskkill /F /IM "Arrowgrass Reports.vshosts.exe" 

You might also be lucky and just move the file in question. You can move the file by adding the following lines of code to the preliminary build event of your project:

 if exist "$(TargetPath).locked" del "$(TargetPath).locked" if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked" 
+21
Apr 22 2018-10-22T00:
source share

Turning off windows search did not help me. However, disabling Anti-Virus (our Anti-Virus is Symantec Endpoint Protection 11)

Thus, I was able to fix this for myself by changing the Debug settings in the project to point the working folder to the path on the C: drive, and then exclude this path from anti-virus automatic protection settings.

I hope this helps someone.

+4
Jul 26 '11 at 18:29
source share

I posted this answer in a similar question, but decided that I would also say it here:

Okay ... this might seem pretty crazy.

I had this problem in VS2010 for the last couple of years. The workaround mentioned here works for me, but many times I forgot to close all my forms / user controls first.

I found that I was just browsing open files through:

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

will "release" which file is locked. Very strange, but it works for me!

+4
Aug 04 2018-11-11T00:
source share

In my case, I made the Project Properties β†’ Security Tab β†’ Uncheck Click-Once security settings (if installed). It worked for me. In my project, it showed this error for the C ++ dll used in my C # project.

+2
Aug 18 '14 at 9:45
source share

The described condition may also be caused by a violation of the DLL link itself or the EXE link; in this case, the Process Explorer test described earlier never returns a match (for example, it does not work). This unexpected situation, apparently, arises during some sequence of operations in VS2010 (and, probably, in all previous versions), which insidiously adds the link behind the curtains. The specific reason for this has not been tracked (or resolved, which I know of). To check and fix this error, just make sure that the corrupted DLL or EXE is not listed as a reference to itself.

+1
Apr 27 '11 at 18:44
source share

Got an error ("The process cannot access the file ... because it is being used by another process") when I changed the solution (Visual Studio 2010 C # Express Service Pack 1) from two large (10 source files, ~ 500 lines to one file) with one link to another, to a batch (6) of small projects with a large number of projects that link to other projects.

Links to dll and exe files (Debug versions of them), and not to projects, even if the projects were in the same solution.

Then I found out that links should be related to projects, not files, since F12 works correctly. So I changed the links. This made F12 work (go to the source file instead of the description of the automatically created interface), and at the same time the error "do not access the file" disappeared during the build.

I got a "do not access the file" error while executing the release build. The links were on the Debug exe / dll version. I suspect this confusion is what causes the error in VS.

+1
Aug 22 '11 at 9:30 a.m.
source share

I ran into this problem while developing Windows services. I found out that this happens when the service is running. Thus, you only need to stop the service (from the services.msc console), and you are good to go!

Hope this helps. Tijani.

+1
Aug 08 '12 at 14:57
source share

Check the task manager for the specified process and explicitly terminate the process. This solution worked for me.

+1
Dec 05 '12 at 11:50
source share

I can’t write a comment because it’s not at 50 points, but for me I deleted my project folder in ESET Enpoint Security ver 5. It seems that it blocked / clogged some files. My error did not indicate which exe or file was used, so it took a long time to finally get to the point that JoeC said about the antivirus and tried it. It seems to be working now (Visual Studio 2010 SP1)

+1
Jul 18 '14 at 8:05
source share

Closing the recently modified User Controls solved the problem in my scenario. Hope this helps someone out there.

+1
Dec 18 '14 at 8:55
source share
0
Mar 11 2018-11-11T00:
source share

Try uninstalling Windows Live SYNC. Is this still happening?

0
Jul 15 '11 at 14:50
source share

I think I just found the culprit and solution.

Go to the services and stop and disable the window search service.

This solved the problem for me now.

0
Jul 15 2018-11-15T00:
source share

For me, the solution was to change the startup project to dll (the problem only occurs in debug mode when there is an application as a launch). If your solution contains several projects (and it will, and it will contain .dll, otherwise you will not get the problem), switch to this .dll, no.vshost.exe, without problems.

Also, killing .vshost.exe did not work for me, because right after launch it again blocked .dll.

Also, make sure your links are clean, especially in more complex projects, and also prefer links to links to assembly links, etc. I believe that bad links (circular and similar) will inevitably cause problems, at least I read.

A short article from me on this issue (and my solution)

How to "clear" your links in a solution

0
Aug 14 '12 at 10:27
source share

Adding the following to the Pre-build event of a common dll worked for me:

 if exist "$(TargetPath).locked*" del "$(TargetPath).locked*" set exitprebuildfor$(ProjectName)= for /l %%a in (1,1,10) do ( if defined exitprebuildfor$(ProjectName) goto :ok if not exist "$(TargetPath).locked%%a" if exist "$(TargetPath)" move "$(TargetPath)" "$(TargetPath).locked%%a" & set exitprebuildfor$(ProjectName)=1) :ok set exitprebuildfor$(ProjectName)= 

This is based on the solution here , but instead of just renaming the dll to .locked, it tries to rename it to .locked1, locked2. Using 10, I usually run into the problem once a day, but you can use the ant value.

0
Nov 30 '12 at 14:20
source share

Just make a copy of the whole project and run the project from a new copy ... it will work fine. But you will have to finish the debugging process in some way to delete the old project.

0
Oct 21 '13 at 4:21
source share

Stop IIS and try creating it again, or if you can afford to restart your computer, try. Worked for me in both directions.

Greetings

0
Nov 06 '13 at 12:28
source share

My problem was that Outlook 2010 (outlook.exe) used the same port as my ASP.NET MVC project with IIS express.

Solution: close outlook.exe, run the solution and open Outlook again (so that it uses a different port).

Hope this helps someone because I got the same error message as described in this section.

0
Mar 05 '14 at 9:27
source share

Try deleting the .exe file in the debug or release folder (no matter what you are running) Windows will report that process X has opened it, and you cannot delete it after that, go to the task manager and in detail the task completion tab X process

0
Mar 16 '14 at 12:37
source share

Delete obj file. And stop your service and restart again. Then you can solve the problem.

0
Mar 19 '14 at 11:20
source share

The best solution for me was to transfer my project files from My Documents, which is located on a server managed by the IT department, and localize them locally on my C drive. Also works: uncheck the box "Enable Visual Studio Hosting Process" as other people have stated.

0
Aug 25 '14 at 2:02
source share

If you are working on a C # project using a link to the C DLL, you can resolve the error by checking the box "Allow insecure code." I know that I did not use pointers in my C # project, but I used some bitwise operator in C #. Perhaps these C-like functions turned it into "Unsafe" code.

0
Jan 30 '15 at 10:04
source share

What worked for me was to remove the read-only status in the bin folder. As soon as I did this, it has been working ever since.

0
Feb 18 '15 at 16:10
source share

I had this error when the project is on a remote resource (for example, if your $ env: home path using your IT department is redirected to a network resource). Make sure your project is on a local drive.

0
Apr 6 '15 at 19:31
source share

My problem started after creating a custom control and dragging it into the tool palette to use it in design forms. First, a warning appeared that there was redundancy between the source user control (.cs) file and project executable files (.exe). An error occurred during execution / debugging: it is impossible to access (.exe) because it is being used (and this was true).

Literally, the entire source code for the custom control was removed, and the last problem never stopped until I checked the links, and it referred to itself in order to be able to β€œget” the old user control. I deleted the link and did !!

So: just check the links and remove the self-esteem for the project.

0
Jul 27 '16 at 6:29
source share

Delete the bin folder and run the application. This worked for me. :)

0
Feb 03 '17 at 5:34 on
source share

Just turn off Visual Studio hosting when debugging, run the project and run it again and run the project.

Open the project in Visual Studio.

. From the Project menu, select Properties.

. Click on the Debug tab.

. Uncheck Enable Visual Studio Hosting Process.

0
May 19 '17 at 18:29
source share

For a Windows project

The Visual Studio hosting process may contain an executable pointer. To stop the host instance, open Project properties , and then go to the Debug tab. Now clear the Enable the Visual Studio hosting Process check box, and then check the box for debugging again.

For web project

IIS may contain a file pointer. Restarting IIS may fix the problem.

0
Jun 30 '17 at 15:08
source share



All Articles