Unable to start debugging. The startup project could not be launched. VS2015 - c#

I have started a new console project in VS2015. I only have this code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SautinSoft;
namespace PdfParser
{
class Program
{
static void Main(string[] args)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
SautinSoft.PdfFocus f = new PdfFocus();
f.OpenPdf(#"path:\abc.pdf");
if (f.PageCount > 0)
f.ToExcel(#"path:\abc.xls");
}
}
}
When I try to run, I get this :
Unable to start debugging. The startup project could not be launched.
Verify debug settings for the startup project.
How can I fix this? Thanks.

After upgrading MSVC2015 to Update3, I had the same problem: instead of std::map in the Watch window display as a horrible std::_Tree<std::_Tmap_traits... etc., some plugins started to throw exceptions, some projects was not able to run in debug mode.
All was solved by deleting CurrentSettings.vssettings. It is usually located at Documents\Visual Studio 2015\Settings If not, go to `Tools -> Options -> Environment -> Import and Export Settings ' to find the location of this file.

Had this on a brand new scaffolded ASP.NET Core 1.0 web application.
Solved with restart of Visual Studio.

I was also stuck with this. I removed both bin & obj folders, did a rebuild, and then it launched.
A very meaningless error....

I had this problem when I tried to start (without) Debugging my Asp.Net MVC project
are you running Visual studio as Administrator
so just restart visual studio As Administrator

Additionally to "Unable to start debugging"
I also had errors "The operation could not be completed: Unspecified error" when I tried to rebuild.
Thanks to Visual Studio popup: "the operation could not be completed"
it was enough to close Visual Studio 2015 and then open again.

Make sure you're launching Visual Studio as Administrator.
Right click on the Visual Studio 2015 Shortcut
Select the Shortcut tab
Click on Advanced
Check the box to "Run as administrator" at all times(see below)
This has resolved the issue for me with the exact error message in question.
It is not ideal to run the VS in administrator mode at all times. Make sure you un-check the box once your issue has been resolved.

There is no need to delete everything in my case, I just opened the
"CurrentSettings.vssettings"
file and commented this property
<PropertyValue name="DefaultBehaviorForStartupProjects">1</PropertyValue>
and everything fixed.
Sample

Just delete the .vs hidden folder. This folder resides at the same location where the sln file is. Deleting this folder also refreshes intellisense cache and would fix any issues with that. Hope this helps.

VS 2019, two Core 3.1 projects (an MVC and an API), brand new projects created, no other changes to the solution or projects.
I kept getting the referenced error when trying to start both projects within the IDE, despite having checked all the things already mentioned in this SO.
However, I finally realized, I forgot to specify the "Action" after switching the solution to "Multiple startup projects" (they were both still set to "None"). Right-click solution in "Solution Explorer", choose "Properties" (at very bottom).
Such a ridiculously simple thing. Hope it helps someone else.
"Broken"
Working

I just had the same problem and solved it by deleting the .vs directory in the project directory.

Delete all relevant /obj and /bin folders. Run again.

Close the Visual Studio and re-open it again.

Just restart your visual studio and run as admin.

I had this with a Xamarin.iOS project in my Xamarin.Forms solution. I tried every suggestion here, without success.
The source of the error was a misconfigured .csproj of the project. I never edited it myself and not even touched the project properties. I use Visual Studio 2017 RC.
I came across the solution when I compared the project file with previous versions on Source Control.
Solution: Compare the project file with a previous version and try to granually revert changes until you eliminated the problem and know what the cause was.

The solution for me was to delete all *.user files that are normally generated for both solution and project files

I found this problem too. But after restart the Visual Studio Community 2015 as an administrator I found new problem :
And then I try to open another solution, close the another solution, and open the solution which the problem occur, then the problem solved.

Had the Same Issue with the existing application, I deleted the vs settings but still the issue remained,
Finally i just restarted the VS and it worked fine.
I think sometimes when we load the project some library doesn't get loaded with the solution so the best option before doing anything is simply restarting the VS.

After adding a project reference 'MyProjectReference' to my app, then removing it, I was also getting the same error :
Unable to start debugging . The startup project could not be launched.
Verify debug settings for the startup project.
Deleting configuration, running as admin, restarting VS, rebooting machine all had no effect.
After running my web app without debugging (Right-Click Project -> View In Browser (Google Chrome) I got a much more useful error:
Could not load file or assembly 'MyProjectReference' or one of its
dependencies. An attempt was made to load a program with an incorrect
format.
My Solution was then to re-add back to the solution, then remove it again. After that rebuild and debug worked.

How I fixed my issue, I closed project that had that error , created new project build new project then opened the project that had an issue and build it. That worked for me.

Make sure you close all instances of Visual Studio and then restart as Administrator. In my case I had multiple instances of Visual Studio open and I had to close them all and then restart Visual Studio as admin in order to get things working.

I had visual studio 2015 with an ASP.net MVC5 arcitectured with DDD (Domain Driven Design). The problem was the same since I just opened visual studio normally.
The problem was solved when I closed all instance visual studio and restarted as an adminstrator.

I also faced to this issue in VS 2015 , but finally I resolved it by following bellow steps
In VS go to : Tools -> Options - > Projects and Solutions -> Build and Run
Select "Always Build" in "On Run when project are out of date"

This issue happened to me with the Latest VS2019.
I've tried everything here, but unfortunately without any result.
Finally, I've restarted the IIS server, also manually Recycled the "Default Application Pool".
After debugging issue fixed.

For me solution was to run testapp.csproj instead of testapp.sln. This can be selected from drop down next to green play button.

Simply updated visual studio which then prompted PC restart. This is what fixed the problem for me.
Note: I tried some of the above / below but to no avail.

I got this problem solved by clearing MEF component cache.
Use this VS Extension to clear cache very easily.!!

I stop debugging and exit the projects from IIS Express then clean and build the project and my error is gone.

I get this running as non-Adminsitrator in Visual Studio 2019 16.2.5, with two .NET Core projects.
The solution I found is to set at least one of the projects as "Start" (in Solution's Property Page). If both are set to "Start without Debugging" it fails. This happens even if I want to start the entire project without any debugging (Ctrl+F5).
Bug. Still unaddressed by Microsoft and their bug page issue report it is closed as unreproducible.

#Flowerking's commend did it for me.
Right click on you project and select "Set as StartUp Project".

I had this problem developing a react native app for windows in Visual Studio 2019. I started the debugger then stopped it in the terminal by using ctrl-C. I was not able to restart the debugger and the "start debugging" and "start without debugging" options were disabled in the debug dropdown. Restarting Visual Studio, etc, and some of the things described above did not work. Through hunting and testing, I noticed that if I switched views in the Solution Explorer to the MyProject.sln instead of the fileview, the debugging was enabled again. I'm not sure why, but it appears I need to be in the sln view to start the debugger.

Related

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

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?
I had an issue similar to this and I had to clear the component cache instruction can be found Here.
Hope this helps.
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 &rightarrow; Settings &rightarrow; Integration &rightarrow; Default term &rightarrow; 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 .../>
I was getting similar errors. I just had to restart visual studio. Sometime couple times a day.
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 found a solution here:
Please check "Use Managed Compatibility Mode" under Tools|->Options->Debugging->General.
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.
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
open the folder which contains the solution in visual studio.
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
First restart Visual Studio
Click the build icon
Select the rebuild option
Run the Program or Debug the Program
This was a weird one. Going to put what happened to me here because it might happen to someone else. Everything was fine with the app until suddenly after some fairly insignificant code changes I suddenly started getting this error. Visual Studio was compiling the executable just fine. But, the moment I tried to run it (either from Visual Studio or directly) the executable file would be automatically deleted right out of the Debug folder. Super odd--never seen anything like it. I began to get suspicious that perhaps an anti-virus or the OS was somehow identifying a checksum or some signature in the executable as "dangerous". Or perhaps some obscure compilation bug was corrupting the executable. So on a hunch I made another innocuous change (added a couple of lines of code to color code some text in a rich text box) and the problem went away.

VS Crashing after 'Set As StartUp Project'

I have a solution in VS 2012,
I try to change the startup project to specific project but the vs crashing immediately (with the other projects - no problem)
with the familiar message "Visual Studion Stop Working.."
I try also to define the startup project manualy in the .suo file
(See details in Why is "Set as Startup" option stored in the suo file and not the sln file?)
But when i reopen the VS, it crashes during the assemblies loading.
Any idea what can be the cause?
Edit:
Additional Details:
Its solution contains also WCF project, run in front of local IIS, This project run perfectly, with the same code, in other team computers.
As result of the facts, It seems an environment problem, IIS setting, Permissions and etc.
Note that i already reset VS setting, and also repair the installation and the problem not resolved.
Maybe someone knows what the logical action of 'Set as startup project', what the VS perform during the action except for the start point definition? i think that the root of the problem hides there...
I had this problem too, but on VS 2015. You should logoff from your MS account from VS, set your project as startup and then login back if you want ...
It is hard to guess what the problem could be, but because it works on other team members' machine, it might have something to do with your Visual Studio state.
Try clearing or moving out all files from:
C:\Users\<Username>\AppData\Local\Microsoft\VisualStudio (if starting as admin)
C:\Users\<Username>\AppData\Roaming\Microsoft\VisualStudio (if not starting as admin)
You might need to restart your machine if the files are in use before you can delete/move them. These folders contain some VS settings, cached files and logs.
In addition to what AVS said, you can try deleting your Visual Studio .suo file.

"Publish Now" button doesn't work, but Build>Publish does

In Visual Studio 2010, I have just one project that cannot be published using the "Publish Now" button.
If I publish using the menu option instead, it works fine. I can then increment the version number, click "Publish Now" (or use "Publish Wizard..."), and get this error:
Cannot publish because a project failed to build.
However, no other error message is given. I managed to get screenshots of the output screen before it clears and flips to the Error List tab, but there is no mention there of any error. Clean & Rebuild doesn't fix the problem.
What do these two options do differently? Why is the build failing one way but not the other?
Since "rebuild solution" and "clean Solution" are not solving these issues, it might be either logs or assemblies in Bin.
This error seems to be caused by various issues :
Solution 1. set the build log verbosity to Diagnostic from the menu Tools->Options->Project and Solutions->Build and Run in Visual Studio 2010.
After that, if you build and publish your project, you can see the detailed build log from the Output window. From there, we should get futher information about why it failed to build.
Solution 2. Do you have Google Desktop by chance? If you do, close the sidebar and try once.
Solution 3. Click here for an another solution
Solution 4. Do you work with people from other timezones ? Files modified in future time may also cause this issue. check this utility
Solution 5.
I suggest you to try running the Visual Studio in safemode that will force the visual studio loading only the default environment and services, and shipped versions of third party packages. If the problem disappears you may stuck with some version of IDE tools with bugs. update them then.
If nothing seems to work, try this.
*Solution 6*
After researching it, it appears that the built in build/publish script that Visual Studio (2010 in our case) uses has a flaw in the order that it does things. Most importantly it runs a cleanup on the OBJ directory deleting the target EXE file before the publish step can grab it.
The solution
This is somewhat of a hacky workaround, but it solved the problem for me.
The fix is to copy the file back to the /obj/ folder from the /bin/ folder right before the publish step. Unfortunately there is no way that I know to specify a BeforePublish event through the IDE, so you will have to edit the .vbproj file in a text editor.
Add the following section just before the final tag.
<Target Name="BeforePublish">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(IntermediateOutputPath)" />
</Target>
Clean and Rebuild worked for me. It seems like Google desktop and some browser extenstions causing this bug often. looking for a security update is good way to go with this.
I eventually created a new branch, and that branch did not have this problem. I never discovered what the actual cause was.

Visual Studio 2012 not building dependent projects

I just upgraded a VS2010 project to VS2012 and am now having a problem where dependent projects are not building on demand. For instance, say I have the following projects in my solution:
Library A
ConsoleApp 1
Where ConsoleApp 1 references Library A. If I change the signature of a method in a class in Library A and run ConsoleApp 1, there will be a compiler error due to ConsoleApp 1 not seeing my changes because running ConsoleApp 1 did NOT cause Library A to build.
If I manually build Library A, then manually build ConsoleApp 1, it works fine. However, I would expect that running ConsoleApp 1 should cause any dependent projects to be rebuilt before launching.
Could I have something configured incorrectly? Or is this a bug in VS2012?
Your symptoms sound very similar to those I experienced a while ago. Ensure that the projects are set to build with your current active solution configuration and active solution platform under Build->Configuration Manager.
Try by removing project references and adding them again (path to follow: References -> (right click) Add reference -> Solution -> Project). Before giving another try Save All. This is how I solved it.
This happens when the .suo file for the solution becomes locked and Visual Studio is no longer able to write to it. Another symptom of this problem is that you will see temp suo files being created next to the solution when you open it. Try closing Visual Studio and deleting all *.suo files in your working area. Then reopen Visual Studio and rebuild all. No need to manually rebuild your solution. This will fix the issue when it is caused by a locked .suo, as happened to a colleague of mine today.
In his case, the cause seemed to be that he shutdown his laptop while Visual Studio was still open. Maybe the shutdown of Windows didn't complete cleanly? We can only speculate on how the .suo originally became locked.
I tried all the solutions above and that did not fix the issue for me. I found that it was because of the Active configuration in the ConfigurationManager was set to build only the Main (start up) project.
Go to Build > ConfigurationManager
Ensure that all the projects you want to build are checked as in the screenshot below
This is a similar issue on Asp.Net forum here and this is the details on MSDN
. Although it was weired, bcoz I never changed these settings and it was working properly last week
I've encountered a similar problem, the solution (or the probelem) were the Build and Run settings under Tools > Options... > Projects and Solutions > Build and Run where "Only build startup projects and dependencies on Run" was checked. The screenshot shows my currently working solution.
For me, I resolve the issue by right clicking on the project; Build Dependencies > Project Dependencies. Then manually setting the order for each project. very painful if you have a lot of projects.
make sure that the referencing project has same or higher .Net framework version than the referenced project.
Right Click solution in solution explorer then click "Clean Solution".

Visual Studio C# IntelliSense not automatically displaying

Just recently, my Visual Studio 2010 stopped displaying IntelliSense suggestions automatically while I am typing. I can still press ctrl+space to get it to work, but it doesn't automatically show a list of suggestions like it used to. I have already tried disabling all my extensions, restarting VS and the computer, and I have checked all the appropriate settings (Options -> Text Editor -> C# -> IntelliSense) to make sure that it is set to offer suggestions after a character is typed.
Has anyone seen this behavior before? Does anyone have any other suggestions for how I can get IntelliSense to go back to the way things were before? If not, I might just have to do a fresh reinstall of VS...
In prose, in case you can't see the above image:
Open Tools > Options > Text Editor. If you're only having this issue with one language, find that language; if it's for everything, click "All Languages". Right at the top, there'll be a few options labeled "Auto list members", "Hide advanced members", and "Parameter information". Make sure all of those are enabled (though the second may be disabled; if so, ignore it).
I have found that at times even verifying the settings under Options --> Statement Completion (the answer above) doesn't work. In this case, saving and restarting Visual Studio will re-enable Intellisense.
Finally, this link has a list of other ways to troubleshoot Intellisense, broken down by language (for more specific errors).
http://msdn.microsoft.com/en-us/library/vstudio/ecfczya1(v=vs.100).aspx
I'll start off my noting that this hasn't happened since I upgraded my RAM. I was at 4GB and would often have multiple instances of VS open along with SSMS. I have since gone to 8GB and then 16GB.
Here's the steps I go through when I lose intellisense.
If only one file/window appears to be affected, close/reopen that file. If that doesn't work, try below.
In Visual Studio:
Click Tools->Options->Text Editor->All Languages->General
Uncheck "Auto list members"
Uncheck "Parameter information"
Check "Auto list members" (yes, the one you just unchecked)
Check "Parameter information" (again, the one you just unchecked)
Click OK
If this doesn't work, here's a few more steps to try:
Close all VS documents and reopen
If still not working, close/reopen solution
If still not working, restart VS.
For C++ projects:
MSDN has a few things to try: MSDN suggestions
The corrupt .ncb file seems most likely.
From MSDN:
Close the solution.
Delete the .ncb file.
Reopen the solution. (This creates a new .ncb file.)
Notes:
This issue does not appear to be specific to C# as C++ and VB users
report the same issue
Tested in VS 2013/2015
Steps to fix are:
Tools
Import and Export Settings
Reset all settings
Back up your config
Select your environment settings and finish
I also faced the same issue but in VS2013.
I did the below way to fix, It was worked fine.
Close all the opened Visual studio instance.
Then, go to "Developer command prompt" from visual studio tools,
Type it as devenv.exe /resetuserdata
Restart the machine, Open the Visual studio then It will ask you to choose the development settings from initial onwards, thereafter open any solution/project. You'll be amazed.
Hope, it might helps you :)
Deleted the .suo file in solution folder to solve the problem.
Sometimes i've found Intellisense to be slow. Hit the . and wait for a minute and see if it appears after a delay. If so, then I believe there may be a cache that can be deleted to get it to rescan.
I hit this today after the following sequence:
Added a new class to my project.
Closed Visual Studio, but accidentally selected No when it asked if I wanted to save changes.
Reopened Visual Studio, and found that it reopened the new file automatically but without my previous changes (as expected). However, IntelliSense was no longer working in the new file.
The problem was in addition to not saving changes to the new file, it didn't save changes to the project, so after reopening Visual Studio the file was not part of the project. The Show All Files command in Solution Explorer, or Add → Existing Item..., resolved the problem.
I had the file excluded from the project so i was not able to debug and have intellisense on that file.
Including the file back into the project solved my problem! :)
A new cause for this in the .net core era is having a project loaded for an unsupported .net core version. For instance if you loaded a project from GitHub that was set to use:
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
But you only have 2.1 installed or find yourself using Visual Studio 2017 then the compiler wont be able to find the SDK code and thus provide intellisense.
The solution in that case might be to right click on your project and select Edit MyProject.csproj from the context menu and change the target framework as necessary:
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
This assumes whatever project you loaded can actually be run under a lesser target framework.
I simply closed all pages of visual studio and reopened ..it worked.
Deleting the .vs folder in the solution solved my issue. You have to exit from Visual Studio and then delete the .vs folder and start Visual Studio again.
Closed all my VS windows
Started the Visual Studio Installer and clicked 'Modify'.
Under 'Individual components' > 'Code Tools' > Deselected NuGet package manager and re-selected it.
After modifying and restarting VS, IntelliSense was working correctly again.
Found my answer on https://developercommunity.visualstudio.com/content/problem/130597/unity-intellisense-not-working-after-creating-new-1.html
[Tools -> Options -> Text Editor -> All Languages -> CodeLens]
Check if check box "Enable CodeLens" is checked
I have just come to about this problem while installing one of the extensions and its file was deleted by my anti virus so I just disabled my anti virus and reinstalled visual studio. Suggestions are working properly without any changes made after installation.
At the bottommost right look at the blue line where Ln, Col, Spaces, UTF, CRLF,..... here the language is specified.
Check that your language and the language specified there are the same.
In my case, it was Django Python while I was trying to use HTML.
This may be due to the solution configuration changed to Release Mode instead of debug. Right click on solution -> Properties -> Configuration Properties -> Set Configuration To Debug if it is in Release.

Categories