I just did a fresh download of Visual Studio 2015 on my laptop running Win10 (x64). I go to create my first Console Application and is opens successfully. I proceed to write a simple application..
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");
Console.ReadLine();
}
}
}
When I clicked debug, I get an error saying...
Unable to copy file "obj\Debug\ConsoleApplication1.exe" to "bin\Debug\ConsoleApplication1.exe". Access to the path 'obj\Debug\ConsoleApplication1.exe' is denied.
However, when I comment out the Console.ReadLine() code, the application runs just fine. I can't imagine writing an application without these Console.ReadLine() statements because it allows for the end user to add information. When the code runs without this line, it, of course, runs, completes and stops.
Can anyone tell me why this won't run with Console.ReadLine()? It also didn't run with Console.ReadKey() either.
Talk1:
Impossible to say for sure, for anyone not sitting at your computer. But it sure sounds like you haven't exited the previously running instance of your program (i.e. by pressing an appropriate key) before you try to re-compile and run another. Of course, when you remove the call to ReadLine() or ReadKey(), that previously running instance exits normally rather than waiting, so in that case it works fine.
Talk2:
There is a possibility that your anti-virus causes it, in which case you should look for log entries and for quarantined files in the AV. Can also be caused by the disk being close to full. But most likely it's as @PeterDuniho explains.
Talk3:
But this was the very first code I tried to execute. The very first time I tried to compile. There aren't any more programs (that I know of) that are using this file. I also just tried commenting out the Console.WriteLine() line and leaving the ReadLine(). Oddly enough, it works! It just not working with those two together.
Solutions1
killing VBCSCompiler.exe process hepls me