From: jazzydance on
Since I am new to c#.net 2008 but I have worked a little with visual
basic.net 2005, I have the following questions I would like to ask:
1. When I am looking at a .sln file that I will be maintaining a work, I can
see there are lots of static void Main() methods in a file called program.cs
throughout the solution in separate folderts. Can you tell me the purpose of
this kind of code? Does this instantiate an object, is this a class libary
member?
2. When running the C#.net 2008 professional version windows application,
how do I know which 'main' method is being called?
3. When looking at this sln, I would like to determine all the different
ways to run this .sln application there are. To do this would I look at the
different ways there are to run the application (release, debug, configuation
mange), would I use the object explorer? How would you recommend I learn how
this .sln is executed
From: Peter Duniho on
jazzydance wrote:
> Since I am new to c#.net 2008 but I have worked a little with visual
> basic.net 2005, I have the following questions I would like to ask:
> 1. When I am looking at a .sln file that I will be maintaining a work, I can
> see there are lots of static void Main() methods in a file called program.cs
> throughout the solution in separate folderts. Can you tell me the purpose of
> this kind of code? Does this instantiate an object, is this a class libary
> member?

You appear to have the same Internet identity as "Wendy Elizabeth". Are
you? If so, why are you posting a question almost identical to the
previous one you posted?

To add to my previous answer (since you didn't mention solutions in your
previous question): a single solution can refer to two more projects,
any of which can be an application. Each application project will have
its own entry point, defined as a Main() method in some class (but in
the Program class by default).

When debugging a solution, only one project can be the current "startup
project", which you can choose by selecting in the Solution Explorer,
right-clicking and selecting the menu item "Set as Startup Project" (or
something like that…I forget if that's the exact wording).

Of course, when running each application outside of the debugger, you
can choose whichever specific application you want to run, and each will
work according to whatever its project settings were.

> 2. When running the C#.net 2008 professional version windows application,
> how do I know which 'main' method is being called?

One way to do it is open the solution and the press the F10 key, which
will single-step into the startup project's entry point.

Without debugging, you would have to look to see which project is the
startup project for the solution (it will be the project displayed with
a bold font name in the Solution Explorer), and then look at that
project's properties to see which class is the startup object for the
project. The Main() method in that class is the entry point for the
project.

> 3. When looking at this sln, I would like to determine all the different
> ways to run this .sln application there are. To do this would I look at the
> different ways there are to run the application (release, debug, configuation
> mange), would I use the object explorer? How would you recommend I learn how
> this .sln is executed

You don't execute a Solution per se, though as I mentioned, a Solution
does have a current startup project. It's the project that is executed,
and that can change if there are more than on executable projects in the
Solution.

Configuration Manager can show you all the different configurations
configured for the Solution (noting, of course, that each project can
have its own possible build configurations which may or may not be
identical to those for the Solution, though normally one tries to keep
the Solution and project configurations in sync with each other).

Beyond that, it's simply a question of what project is the current
startup project, and what class within that project is the current
startup object class.

Pete