error CS2012: Cannot open <executable path> access to <executable path denied>
Asked Answered
C

6

10

I was working on a WPF application in Visual Studio 2015 and all went well until unexpectedly the build dropped me the CS2012 error inform me that it cannot access/update the executable in the /Debug directory.

I tried the following and it didn't work:

  1. Restart
  2. Close VS and open the application again
  3. Build->Clean

I couldn't find any solution in the web so I tried: 1. to move the whole project directory to another location. 2. creating a new WPF project and assembling it file by file with copy/pastes.

The weird thing was that in both cases the application worked in the new location. I continued the experimentation (in the original directory) and i tried to build a "Hello World" Console application in the same directory. The result was that the trivial console application didn't work and produced the same problem as the WPF application (CS2012 error).

Since I haven't noticed any activity of another program (i.e., antivirus) trying to quarantine (or changing the file/folder permissions of) this folder, I assume that this has been done by VS somehow but I don't know why. Perhaps it is a bug.

Is anyone has a logical explanation about this problem? And a way to fix it?

Courtyard answered 31/5, 2016 at 18:8 Comment(3)
I get the same error message every now and then after installing VS2015 running the same code base in VS2013 I have zero issues. I usually have to do a Clean, the Build, if that doesn't work I open Task Manager and Kill the name of the Application that's running in vs2015 then all works..also I run the application in Administrator ModeTungstite
@vishakh369 Stop making garbage edit suggestions.Downtoearth
Restarting Visual Studio worked for meEmbree
F
9

I found that my other running solution was referencing the same < executable path>.

Just make sure that no other process is using the referenced folder/file/dll

Factional answered 13/9, 2016 at 12:23 Comment(1)
If you are using antivirus app such as Bitdefender. It may also cause this error. Llook its notificaitions.Flo
T
3

Deactivate your anti-virus for a while and try again.

This works for me.

Tonga answered 21/3, 2021 at 11:16 Comment(0)
A
2

Try to close all processes, move the project to a different folder (on a different disk) b restart the computer and everything will work as it should. It worked for me without any problems. Hope this helps someone

Allhallows answered 8/8, 2020 at 12:29 Comment(1)
This does not provide an answer to the question. Once you have sufficient [reputation] (stackoverflow.com/help/whats-reputation) you will be able to comment on any post; instead, provide answers that don't require clarification from the asker.Dashtikavir
B
2

I wanted to quickly test something in a .NET Core Console Application Solution and ran into this issue due to BitDefender blocking the resulting binaries.
I've named the app client which actually was the culprit. Renaming my solution fixed this.

Blowhole answered 18/4, 2021 at 15:12 Comment(0)
S
1

Sometimes antivirus softwares can block copying an exe file from a folder to any path. You can manage by settings or the easiest way is to shut down live protection while you are coding and debugging. :)

Sinh answered 8/4, 2020 at 14:9 Comment(0)
T
0

In my case, due to some weird reason, the entire folder containing the solution had the read-only property enabled, disabling it worked for me!

Go to the folder containing the solution, right click and un-check the read-only attribute for it.

Titillate answered 11/4 at 18:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.