Home > OS >  Sudden issue with Visual Studio debugging, while working in Unity
Sudden issue with Visual Studio debugging, while working in Unity

Time:04-22

I am working on a project in Unity for a couple of months now. The last couple of days an issue appeared with my Visual Studio client, without realising how.

On the debugging toolbar, there is no "Attach to Unity" button to start debugging the project, but instead the button now says "Start". If i try to press it i get the following error, also shown in the screenshot:

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 referances the library project. Set the executable project as the startup project.

Error: 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 referances the library project. Set the executable project as the startup project

I have found out this question here that explains how to fix that error, but in my case it does not work: enter image description here

More specific for my case, when i open my .cs files in Unity and Visual Studio launches, i now get this error: enter image description here

This suggests that my Unity settings are not set for Visual Studio as an external tool, which is false, since i have configured that a long time ago and have never made any changes since then to those settings. In fact going there to double check Visual Studio is indeed set as the external tool to use.

enter image description here

The problem must be occuring because of that last error, cause when i launch VS momentarily i can see the "Attach to Unity" button, the error pops up and the button changes to "Start" after that.

What i m thinking is that since i have updated VS lately, the external tools might be referancing still the previous version, but since the VS file directory is a mess i cant figure out if that is the case, and i do have seperate .exe files for the different versions or if it is something else that causes this issue.

Any help will be much appriciated since i m in the dark here!

CodePudding user response:

Ok so i managed to solve the issue myself after the comment of user Ruzihm in my question that got me thinking about Visual Studio versions VS Visual Studio Editor versions.

It was indeed a problem that had to do with Visual Studio Editor version. After going to read this thread for configuring VS for Unity: enter image description here

After updating to the new version everything went back to normal and i can start debugging again!!

It is very weird cuase ussually Unity threw a warning about this particural package on stratup so you know there is a new update, but it didnt do that in my case this time and i didnt think about it when looking to fix that error.

CodePudding user response:

I looked for the previous answer: The project you have downloaded compiles into a dll assembly and provide a set of classes with implemented functionality.

You should add to your solution a new project with Output Type of either Console Application or Windows Application (VS Add Project wizard will offer you different templates of Projects).

In the newly added project, you can implement logic to test your Class Library.

Output type of the project you can find and change by the following steps:

Right click on project in Solution Explorer -> Properties.

In opened tab with properties select Application and there will be ComboBox marked with Output Type label. This problem occurs when developing with vs tools, I hope it will help you. Thank you this is the link: "A project with an Output type of Class Library cannot be started directly" library-cannot-be-started-directly

  • Related