3

I created a new cloud service solution in visual studio 2015 update 2 with azure SDK 2.9

According to one book I am reading, it says that if I start a worker role, it should open the compute emulator and I should be able to debug my code.

However I get this error: A project with an Output type of Class Library cannot be started directly

I know exactly what the error means, and on the tray icon the compute emulator has been started.

How can I debug the worker role?

Luis Valencia
  • 32,619
  • 93
  • 286
  • 506
  • 1
    You must have a cloud project in your solution. Please change that project as the `Startup Project` or debug that project. – Gaurav Mantri Apr 24 '16 at 03:14
  • I used the azure cloud solution templatewhich includes the project templates too http://screencast.com/t/RR3Mtzekvv – Luis Valencia Apr 24 '16 at 03:31
  • Thank you for sharing the screenshot. I see a yellow warning icon with your Cloud Service project. Can you please check the reason for that. That may be causing the problem. – Gaurav Mantri Apr 24 '16 at 03:43
  • Possible duplicate of ["A project with an Output type of Class Library cannot be started directly"](https://stackoverflow.com/questions/3363106/a-project-with-an-output-type-of-class-library-cannot-be-started-directly) – kenorb Sep 18 '18 at 16:08
  • lol you are flagging questions from 2016 – Luis Valencia Sep 18 '18 at 17:22

2 Answers2

6

Just in case this ever happens to anyone else, there's another possibility: Resharper 9.2 introduced Run Configurations which, among other things, allow you to set a specific project as the startup target.

The page though notes:

ReSharper overrides Visual Studio's Start and Start Without Debugging commands (i.e. Start/F5 etc) to execute ReSharper's active configuration.

So, silently, pressing F5 suddenly doesn't do what you expect.

If - like me - you have never heard of this feature, you might find yourself being vexed and perplexed when Visual Studio suddenly refuses to run the project you set as startup: in my case, a class library had been set in the Resharper Run Configuration, so I received the error "A project with an Output type of Class Library cannot be started directly", which led me to this question, as I had just added a new worker role to the cloud service.

It was only when I got a different error from Resharper itself - "The project to be run with this configuration is not present in the solution" - that I managed to figure out what was going wrong, as that led me to this page. Then I could open up the Run Configuration dialog and reset it to use the Visual Studio setting.

I have no idea how the Resharper startup got set. Maybe some strange key combination or something.

stuartd
  • 70,509
  • 14
  • 132
  • 163
  • Worked, thanks. To clarify, Resharper -> Tools -> Run Configurations... -> Delete any that you can (probably all those bar the top one denoted '(VS Startup)' ). – Taran Nov 07 '16 at 09:26
1

If you create a cloud solution, the project that was created should first should be the startup project. Or if you have multiple cloud projects in one project. Select the one you want to start. Set the project as startup project by right clicking => 'Set as StartUp Project'. Make sure it is not a type library, but a native cloud project.

Then you would be able to start local debugging.

Peter
  • 27,590
  • 8
  • 64
  • 84