Share via


Error BC2012 Can't Open for writing: Access to the path is denied.

Question

Friday, February 12, 2016 12:39 AM

Running VS2015 with Win10, .NET Framework 4.5, project is in VB. Was able to run project approximately 2,000 times before the error started occurring:
"vbc : error BC2012: can't open 'C:\MyProject\ProjR5\ProjR5\obj\Debug\ProjR5.exe' for writing: Access to the path 'C:\MyProject\ProjR5\ProjR5\obj\Debug\ProjR5.exe' is denied."

I have checked the path, the the ProjR5.exe doesn't even exist, yet upon starting the build, VS is looking for it, however, based on the error semantics, the issue isn't the missing file, but the denial of access to anything in the path ... or is it?

I have spent a greater portion of three days scouring the web for a solution to the problem, to no avail. Here is what I have tried to alleviate this problem ... Have I missed something?

  • ran sfc /scannow (elevated prompt)
  • Using ProcessExplorer, find handle or DLL substring that included my project
  • Made sure there were no hanging procs (including procs with my project name, devenv.exe, [project].exe, [myproject].vhost.exe, etc.)
  • Restarted VS2015
  • Restarted VS2015, running "as Administrator"
  • Restarted Computer
  • Full Shutdown of computer
  • Complete Rebuild of Solution
  • Complete Reentry of all code from scratch
  • Removed all references
  • Re-added all references
  • Build->Clean Solution
  • Build->Clean Solution, then Build->Build Solution
  • Build->Rebuild Solution
  • Uninstalled and Reinstalled VS2015
  • Disabled All Indexing
  • Removed "Read Only" attribute from entire project folder
  • Checked startup scripts for like- or identical processes
  • Disabled all antivirus apps
  • Disabled all antispyware apps
  • Disabled all firewalls
  • Verified Application Experience (in services.msc) wasn't disabled (I'm using Win10 ... it isn't in the list of services)
  • Set Tools->Options->Projects and Solutions->Build and Run->Max. parallel builds to 1
  • Rerun aspnet_regiis.exe (under .NET\Framework)
  • Checked Local Security Policies and verified account was listed under "Impersonate a client after authentication"
  • Removed \bin and \obj folders altogether
  • Put \bin and \obj back when removing didn't help

I'm sure I've overlooked something right in front of my nose. Any ideas?

All replies (4)

Monday, February 15, 2016 3:32 AM âś…Answered

Hi Garrett Holland,

Thanks for your post.

I did a research for your issue, and I found you have also posted this case in the stackoverflow forum.

And you have shared the solution there:

http://stackoverflow.com/questions/35353300/visual-studio-2015-cant-open-project-exe-for-writing-access-to-path-denied

Since you have found the solution. if possible, please also mark the reply as the answer, so it would be helpful for other members who get the same issue as yours to research and find the answer directly, and I could close this case.

Have a nice day.

Best Regards,

Lake Xiao


Friday, February 12, 2016 9:04 AM

Hi Garrett Holland,

  1. Does the folder  'C:\MyProject\ProjR5\ProjR5\obj\Debug' exist?
  2. If exists, please inform all files in this folder.
    Regards.

Wednesday, April 17, 2019 4:19 PM

I'll post the same text as i write on stackoverflow, for the devs who need help.

This work for me:

It's quite simple, just change your proyect assembly name:

  1. On your solution explorer: Right click on your proyect.
  2. Properties>> aplication>> assembly name>> change it. 
  3. Compile, run to test it.
  4. Change the name again if u wanted the original name.

Saturday, January 4, 2020 8:15 AM

I know that it is an old thread but i want to share my procedures to solve this issue,

I'm still facing it ,

**Go to Build then Clean ... OR Rebuild **

that's all

** **

Regards From Egypt