31

I have developed an C#, ASP.NET web application in a Windows 7 machine using Visual Studio 2012. Now i had imported the entire project into VS 2017 running on windows 10 machine, and when i try to enter the debugging mode to analyze my code it shows the following error:

enter image description here

I guess the project configurations are conflicting hence it throws this error. Any suggestions??

Rufus L
  • 36,127
  • 5
  • 30
  • 43
user6304166
  • 411
  • 1
  • 4
  • 3
  • 1
    Try setting up your web project as the start-up project and then retry. – CodingYoshi Feb 03 '18 at 22:50
  • @CodingYoshi sorry but i am new to VS could you please elaborate? How can i do that? – user6304166 Feb 03 '18 at 22:52
  • Right click the web project and on of the options should be *set as startup* or something similar. – CodingYoshi Feb 03 '18 at 22:53
  • I experienced this issue once, randomly. I fixed it by restarting Visual Studio and installing the available package updates. (There will be a highlighted flag in the upper right if you have updates available.) [This user](https://stackoverflow.com/a/36879401/8116884) also has a solution to a similar or the same problem, but I can't personally vouch for it. – Matthias Jun 22 '18 at 00:35

7 Answers7

28

The same error happens when Visual Studio solution has selected the wrong Startup Project. The bold project is the designated startup project.

Go to the Solution Explorer > Right click on the correct project and select "Set as StartUp Project" in the context menu.

Thomas
  • 381
  • 3
  • 5
13

I also got this error. I ultimately got to know that I was not selecting .sln file.

In VS, you should select .sln file and it automatically loads the complete project structrue is what I learnt.

Selecting .sln file worked for me

Chinmay Atrawalkar
  • 942
  • 1
  • 8
  • 6
  • also try to double-clicking the .sln file. If the .sln not visible, click the "show all Files" icon in solution explorer – Mike Oct 01 '21 at 17:34
7

These errors are mostly because you are not selecting the .sln or solution file. In your solution explorer tree, double click the solution file and then build and run.

This runs contrary to a users intuition that simply opening a file and running it would work. Consider it a poor user interface. Jet Brains Rider, for instance, does not have this issue.

Dean P
  • 1,841
  • 23
  • 23
1

Change Targeting Platforms with the Configuration Manager and Build the project then try to debug it.I hope this will help you.

Hiren Patel
  • 1,071
  • 11
  • 34
0

Don't export the project folder. upload the .sln file. It will work.

enter image description here

Dino
  • 7,779
  • 12
  • 46
  • 85
0

DLLs cannot be ran/debugged directly. You have to specify host application in the Configuration Properties>Debugging>Command and then let it load the DLL by itself.

You will most likely need to copy the DLL to the directory searchable by the host application e.g. its root or ./plugins folder. In the Configuration Properties>Build Events>Post-Build Event>Command Line simply enter something like:

copy "$(TargetPath)" "$(HOST_APP)\plugins" 
Soyal7
  • 381
  • 5
  • 10
0

The Startup Item needs to be a .exe file. It's looking at BusinessLayer.dll because BusinessLayer is currently the Startup Project.

First, build the solution. Then, set the Solution Explorer to folder view and find the .exe in one of you project's /bin folders. Right click on it and set it to the Startup Item.

Finally, click the play button in Visual Studio top bar.

EDIT: Basically the same as Thomas' answer, but I'm pointing out that the "correct project" is the one with the .exe file. I would have commented on his answer, but I have less than 50 rep right now.

Joshua Swain
  • 571
  • 2
  • 4
  • 22