Reputation: 322
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:
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?
Upvotes: 11
Views: 25850
Reputation: 11
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.
Upvotes: 1
Reputation: 75
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.
Upvotes: 2
Reputation: 59
Deactivate your anti-virus for a while and try again.
This works for me.
Upvotes: 3
Reputation: 21
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
Upvotes: 2
Reputation: 11
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. :)
Upvotes: 1
Reputation: 2412
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
Upvotes: 9