Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

More two Main App in one project

iamdonyiamdony Posts: 3Member
Hi..

I have a project, but wanted to incorporate the project into another project. At the time appears error when complile file whose contents are two main application. What should I do?

Thanks

Comments

  • DataDinkDataDink Posts: 135Member
    Sorry, I'm not understanding what you are trying to do:

    You have two .csproj set up in the same .sln and you have a compile error?

    if that's the case then please post what the error is - and the code that is causing the error.
  • iamdonyiamdony Posts: 3Member

    Yes, I have two more main application (two Public Static void Main).

    This is an error report:

    * Error 1 Program 'E:Project 2 Revision.NetHaiApplicationAppDemoHaiApp3WPFHostobjDebugWPFHost.exe' has more than one entry point defined: 'WPFHost.App.Main()'. Compile with /main to specify the type that contains the entry point. E:Project 2 Revision.NetHaiApplicationAppDemoHaiApp3WPFHostobjDebugApp.g.cs 58 28 HaiHost

    * Error 2 Program 'E:Project 2 Revision.NetHaiApplicationAppDemoHaiApp3WPFHostobjDebugWPFHost.exe' has more than one entry point defined: 'WinSharer.Program.Main()'. Compile with /main to specify the type that contains the entry point. E:Project 2 Revision.NetHaiApplicationAppDemoHaiApp3WPFHostProgramSD.cs 13 21 HaiHost


    What should I do?

  • DataDinkDataDink Posts: 135Member
    Are you using visual studio?
  • iamdonyiamdony Posts: 3Member
    Yes, Visual Studio 2008
  • DataDinkDataDink Posts: 135Member
    When visual studio is compiling it is looking for this
    [code]
    [STAThread]
    public static void Main()
    {
    // start up code here.
    }
    [/code]
    in order to know where to start executing your program - if you have more than one of these, then it doesn't know where to start and throws an error.

    You have two of these somewhere.

    This is commonly caused by not starting new projects or solutions when you are learning C# and instead just adding new files to an old project. In the future just make sure to start a new solution (.sln) for every class lesson or project.
  • DataDinkDataDink Posts: 135Member
    Sorry - I forgot about the original question:

    WHen you are working in Visual Studio you have Solutions and Projects. You can only work on one solution at a time - but one solution can have many projects in it.

    THe way to add a project to a solution is to right-click on the "Solution" in the solution explorer and select Add-> Existing Project

    Select your project and it will be added to your solution.

    In order for one project to see the classes and objects in the other then you must make a reference between the two.

    One project can only reference the other though. Two projects can not reference each other because the compiler will not know which one to compile first.

    So let's say
    ProjectA - the class that needs to reference ProjectB
    ProjectB - the class to be referenced

    Right click on ProjectA and select "Add Reference"

    In the dialog that pops up, select the "Project" tab and select ProjectB.

    Once your done with that, ProjectA will be able to see and access the classes in ProjectB.

    ___________________________________________________________________


    Now to address your underlying problem.

    You were originally trying to add the project files from one fully executable project to another. This is what caused your conflict. This means you have an actual entry point for both projects and want to somehow combine the functionality of two totally seperate entities. The problem that you are running into is that you are violating some design principles that are leading to these conflicts.

    My recomendation is to read up on both "Software Design Models and Patterns" and "Object Oriented Programming Patterns and Practices"

    These will give you insight on what goes where and how to put it all together.
Sign In or Register to comment.