"Error while trying to run project: Unable to start program". Can run program only once. Then VS needs restart

Viewed 18266

I'm running my .NET 4.0 (C#) project in debug mode after I start VS2013. It runs just fine.

The second time I start it from VS, I get the Dialog box that says "Error while trying to run project: Unable to start program C:\path\to\file.exe"

The process is still alive in the Taskmanager when I dismiss the dialog box. From Windows Explorer, I can run the program just fine. And after closing it, the process is gone too from the Task Manager.

A rebuild doesn't help. Is this a common problem with a known solution?

11 Answers

For my case, it cause by Platform target, you could force choose it to x86 or x64 which your project is:

Each Project's Properties > Build > Platform target

As I pointed out also here, the only solution that worked for me was to disable the ConEmu integration:

ConEmu → Settings → Integration → Default term → disable Force ConEmu as default terminal for console applications

Some users reported that it was enough for them to disable the Aggressive mode in that same settings tab; that wasn't the case for me though.

The topic is old, but this might help someone else.

So in my case I made a file in Visual Studio with .cp extension (accidentally deleted the last 'p') this made visual studio just "include" the the file and not mark it as a compilation unit, thus not compiling it, I looked the *.vcxproj file in a text editor and found out about this, so if you open the project file in a notepad or something just find your file at the bottom usually and change from <Item .../> to <ClCompile .../>

Just simply create a folder name as "projects" in c drive and copy paste the newly created project in it. Run the project by doing clean & Build or Rebuild method . It will work

  1. open the folder which contains the solution in visual studio.
  2. again, open your *.sln file by double clicking it inside the solution explore once opened try running the solution or rebuild the solution. once rebuild gets completed, it will open without error from next time.

My way of solving the error : error while trying to load project : Unable to start program and c:\Path\to\file.exe was simply by

  1. First restart Visual Studio
  2. Click the build icon
  3. Select the rebuild option
  4. Run the Program or Debug the Program

I had a similar error and resolved it by cleaning the solution. Right-click the solution name in Solution Explorer and choose Clean Solution.

I'm Brazilian, I don't speak English very well. I did this translation on google translator. I know the topic is old, but it can still help someone. I had this same problem in the following situation, I have a dual boot computer (linux debian 11 and windows 10). Inside debian, on my NTFS D disk, I created a folder to perform programming tests. After accessing that same folder with windows, I created a new project in visual studio inside that same folder that I had created in linux. The creation of the project went without problems, however when I tried to run the project (F5), I received the same error from this topic. I tried all the solutions I found on the internet, and nothing worked. I gave all permissions to my admin user and it still didn't work. Then I realized that even going straight to the folder where the application's executable was and clicking directly on it, I still received the access denied error message. So, I took the project out of the folder I had created in linux, and it worked. So, what I could conclude, is that because the folder where my project was was created in linux, for some reason, my windows didn't trust this folder, so it didn't allow running executables from inside that folder, even this one executable having been created by visual studio from within windows.

Related