Unable to copy file .exe in Visual Studio 2017

Viewed 2673

I have an asp.net core project that references .NET Framework and I'm using Visual Studio 2017 Enterprise. When I try to build my solution, I came across with this error:

Unable to copy file "obj\Debug\net461\MyProject.exe" to "bin\Debug\net461\MyProject.exe". 
Access to the path 'bin\Debug\net461\MyProject.exe' is denied.

Even if I cleaned the solution and build again, I still have this error.

Anyone faced this error?

4 Answers

Close the application and delete Obj and bin folder

First, make sure you have the .net core localhost server stopped, before trying to build the solution.

I have seen this error before. Trying the following has worked for me:

1. Close the current solution.
2. Close Visual Studio.
3. Start Visual Studio in Administrator mode.
4. Re-open and build the solution.

The above can avoid the common copy file and file Access Denied errors.

Related