compilation error (class library error)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • juli jul

    compilation error (class library error)

    Hello,
    I am trying to compile a project and get the following error:
    A project with an Output Type of Class Library cannot be started
    directly

    Can somebody explain me why?
    Thank you very much!



    *** Sent via Developersdex http://www.developersdex.com ***
  • Oliver Sturm

    #2
    Re: compilation error (class library error)

    juli jul wrote:
    [color=blue]
    > I am trying to compile a project and get the following error:
    > A project with an Output Type of Class Library cannot be started
    > directly
    >
    > Can somebody explain me why?[/color]

    Well, a class library is just not a executable type of project. If you
    want to execute the result of your compilation, you need to create a
    project with the word "Applicatio n" in its name (the name that's shown
    in the New Project dialog).

    Now that you have created the class library, it's not really easy to
    change it to an executable type, so it would probably be best if you
    just created a new project, probably of type "Windows Application", and
    take over the code you have already written. If you absolutely need to
    convert the project you already have, please don't hesitate to ask again.



    Oliver Sturm
    --
    omnibus ex nihilo ducendis sufficit unum
    Spaces inserted to prevent google email destruction:
    MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
    ICQ 27142619 http://www.sturmnet.org/blog

    Comment

    • Brian Delahunty

      #3
      RE: compilation error (class library error)

      It sounds to me like you are not trying to compile the project but you are
      trying to execute it or debug it.

      In this case you have a library which, generally speaking, does not have an
      entry point. You are probably pressing F5 or Ctrl+F5 in Visual Studio which
      are actually the commands for debug and run without debugging respectively.
      These commands do actually compile the project but they are not the way you
      shoudl do it.

      Hit Ctrl+Shift+B to build (i.e. compile+link+wh atever else) your project or
      select build from the build menu.

      If on the other hand you are actually trying to execute your library then
      chance are you shoudl have a console app or a windows forms app so you should
      just right click on the project, go to properties, and then change the
      "Output Type" from Class library to something else.

      Hope this helps

      --
      Brian Delahunty
      Ireland




      "juli jul" wrote:
      [color=blue]
      > Hello,
      > I am trying to compile a project and get the following error:
      > A project with an Output Type of Class Library cannot be started
      > directly
      >
      > Can somebody explain me why?
      > Thank you very much!
      >
      >
      >
      > *** Sent via Developersdex http://www.developersdex.com ***
      >[/color]

      Comment

      • juli jul

        #4
        Re: compilation error (class library error)

        I can't change the project name.What can I do in order to solve this?
        Thanks




        *** Sent via Developersdex http://www.developersdex.com ***

        Comment

        • Michael Voss

          #5
          Re: compilation error (class library error)

          juli jul wrote:
          [color=blue]
          > I can't change the project name.What can I do in order to solve this?[/color]
          [...snip...]

          Oliver's post was a little misleading. He didn't want you to change the
          project name, but the project type. When creating a new project, VS asks you
          to specify what kind of project you want to open.
          If you select "class library", you will not be able to *execute* the
          project. The build will perfom ok. If you need an executable, you'd have to
          select any item with "applicatio n" in it's name _upon project creation_.

          Refer to Biran's post on what to do to make your project compile correctly.


          Comment

          • Oliver Sturm

            #6
            Re: compilation error (class library error)

            Michael Voss wrote:
            [color=blue][color=green]
            >>I can't change the project name.What can I do in order to solve this?[/color]
            >
            > [...snip...]
            >
            > Oliver's post was a little misleading. He didn't want you to change the
            > project name, but the project type. When creating a new project, VS asks you
            > to specify what kind of project you want to open.
            > If you select "class library", you will not be able to *execute* the
            > project. The build will perfom ok. If you need an executable, you'd have to
            > select any item with "applicatio n" in it's name _upon project creation_.[/color]

            Sure, that's what I meant.
            [color=blue]
            > Refer to Biran's post on what to do to make your project compile correctly.[/color]

            And what Brian suggests was something I didn't want to suggest, because
            a class library project will not contain a Main method and it will be
            difficult to explain how to create one manually. That's why I suggested
            creating a new project to start with and taking over the important parts
            that may have been created already in the class library project.



            Oliver Sturm
            --
            omnibus ex nihilo ducendis sufficit unum
            Spaces inserted to prevent google email destruction:
            MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
            ICQ 27142619 http://www.sturmnet.org/blog

            Comment

            • juli jul

              #7
              RE: compilation error (class library error)

              Thank you very much,that was my problem (the build)



              *** Sent via Developersdex http://www.developersdex.com ***

              Comment

              • Brian Delahunty

                #8
                RE: compilation error (class library error)

                You're welcome. Glad I could help.
                --
                Brian Delahunty
                Ireland




                "juli jul" wrote:
                [color=blue]
                > Thank you very much,that was my problem (the build)
                >
                >
                >
                > *** Sent via Developersdex http://www.developersdex.com ***
                >[/color]

                Comment

                Working...