Reputation: 361
A project with an output type of class library cannot be started directly. In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup project.
While running the program in C# visual studio 2010 I am getting this error. Please tell me how to sort out this error?
Upvotes: 34
Views: 96179
Reputation: 330
Please do follow as
Right click on Solution-->Go to properties-->Expand Common properties tab-->(On right side) Select Radio button with option Single startup project-->choose project from drop down list.
Enjoy.
Upvotes: 5
Reputation: 1
If it is a function app project that you want to execute then you need to have Azure development tool installed in your visual studio. Please see the below image for more info.
Upvotes: 0
Reputation: 1
If you want to solve it fast just in your project config file add
XML <OutputType>Exe</OutputType>
like:
<PropertyGroup>
//other fields
<OutputType>Exe</OutputType>
//other fields
</PropertyGroup>
Upvotes: 0
Reputation: 1
You need to mark the API in the set as startup project Right key on the API
Upvotes: 0
Reputation: 1
select .net core project, then it will start directly with no doubt. Thanks
Upvotes: -3
Reputation: 523
I was surprised to learn that you can indeed set some Class Libraries as Startup and run them, IF they contain user controls. They run in the UserControl TestContainer which allows one to modify properties, etc. Basically debug at DesignTime, which can be really helpful. I have about 20 user controls in a single Project. This way I can run the TestContainer and choose which user control to run and debug.
Upvotes: 1
Reputation: 11
The same error type i have found in my one of project suddenly which is running in VS 2012 with MVC 4 only. I have run multiple ways to resolve this error, but i have found filly with small change option in Property window of your respective error giving project. I have went project property window there i have change startup Project from Healpars to Myproject.Then it is working fine. Thank you
Upvotes: 1
Reputation: 37566
Set your startproject in the project explorer by clicking right mouseclick on an executable project and choose "Set as start project"
Upvotes: 70
Reputation: 12705
what you have done is that you have made a class library
with all your code
every project in .Net needs a starting point like Main()
function in c# which obsly isnt present in a class libraty type of project
what you can do instead is
1. Make a console project inside the same solution. by right clicking the solution and add new project
2. Add a reference to the class library
3. Access the classes/methods of the class library and then starting the console project instead of class library project
Alternatively,
If you have a console project OR any other project in the solution already
right click the project in the solution explorer and Set as Startup project
Upvotes: 10
Reputation: 14386
If you want to debug code in the DLL or run it using tests, go to the properties of the project, go to the Debug tab, select "Start external program" and enter the name of the application to use, such as a test runner.
Upvotes: 4
Reputation: 245429
You created the project as a class library project, not an executable program. Class libraries are compiled and then used by other applications for common functionality.
If you meant to create a class library, you need to create a test application (or, better yet, Unit Tests) to test the functionality. If you meant to create an executable application, you'll need to modify the project.
If you have multiple projects in a single solution, you might also need to make sure you have the correct project set as the "Start Project" rather than one of the class library projects.
Upvotes: 22
Reputation: 3358
Go to your project properties page, change Output Type to Console Application
or Windows Application
(depending on what it is).
Make sure that you've got correct project set as startup one (right click -> set as startup project), and that this one is not of type Class Library
. If your only project in solution is class library, then you need to create some test executable for it.
Upvotes: 2