compile problems

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

    #1

    compile problems

    I have created a solution with 3 projects, P1, P2, P3.
    Project P1 has my main method and it also relies on
    objects/classes from P2 and P3. Two Questions:

    1.
    P2 and P3 don't have main methods. Do they need main
    methods even though some of their objects are only being
    created in P1? The reason I'm asking is because I get
    compile errors for both projects which says that
    the .exes don't have entry points.

    2.
    When I try to instantiate P2 and P3 objects in P1, I get
    compile errors which tell me that I'm missing using
    statements or assembly references. I tried 'using'
    statements but it still didn't work. I assume I need to
    create .dlls from P2 and P3 and then add references to
    P1. Is this the right assumption? Do I need to use
    command line or can I do it through the GUI? Does anyone
    have any useful links to reading material on this kind of
    stuff?

    Any suggestions will be greatly appreciated. Thanks a lot
    for the reply.

    Mike
  • Jon Skeet

    #2
    Re: compile problems

    Mike <mikebiros@hotm ail.com> wrote:[color=blue]
    > I have created a solution with 3 projects, P1, P2, P3.
    > Project P1 has my main method and it also relies on
    > objects/classes from P2 and P3. Two Questions:[/color]

    <snip>

    Both of your problems are basically due to P2 and P3 having their
    project types as application (console or windows). Instead, they should
    be "Class Library". You then need to add a reference to each of P2 and
    P3 in P1 - in P1, there's an item "References ". Right click that and
    click on "Add Reference". Go to the Projects tab and click on each of
    P2 and P3 to add them as references.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • Ranier Dunno

      #3
      compile problems

      [color=blue]
      >-----Original Message-----
      >I have created a solution with 3 projects, P1, P2, P3.
      >Project P1 has my main method and it also relies on
      >objects/classes from P2 and P3. Two Questions:
      >
      >1.
      >P2 and P3 don't have main methods. Do they need main
      >methods even though some of their objects are only being
      >created in P1? The reason I'm asking is because I get
      >compile errors for both projects which says that
      >the .exes don't have entry points.[/color]

      If P2 and/or P3 should be standalone executables (exe's),
      they need entry points. If they will only be used from
      other projects (like P1), they should be compiled as
      libraries (dll's) instead. Right-click on your projects
      in VS .NET and choose properties -> output type.
      [color=blue]
      >2.
      >When I try to instantiate P2 and P3 objects in P1, I get
      >compile errors which tell me that I'm missing using
      >statements or assembly references. I tried 'using'
      >statements but it still didn't work. I assume I need to
      >create .dlls from P2 and P3 and then add references to
      >P1. Is this the right assumption? Do I need to use
      >command line or can I do it through the GUI? Does[/color]
      anyone[color=blue]
      >have any useful links to reading material on this kind[/color]
      of[color=blue]
      >stuff?[/color]

      This is the right assumption. Once you have compiled P2
      and P3 as DLL's, you can include references to them
      easily using the VS .NET GUI. Right-click on 'References'
      under P1, choose 'Add reference', then 'Projects' and
      browse until you find your DLL's.

      - Ranier

      Comment

      • Mike

        #4
        Re: compile problems

        [color=blue]
        >-----Original Message-----
        >Mike <mikebiros@hotm ail.com> wrote:[color=green]
        >> I have created a solution with 3 projects, P1, P2,[/color][/color]
        P3.[color=blue][color=green]
        >> Project P1 has my main method and it also relies on
        >> objects/classes from P2 and P3. Two Questions:[/color]
        >
        ><snip>
        >
        >Both of your problems are basically due to P2 and P3[/color]
        having their[color=blue]
        >project types as application (console or windows).[/color]
        Instead, they should[color=blue]
        >be "Class Library". You then need to add a reference to[/color]
        each of P2 and[color=blue]
        >P3 in P1 - in P1, there's an item "References ". Right[/color]
        click that and[color=blue]
        >click on "Add Reference". Go to the Projects tab and[/color]
        click on each of[color=blue]
        >P2 and P3 to add them as references.
        >
        >--
        >Jon Skeet - <skeet@pobox.co m>
        >http://www.pobox.com/~skeet/
        >If replying to the group, please do not mail me too
        >.
        >[/color]

        Thanks for the reply. It was very helpful. I have one
        more question. I added a project P4 to my solution which
        is a standalone, thus it(P4) has a main method. I get
        the same referencing compile error even though I tried
        including a 'using' statement. How can I add P4 as a
        reference in order to use its objects/classes in P1 even
        though they both have main methods? Again thank you for
        the reply.

        Comment

        • Jon Skeet

          #5
          Re: compile problems

          Mike <mikebiros@hotm ail.com> wrote:[color=blue]
          > Thanks for the reply. It was very helpful. I have one
          > more question. I added a project P4 to my solution which
          > is a standalone, thus it(P4) has a main method. I get
          > the same referencing compile error even though I tried
          > including a 'using' statement. How can I add P4 as a
          > reference in order to use its objects/classes in P1 even
          > though they both have main methods? Again thank you for
          > the reply.[/color]

          I don't believe you can add a reference to an executable in VS.NET.

          --
          Jon Skeet - <skeet@pobox.co m>
          Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

          If replying to the group, please do not mail me too

          Comment

          • Chris Capel

            #6
            Re: compile problems

            Try putting all your main code in P4 into a separate .dll, then writing a
            new Windows Executable that simply creates a form from P4.dll. The entire
            code of the executable could look like this:

            using System;
            using System.Windows. Forms
            using P4Namespace;

            class SomeClass {
            static void Main() {
            Application.Run (new P4FormClass());
            }
            }

            Not much more than that would be necessary, and then you could reference P4
            from P1 or wherever else.

            Chris

            "Mike" <mikebiros@hotm ail.com> wrote in message
            news:0dcc01c35c 3b$a03af4b0$a60 1280a@phx.gbl.. .[color=blue]
            >[color=green]
            > >-----Original Message-----
            > >Mike <mikebiros@hotm ail.com> wrote:[color=darkred]
            > >> I have created a solution with 3 projects, P1, P2,[/color][/color]
            > P3.[color=green][color=darkred]
            > >> Project P1 has my main method and it also relies on
            > >> objects/classes from P2 and P3. Two Questions:[/color]
            > >
            > ><snip>
            > >
            > >Both of your problems are basically due to P2 and P3[/color]
            > having their[color=green]
            > >project types as application (console or windows).[/color]
            > Instead, they should[color=green]
            > >be "Class Library". You then need to add a reference to[/color]
            > each of P2 and[color=green]
            > >P3 in P1 - in P1, there's an item "References ". Right[/color]
            > click that and[color=green]
            > >click on "Add Reference". Go to the Projects tab and[/color]
            > click on each of[color=green]
            > >P2 and P3 to add them as references.
            > >
            > >--
            > >Jon Skeet - <skeet@pobox.co m>
            > >http://www.pobox.com/~skeet/
            > >If replying to the group, please do not mail me too
            > >.
            > >[/color]
            >
            > Thanks for the reply. It was very helpful. I have one
            > more question. I added a project P4 to my solution which
            > is a standalone, thus it(P4) has a main method. I get
            > the same referencing compile error even though I tried
            > including a 'using' statement. How can I add P4 as a
            > reference in order to use its objects/classes in P1 even
            > though they both have main methods? Again thank you for
            > the reply.[/color]


            Comment

            Working...