none
In Order to debug this project, add an executable project to this solution which references this library project.

    Question

  • How do I reference the library project when I get this 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 references this library project.  Set the executable project as the startup project."

     

     

    Friday, January 11, 2008 8:45 PM

Answers

  • in your IDE go to File\Add\New Project and choose WindowsApplication. In the Solution Explorer right click on the WindowsApplication project and choose "Set  As Start Up". Right click on it again and choose "Add Reference". Click the Projects Tab and Select your class library project. You can now reference your class library in code from the windows application like so:


        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim tc As New ClassLibrary1.Class1
            Dim Sum As Integer = tc.Add(5, 2)
            MsgBox(Sum.ToString)
        End Sub

     

    hope it helps

     

    Friday, January 11, 2008 9:20 PM

All replies

  • in your IDE go to File\Add\New Project and choose WindowsApplication. In the Solution Explorer right click on the WindowsApplication project and choose "Set  As Start Up". Right click on it again and choose "Add Reference". Click the Projects Tab and Select your class library project. You can now reference your class library in code from the windows application like so:


        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim tc As New ClassLibrary1.Class1
            Dim Sum As Integer = tc.Add(5, 2)
            MsgBox(Sum.ToString)
        End Sub

     

    hope it helps

     

    Friday, January 11, 2008 9:20 PM
  • How would you do this using Visual C# 2010 Express?
    Thursday, July 29, 2010 4:04 PM
  • How would you do this using Visual C# 2010 Express?

    Exactly the same way!
    Thursday, July 29, 2010 5:41 PM
  • Hi Chris, thanks for the response.

    It's somewhat different in 2010 Express. There is no Add under File, only File --> New Project. Then the options are Windows Forms Application, WPF Application, Console Application, Class Library, WPF Browser Application, and Empty Project. There is no listing for WindowsApplication. I am just starting out with this stuff and I thank you for any additional help on this topic.

    Thursday, July 29, 2010 7:13 PM
  • I am getting this same error.  I'm new to this and I'm following Brian Marchionni's Introduction to Custon GIS Apps, but there is a workaround for Starting an External Program (MapWindowGIS).  However, after installing and opening the "MyFirstPlugin.sln" file I still get the "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 this library project.  Set the executable project as the startup project" error.  Anyone have any solutions???
    Wednesday, August 04, 2010 8:24 PM
  • Hi Chris, thanks for the response.

    It's somewhat different in 2010 Express. There is no Add under File, only File --> New Project. Then the options are Windows Forms Application, WPF Application, Console Application, Class Library, WPF Browser Application, and Empty Project. There is no listing for WindowsApplication. I am just starting out with this stuff and I thank you for any additional help on this topic.


    You must add a Windows Forms Application or a WPF Application . Those are the executables the "program" so to speak . It is in those projects that you add references to class libraries or dll's .
    Coding4fun Be a good forum member mark posts that contain the answers to your questions or those that are helpful
    Please format the code in your posts with the button . Makes it easier to read . Or use the Forum Code Formatter by JohnWein http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/bf977a14-d9d4-4e84-9784-bf76b9e23261
    Wednesday, August 04, 2010 8:55 PM
  • I am getting this same error.  I'm new to this and I'm following Brian Marchionni's Introduction to Custon GIS Apps, but there is a workaround for Starting an External Program (MapWindowGIS).  However, after installing and opening the "MyFirstPlugin.sln" file I still get the "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 this library project.  Set the executable project as the startup project" error.  Anyone have any solutions???

     Once you have a project be it a class library or application you then get the add button . If a project is an executable but has been in error set as a class library you can go to the properties page of the project and on the Application tab change the application type in the application type dropdown but it is rare that that would happen .
    Coding4fun Be a good forum member mark posts that contain the answers to your questions or those that are helpful
    Please format the code in your posts with the button . Makes it easier to read . Or use the Forum Code Formatter by JohnWein http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/bf977a14-d9d4-4e84-9784-bf76b9e23261
    Wednesday, August 04, 2010 8:58 PM
  • Well, it turns out that all you need to enable debugging in Visual Basic Express Edition is a separate file in the project folder, called "MyProjectName.vbproj.user". This contains the user-specific project settings for the MyProjectName project. In my test I used the default project name for a Class Library, and so the file was called "ClassLibrary1.vbproj.user" and in the same folder as "ClassLibrary1.vbproj". Here is what th file needs to read:

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <StartAction>Program</StartAction>
        <StartProgram>C:\Program Files\Your Application\Application.exe</StartProgram>
      </PropertyGroup>
    </Project>

    After creating this file (please make sure the executable path is correct for your system, of course), you will need to reopen the project for it to be detected and read. But once it's found, you can debug your class library project with an external executable, just by hitting F5.

    • Proposed as answer by dhaines Friday, September 09, 2011 4:32 PM
    Friday, August 20, 2010 4:31 PM