CheckForDotNet45.Program.Main C# (CSharp) Method

Main() public static method

Main entry point for program.
public static Main ( ) : void
return void
        public static void Main()
        {
            try
            {
                Console.Write("Checking .NET version...");

                int releaseKey = 0;
                string version = null;
                if (IsNet45OrNewer())
                {
                    releaseKey = GetDotnetReleaseKeyFromRegistry();
                }
                else
                {
                    version = Environment.Version.ToString();
                }

                string url = string.IsNullOrEmpty(version)
                        ? string.Format(SiteWithReleaseKey, releaseKey)
                        : string.Format(SiteWithVersion, version);
                try
                {
                    Process.Start(url);
                }
                catch (Exception)
                {
                    Console.WriteLine("\nApplication was unable to launch browser to go to {0}", url);
                    if (version != null)
                    {
                        Console.WriteLine("Your current .NET version is: " + version);
                    }
                    else
                    {
                        Console.WriteLine("Please browse to the URL to get version information.");
                    }

                    Console.ReadLine(); // Pause
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred:");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.ToString());
                Console.ResetColor();
                Console.WriteLine("Please log an issue including the error information at https://github.com/shanselman/SmallestDotNet/issues/");
                Console.ReadLine(); // Pause
            }
        }