jason
jason

Reputation: 7164

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

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.

Upvotes: 109

Views: 128509

Answers (30)

Bill Reinke
Bill Reinke

Reputation: 31

I hit this issue in Visual Studio 2022. The solution file *.sln included generated lines like this, associated with the GUID of my project:

{xx-xx-xx}.Debug|x64.ActiveCfg = Debug|Any CPU
{xx-xx-xx}.Debug|x64.Build.0 = Debug|Any CPU

Configuration Manager shows Platform x64 for this project, but the above lines seem to map that to Any CPU, and it fails to start. The fix is to replace Any CPU with x64 in the relevant lines in the solution file:

{xx-xx-xx}.Debug|x64.ActiveCfg = Debug|x64
{xx-xx-xx}.Debug|x64.Build.0 = Debug|x64

Upvotes: 1

Renat
Renat

Reputation: 8962

In my case the issue was solved after selecting correct build configuration for startup project in Configuration Manager.

The build configuration of solution was set to Debug x64, but in Configuration Manager (at Build -> Configuration Manager...) exe project had platform as Any CPU. For this setup I was unable to debug project with "Unable to start debugging" message. After switching platform for exe project to the same x64, I was able to run it under debugger.

Upvotes: 4

Christian Larsson
Christian Larsson

Reputation: 151

I had previously changed some debug settings back and forth when this problem occurred for me. What worked for me was to go to Property Pages, click on "Debugging" in Configuration Properties, make sure "Local Windows Debugger" was used, set "Attach" to "Yes", run the solution one and then change "Attach" back to "No" again. After this it worked again.

Upvotes: 0

Bryan Aneux
Bryan Aneux

Reputation: 348

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.

Upvotes: 0

Felix
Felix

Reputation: 4081

@Flowerking's commend did it for me.

Right click on you project and select "Set as StartUp Project".

Upvotes: 0

claudi
claudi

Reputation: 1

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.

Upvotes: 0

t.j.
t.j.

Reputation: 1337

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" enter image description here

Working enter image description here

Upvotes: 5

shahida
shahida

Reputation: 335

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

Upvotes: 0

Gambitier
Gambitier

Reputation: 590

I got this problem solved by clearing MEF component cache.

Use this VS Extension to clear cache very easily.!!

Upvotes: 0

Mwiza
Mwiza

Reputation: 8961

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.

Upvotes: 0

Honza Slesinger
Honza Slesinger

Reputation: 1

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

Upvotes: 0

Arsen Khachaturyan
Arsen Khachaturyan

Reputation: 8330

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.

Upvotes: 0

sachith walpita
sachith walpita

Reputation: 51

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"

Upvotes: 0

mr NAE
mr NAE

Reputation: 3372

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.

Upvotes: 158

kirti kant pareek
kirti kant pareek

Reputation: 87

Just restart your visual studio and run as admin.

Upvotes: 2

Hedego
Hedego

Reputation: 294

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.

Upvotes: 0

Josh Siegl
Josh Siegl

Reputation: 735

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.

Upvotes: 0

Xolani Dlova
Xolani Dlova

Reputation: 1

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.

Upvotes: 0

Arshath Shameer
Arshath Shameer

Reputation: 453

Close the Visual Studio and re-open it again.

Upvotes: 1

Stachu
Stachu

Reputation: 5857

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

Upvotes: 1

Silmar
Silmar

Reputation: 117

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.

Upvotes: 0

Vivek
Vivek

Reputation: 15

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.

Upvotes: 0

Satria Janaka
Satria Janaka

Reputation: 481

I found this problem too. But after restart the Visual Studio Community 2015 as an administrator I found new problem :

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.

Upvotes: 0

wonster
wonster

Reputation: 746

Make sure you're launching Visual Studio as Administrator.

  1. Right click on the Visual Studio 2015 Shortcut
  2. Select the Shortcut tab
  3. Click on Advanced
  4. 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.

Upvotes: 7

Emil
Emil

Reputation: 2346

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

Upvotes: 0

user4344677
user4344677

Reputation:

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.

Upvotes: 0

Untherxadyus
Untherxadyus

Reputation: 151

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

Upvotes: 6

MrDebnath
MrDebnath

Reputation: 111

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.

Upvotes: 6

Basheer AL-MOMANI
Basheer AL-MOMANI

Reputation: 15327

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

Upvotes: 15

Mark Reid
Mark Reid

Reputation: 101

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

Upvotes: 3

Related Questions