473,385 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Multiple Main() s in Petzold's book.

In his book "Programming Microsoft Windows with C#", page 42, Petzold deals
with the case of a project with multiple Mains.

He explains that when compiling in the command line the argument /main can
be used, as in

csc prog1.cs prog2.cs /main:prog2ClassContainigMain (the code details are
mine)

Then he goes on to explain how to do the same thing when using Visual C#
..Net, or so I expected. He mentions to use the Add Existing Item dialog
box, and selecting the Link File option next to the Open button. However,
this does not deal with the issue of multiple Main() functions.

So my questions are:
1. Is it possible that VS does not have a way to deal with multiple
Main() functions?
2. Could it be that I am missing something?
3. Could it be that P. forgot to explain something?
4. If there is a way to use VS to have the same result as with the
command line (letting the project to use only one of the Main() functions),
what is it?

Thanks,
Victor
Nov 16 '05 #1
5 1487
Hi, Victor
not sure about 1 - I don't use VS for long time already
2. You might need to consider that Main is just another method in class
declaration. As such, you can have Main in any class you design. Just when
compiling to exe csc has to know which of all present Main(s) should be used
as entry point in application, otherwise it is stupefied up to point of
failing to compile.
3. Nothing much relevant, I think
4. - see 1. Sorry, can't help here

HTH - at least in some points
Alex

"Victor" <vm****************************@earthlink.net> wrote in message
news:oT******************@newsread3.news.atl.earth link.net...
In his book "Programming Microsoft Windows with C#", page 42, Petzold deals with the case of a project with multiple Mains.

He explains that when compiling in the command line the argument /main can
be used, as in

csc prog1.cs prog2.cs /main:prog2ClassContainigMain (the code details are mine)

Then he goes on to explain how to do the same thing when using Visual C#
.Net, or so I expected. He mentions to use the Add Existing Item dialog
box, and selecting the Link File option next to the Open button. However,
this does not deal with the issue of multiple Main() functions.

So my questions are:
1. Is it possible that VS does not have a way to deal with multiple
Main() functions?
2. Could it be that I am missing something?
3. Could it be that P. forgot to explain something?
4. If there is a way to use VS to have the same result as with the
command line (letting the project to use only one of the Main() functions), what is it?

Thanks,
Victor

Nov 16 '05 #2
"Victor" <vm****************************@earthlink.net> wrote in message
news:oT******************@newsread3.news.atl.earth link.net...
4. If there is a way to use VS to have the same result as with the
command line (letting the project to use only one of the Main() functions), what is it?


1) Open the project properties dialog box.
2) Navigate to open CommonProperties/General
3) Set the Startup Object property to the class name that contains the
preferred Main method

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com/blogs/mickey
Nov 16 '05 #3
Victor <vm****************************@earthlink.net> wrote:
In his book "Programming Microsoft Windows with C#", page 42, Petzold deals
with the case of a project with multiple Mains.

He explains that when compiling in the command line the argument /main can
be used, as in

csc prog1.cs prog2.cs /main:prog2ClassContainigMain (the code details are
mine)

Then he goes on to explain how to do the same thing when using Visual C#
.Net, or so I expected. He mentions to use the Add Existing Item dialog
box, and selecting the Link File option next to the Open button. However,
this does not deal with the issue of multiple Main() functions.

So my questions are:
1. Is it possible that VS does not have a way to deal with multiple
Main() functions?
No.
2. Could it be that I am missing something?
Yes.
3. Could it be that P. forgot to explain something?
Yes.
4. If there is a way to use VS to have the same result as with the
command line (letting the project to use only one of the Main() functions),
what is it?


In the project properties, Common Properties, set the "Startup Object"
to the name of the type whose Main method should be called.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
Elp

"Victor" <vm****************************@earthlink.net> wrote in message
news:oT******************@newsread3.news.atl.earth link.net...
So my questions are:
1. Is it possible that VS does not have a way to deal with multiple
Main() functions?
VS can deal with mutliple main fonction: in the solution explorer, right
click on your project and choose Properties. Then go to Common Properties ->
General and set the Startup Object Property. There's a drop down list that
lists all the main functions you can choose from (in case there are multiple
main function in your project).
4. If there is a way to use VS to have the same result as with the
command line (letting the project to use only one of the Main() functions), what is it?


See above
Nov 16 '05 #5
Thank you, guys.

Your advice worked as a charm. Very neat.

Victor

"Victor" <vm****************************@earthlink.net> wrote in message
news:oT******************@newsread3.news.atl.earth link.net...
In his book "Programming Microsoft Windows with C#", page 42, Petzold deals with the case of a project with multiple Mains.

He explains that when compiling in the command line the argument /main can
be used, as in

csc prog1.cs prog2.cs /main:prog2ClassContainigMain (the code details are mine)

Then he goes on to explain how to do the same thing when using Visual C#
.Net, or so I expected. He mentions to use the Add Existing Item dialog
box, and selecting the Link File option next to the Open button. However,
this does not deal with the issue of multiple Main() functions.

So my questions are:
1. Is it possible that VS does not have a way to deal with multiple
Main() functions?
2. Could it be that I am missing something?
3. Could it be that P. forgot to explain something?
4. If there is a way to use VS to have the same result as with the
command line (letting the project to use only one of the Main() functions), what is it?

Thanks,
Victor

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: BobforeApples | last post by:
Hi All, I was trying to apply databinding to a custom collection as in the MSDN Magazine article found in the August, 2005 issue. After converting the code in the article to C# and applying it to...
1
by: Gary Shell | last post by:
I am trying to figure out the best way to subdivide a project for multiple programmers. I am embarking on a new development project with one other person but with an idea in mind that we may need...
2
by: Diego | last post by:
Hi everybody! I'm using DB2 PE v8.2.3 for linux. I've defined a database with the following schema: ANNOTATION(ID,AUTHOR,TEXT) ANNOTATION_BOOK(ANNOTATION_ID,OBJECT_ID)...
2
by: blabla120 | last post by:
Hello XSLT-freaks, I have a source xmlfile that I want to transform to 2 different xmlfiles. source.xml: <books> <book> <title>Die Brandmauer</title>
3
by: Martijn Mulder | last post by:
What book on .NET, preferrably with code and examples in C#, can be thought of as the equivalent of the influencial 'Programming Windows' from Charles Petzold?
3
by: Jess | last post by:
Hello, I've been reading Effective C++ about multiple inheritance, but I still have a few questions. Can someone give me some help please? First, it is said that if virtual inheritance is...
12
by: Tom | last post by:
First, my thanks in advance to those who can help explain away this mystery line of code. Petzold is a great teacher and I appreciate his work; however, his explanation about an extra line of...
1
by: Bill Woodruff | last post by:
Visual Studio 2005, .NET FrameWork 2.0, C#, WinForms Application Hi, I've read the recent posts by and to 'Thunderbird' (and learned a lot, thanks, from the usual masters Skeet and Paladino,...
34
by: raylopez99 | last post by:
What is the state of C#? Somebody in a Linux advocacy newsgroup implied it has saturated (leveled off in growth). Note the 'hard code' pre-Wizards coding wizard Charles Petzold does C# only now....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.