Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio solution doesn't compile, but project does

When I build or rebuild my solution I get the error:

Error CS2012 Cannot open 'C:\Users\myUserName\Documents\Visual Studio 2017\Projects\mySolutionFolder\myProjectFolder\obj\Debug\myExecutable.exe' for writing -- 'Access to the path 'C:\Users\myUserName\Documents\Visual Studio 2017\Projects\mySolutionFolder\myProjectFolder\obj\Debug\myExecutable.exe' is denied.'

However, when I build the project, it compiles fine. Once I build the project then a solution build doesn't throw any errors. I am running visual Studio 2017.

What I've tried (without success):

  1. There is a second project in the solution, but I've unloaded it and it still errors.
  2. I deleted the solution file and had visual studio create a new one.

Additional Info: The error is somewhat random. Usually it errors out, but sometimes not. The odds of an error are reduced the longer I wait between a "Clean" and a rebuild. I have the same problem even when running in Administrator mode. I'm beginning to think it's a hard drive issue.

like image 851
Jeff Avatar asked Sep 11 '25 14:09

Jeff


1 Answers

The application is still running.

\Debug\myExecutable.exe' is denied.' is telling you that you cant replace that because its currently open.

Open task manager and make sure that you end that process, and it should work fine after that.

This is usually what happens to me when I get that error.

Hope this helps

like image 81
TheNoob Avatar answered Sep 14 '25 03:09

TheNoob