コード例 #1
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                // Determines if the user can actually connect to the server.
                ApplicationHelper.SetupApplication();

                Application.Run(new MainWindow());
            }
            catch (Exception ex)
            {
                string errorMsg = "The server may not be responding or you may not have the rights to run this application.  If you feel this is wrong, please send a request ticket to ISD with the below information."
                                  + Environment.NewLine + "Server: " + System.Configuration.ConfigurationManager.ConnectionStrings[1].ConnectionString.Split(';')[0].Split('=')[1]
                                  + Environment.NewLine + "Database: " + System.Configuration.ConfigurationManager.ConnectionStrings[1].ConnectionString.Split(';')[1].Split('=')[1]
                                  + Environment.NewLine
                                  + Environment.NewLine + "Error Message"
                                  + Environment.NewLine + ((ex.InnerException == null) ? ex.Message : ex.InnerException.Message)
                                  + Environment.NewLine
                                  + Environment.NewLine + "Stack Trace"
                                  + Environment.NewLine + ex.StackTrace;
                MessageBox.Show(errorMsg, "Failed to access server");
                Console.WriteLine(errorMsg);
            }
            finally
            {
                ApplicationHelper.CloseConnection();
            }
        }