C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2722
Number of posts: 5749

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
More two Main App in one project Posted by iamdony on 2 Sept 2009 at 2:16 PM
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
Report
Re: More two Main App in one project Posted by DataDink on 2 Sept 2009 at 4:41 PM
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.
Report
Re: More two Main App in one project Posted by iamdony on 5 Sept 2009 at 10:50 PM

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

This is an error report:

* Error 1 Program 'E:\Project 2 Revision.Net\Hai\Application\AppDemo\HaiApp3\WPFHost\obj\Debug\WPFHost.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.Net\Hai\Application\AppDemo\HaiApp3\WPFHost\obj\Debug\App.g.cs 58 28 HaiHost

* Error 2 Program 'E:\Project 2 Revision.Net\Hai\Application\AppDemo\HaiApp3\WPFHost\obj\Debug\WPFHost.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.Net\Hai\Application\AppDemo\HaiApp3\WPFHost\ProgramSD.cs 13 21 HaiHost


What should I do?

Report
Re: More two Main App in one project Posted by DataDink on 7 Sept 2009 at 9:28 PM
Are you using visual studio?
Report
Re: More two Main App in one project Posted by iamdony on 8 Sept 2009 at 1:20 AM
Yes, Visual Studio 2008
Report
Re: More two Main App in one project Posted by DataDink on 9 Sept 2009 at 8:36 AM
When visual studio is compiling it is looking for this
        [STAThread]
        public static void Main()
        {
            // start up code here.
        }

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.
Report
Re: More two Main App in one project Posted by DataDink on 9 Sept 2009 at 8:50 AM
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.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.