Entry Point Method – Main

Posted on August 24, 2014 at 9:00 PM
Tags: C#Asp.NetMVCLinq

Agenda: VS.NET and Entry Point Method - Main
  • About Visual Studio.NET
  • VS.NET Editions
  • Developing First .NET Application
  • Entry Point Method Main
  • Importance of Command Line Arguments
  • Resolving Entry Point Main Ambiguity
  • Using Command Line Compiler – CSC.EXE

About Visual Studio.NET 2015 (VS.NET)

1.It’s an IDE (Integrated Development Environment) and RAD (Rapid Application Development) Tool

  • Code Editor
  • Intellisense
  • Code refactoring
  • Debugger
  • Forms Designer
  • Web Designer
  • Database Schema Designer
  • Class Designer
2. It can be extended with plug-ins that enhance the functionality at any level.
  • Macros, add-ins and packages
  • Eg: Source Control like Visual Source Safe
  • Team Foundation Server support
3. Languages Supported
  • C#, VB.NET, VC++.NET, J# & F# (by Microsoft)
  • Other languages such as PHP, Python, Ruby
  • HTML, XML, CSS and Javascript
4. Can be used for developing all types of applications VS.NET 2015 Editions

Community Edition

  • Free for open source projects, academic research, training, education and small professional teams
  • Ideal for learning MS.NET
  • Full featured IDE for developing Desktop and Web Applications.
  • Also for building cross platform iOS, Android and Windows App.

Professional Edition

  • Best for small team of software development as it has professional developer tools for building any type of application.
  • Powerful features to improve your team's productivity such as CodeLens
  • Improve team collaboration with Agile project planning tools, Team Rooms, charts andmore
  • Supports extensive tools for app development and debugging.
  • Supports Unit Testing.

Enterprise Edition

  • Everything what Professional Edition Supports
  • Build quality applications at scale with advanced features such as Load Testing, automatedand manual testing and new IntelliTest capabilities
  • Manage complexity and resolve issues quickly with features such as Code Map andIntelliTrace

class Program

MS.NET – C# VS.NET and Entry Point Method - Main
To Build the Solution Goto Menu: Build  Build Solution (Ctrl + Shift + B) To Run the Application 1. Debug => Start Debugging (F5) – Here we can use break points and debug the application. 2. Debug => Start Without Debuggin (Ctrl + F5) - We can see the output in console window. When the project is build the following output file is generated: Drive:\...\\bin\debug\.Exe Note: In VS.NET, at the time of creating a project we can specify the Framework Version to be used which can be either 2.0, 3.0, 3.5, 4.0 or 4.5.

Importance of Command Line Arguments

Mostly the console based applications are developed in situations where the application should either run as a top level process or as child process (invoked from another parent process). This is the best way of providing input to the console based application.

To specifiy Command Line Arguments:

View =>Solution Explorer => Select Project => Right Click => Properties => Debug Tab => Command Line Arguments => Provide string separated by space (Args1 Args2 Args3) Or Give at command prompt in console window Drive:\. . . \ ProjectName\bin\debug\.exe Args1 Args2 Args3 Significance of Return value of Main MS.NET – C# VS.NET and Entry Point Method - Main 5
1. When the application is not used as child process, the return value of main is not usefull because what ever may return the value when Main method ends the application terminates and OS will clean all the memory allocated to it. 2. The return value of Main is used by the terminating application to communicate its state to the parent process if any. The Integer return value can be predefined with some meaning and the same will be used by the parent process to know the state of child process which terminated. 3. The return value of Main is called as EXIT CODE of the application.

Resolving ambiguity of Main method

One Project can have multiple modules but only one of many modules with valid Main can be treated as Startup or Entry Point of the application. To Add another File to Project: Goto Solution Explorer => Right Click on Project => Add => Class
using System;
To Set Startup Object: View => Solution Explorer => Project => Right Click => Properties => Application Tab => Startup Object => Select Class whose Main should be used as entry point. Note: The class declared as startup object cannot have more that one form of Main which are valid for entry point.


[ms_person name="sandeep soni" style="below" title="Microsoft Certified Trainer (MCT,MCPD, MCSD)" link_target="_blank" overlay_color="" overlay_opacity="0.5" piclink="" picborder="1" picbordercolor="" picborderradius="50" iconboxedradius="48" iconcolor="" icon1="fa-thumbs-o-up" icon2="fa-rss" icon3="fa-thumbs-o-down" icon4="fa-comments" icon5="" link1="" link2="" link3="" link4="" link5="" class="" id=""]Sandeep has 21 yrs of experience working in various Microsoft Technologies/Platforms incl. VB6.0, ASP, VC++, VB.NET, C#. He is involved in managing and architecting projects at Deccansoft. He will be your liaison to Deccansoft, for any kind of communication and project updates. He knows what works and what doesn’t, and what practices are most suitable for design and programming with the ultimate goal of producing a quality system.[/ms_person]