A project with an Output type of Class Library cannot be started directly

前端 未结 7 1778
情深已故
情深已故 2020-12-05 13:37

I\'ve download sample code with C#. but when I run I get this error message:

A project with an Output type of Class Library cannot be started direct

相关标签:
7条回答
  • 2020-12-05 13:56

    The debug settings of your Visual Studio development environment might be left blank. Please check if the following highlighted fields are missing, if they are missing then fill it up with your specific executable.

    Debug Settings

    These fields are required to let the VS start the program for debugging. In the above picture, I'm developing a VSPackage so the:

    1. The external program is devenv.exe
    2. Command line argument is /rootsuffix Exp (for starting the experimental instance).

    Note: I can assure you the answers mentioned in here didn't help me fix the issue because my project was already set as a startup project, now I came across an MSDN blog which helped me and lead to this answer.

    0 讨论(0)
  • 2020-12-05 13:58

    The currently selected startup project is a Class Library.

    You need an entry point for your application. Does your solution contain multiple projects?

    Are you sure you want to 'run' the Class Library?

    enter image description here

    Possibly you've downloaded a Class Library solution only. In that case there might be unit tests that you can 'debug' to step-trough the code.

    Update In response to your comment, these are possibilities to run the class library:

    • Create a console application and reference the class library. Then 'use' its contents
    • Debug an unit-test project
    • start existing client project
    0 讨论(0)
  • 2020-12-05 14:03

    Try to close Visual Studio and restart it by opening the file you are trying to debug from Unity

    0 讨论(0)
  • 2020-12-05 14:09
    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
        <StartAction>Program</StartAction>
        <StartProgram>C:\Program Files (x86)\Microsoft Office\Office14\excel.exe</StartProgram>
        <StartArguments></StartArguments>
        <StartWorkingDirectory></StartWorkingDirectory>
        <EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
      </PropertyGroup>
    </Project>
    
    0 讨论(0)
  • 2020-12-05 14:11

    You need to check that you have the startup project setup correctly.

    If there is more than one project in the solution, right click on the one that should be run when you compile and choose Set as startup project

    0 讨论(0)
  • 2020-12-05 14:14

    I was trying to run a Debug test with breakpoint in the specFlow feature.cs file instead of the Step.cs file. Put the breakpoint in the Step.cs file and it's working as expected. Thanks!

    0 讨论(0)
提交回复
热议问题