103

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.

jason
  • 6,962
  • 36
  • 117
  • 198

32 Answers32

157

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.

mr NAE
  • 3,144
  • 1
  • 15
  • 35
  • 3
    where is `CurrentSettings.vssettings` stored? I am having same issue with update 3 – Zapnologica Jul 05 '16 at 18:50
  • 10
    Probably in your Documents\Visual Studio 2015\Settings\ – mr NAE Jul 06 '16 at 09:00
  • 7
    You can also launch devenv.exe with the switch [`/ResetSettings`](https://msdn.microsoft.com/en-us/library/ms241273.aspx) to reset your .vssettings file – Scott Chamberlain Jul 22 '16 at 21:07
  • There's a lot of stuff in that file. What else will break or change once this file is deleted? – JSideris Sep 10 '16 at 14:37
  • I didn't notice anything important since deleting that file. All important settings are stored somewhere else. Maybe it's because this file is used only for import export settings (look in Options/Environment/). Actually I'm more annoyed that if you open a second Visual Studio 2015 or it terminated by errors, then disappear settings of the Text editor /Tabs and /Scroll Bars. I think Visual Studio 2015 have a lot of bugs in a settings syncronisation. – mr NAE Sep 12 '16 at 12:00
  • 3
    I went to the folder and deleted all of the CurrentSettings.vssettings, but it still came up with the same error. Restarting Visual Studio worked after that. – Stephen Himes Nov 20 '17 at 15:21
152

Had this on a brand new scaffolded ASP.NET Core 1.0 web application.

Solved with restart of Visual Studio.

fiat
  • 15,501
  • 9
  • 81
  • 103
  • 16
    Thank you! I'm glad I tried this first before I deleted my vssettings file! – Rob H Aug 01 '16 at 12:20
  • 2
    Works for me too! – kurakura88 Aug 30 '16 at 05:51
  • Yes, same problem here, with ASP.Net Core 1.0 application, error message "Unable to start debugging. The startup project could not be launched. Verify debug settings for the startup project.". Closed Visual Studio 2015 Update 3, reopened, and the project builds and runs normally. – dmcquiggin Sep 22 '16 at 13:39
  • Had the same issue. Not sure if this caused the initial error but I had 3 windows with Visual Studio open. I closed all 3 instances and restarted and the issue resolved itself. – Gary Woodfine Dec 12 '16 at 14:50
  • This is ridiculous. Worked for me. I had this happen and thought "Oh crap, something was updated and broke my finicky dotnet build", so I created a new project and copied all my classes and settings over and it worked. Four days later had this happen again and just restarted visual studio and it worked. Wow, what a useless error message and a broken IDE. – Jason Goemaat Apr 14 '17 at 07:13
  • 3
    Boy am I EVER glad I looked at this answer before following the advice in the accepted one. Restarting VS fixed it, no need to delete any files^^ – Syndic Jun 29 '17 at 06:46
  • Don't do it! Try the other answers first. This will get rid of a lot of decisions you've made in VS. If you do do it, please back up the file first. – Stachu Oct 11 '17 at 11:56
  • 2
    This solves my problems. But didn't understand what just happened at the first time? – Ashish Gope Nov 14 '17 at 05:55
  • 2
    I love simple solutions! – victor Jan 16 '18 at 19:07
  • i wish everything was as easy as a simple 'restart'! – theITvideos Jan 05 '19 at 01:30
  • just remember to restart ALL instances of Visual Studio! – Papak Aug 29 '19 at 08:12
16

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

A very meaningless error....

James Joyce
  • 1,694
  • 18
  • 20
14

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

Basheer AL-MOMANI
  • 14,473
  • 9
  • 96
  • 92
  • 1
    I tried this answer and it worked. Then I tried restarting and running as a normal user like this answer http://stackoverflow.com/a/38650683/823 and it also worked. – ryantm Nov 16 '16 at 22:43
  • 1
    The problem with this answer was that I had this issue when I started Visual Studio as administrator. – Karlomanio Apr 28 '17 at 14:21
10

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.

Community
  • 1
  • 1
Michael Freidgeim
  • 26,542
  • 16
  • 152
  • 170
  • I had this error and I had a few instances of VS open. It was resolved after closing all instances and then reopening. I tried just closing the one that was giving the error first and it didn't help – PlantationGator Oct 19 '16 at 18:55
7

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.

wonster
  • 746
  • 1
  • 9
  • 11
  • 4
    This is terrible advice. Don't run anything as admin unless it has good reason to be run as admin. There are specific cases when you do need to run VS as Admin, but you shouldn't do it in general. – Will Dean Jan 20 '17 at 12:42
  • 1
    Running once using administrative privileges is surely a good reason, since it solved my problem. After first launch, which worked ok, I closed Visual Studio, reopened it using regular non-admin privileges and everything went equally smooth. Said that, I totally agree with @WillDean that NO ONE should develop under administrative privileges "all times" – Julio Nobre Apr 13 '17 at 10:38
  • I'd also advise against this answer; the error message will still present itself when running VS with Administrator privileges, so you're essentially performing a restart of VS which can temporarily resolve the issue for most users. – derpasaurus Jul 24 '18 at 08:21
6

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

Untherxadyus
  • 151
  • 2
  • 4
  • For me, after commenting that out, as soon as I open a project in VS again, it reverts my change. So this solution doesn't really work. – levininja Dec 06 '19 at 21:09
5

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.

MrDebnath
  • 91
  • 1
  • 5
5

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

t.j.
  • 1,227
  • 3
  • 16
  • 30
  • Interesting...same issue for me. I have no idea why I didn't think to change the Action. I'm glad you spotted the problem. – Rich May 12 '20 at 18:20
  • I'm using the "SwitchStartupProject for VS 2019" extension and didn't need to set the start action as described here when running with Kestrel. However, this answer resolved things for me when running with IIS. – OldBuildingAndLoan Mar 27 '21 at 13:44
3

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

Mark Reid
  • 101
  • 1
  • 3
  • 1
    After I installed scoop package manager and some extensions for vscode I had the same error on all old solutions in VS Community editions. Deletion of .vs dir helps indeed. – alehro Nov 24 '16 at 08:49
  • The .vs file is at the solution level, not the project level. – Rod Feb 09 '19 at 15:51
1

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

Stachu
  • 5,677
  • 3
  • 30
  • 34
1

Close the Visual Studio and re-open it again.

Arshath Shameer
  • 453
  • 4
  • 15
1

Just restart your visual studio and run as admin.

1

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.

Renat
  • 7,718
  • 2
  • 20
  • 34
0

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.

0

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

Emil
  • 2,196
  • 2
  • 25
  • 24
0

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.

Satria Janaka
  • 463
  • 4
  • 15
0

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.

Vivek
  • 15
  • 6
0

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.

Silmar
  • 117
  • 1
  • 9
0

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.

0

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.

Josh Siegl
  • 735
  • 1
  • 9
  • 16
0

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.

Hedego
  • 276
  • 2
  • 12
0

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"

0

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.

Arsen Khachaturyan
  • 7,904
  • 4
  • 42
  • 42
0

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

franiis
  • 1,378
  • 1
  • 18
  • 33
0

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.

Mwiza
  • 7,780
  • 3
  • 46
  • 42
0

I got this problem solved by clearing MEF component cache.

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

Gambitier
  • 504
  • 6
  • 18
0

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

shahida
  • 327
  • 3
  • 9
0

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.

claudi
  • 1
0

@Flowerking's commend did it for me.

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

Felix
  • 3,783
  • 5
  • 34
  • 53
0

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.

Bryan Aneux
  • 328
  • 2
  • 9
0

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.