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

北城以北 提交于 2020-12-05 09:57:45

问题


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?


回答1:


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




回答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




回答3:


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. :)




回答4:


I have experience the same thing today. My company forced a system update that installs microsoft updates.

Now, I create a new Winform project, with just a blank form...get the same error.

If I open an existing solution, I don't get the error, it's just for new solutions/projects.



来源:https://stackoverflow.com/questions/37552769/error-cs2012-cannot-open-executable-path-access-to-executable-path-denied

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!