Exemplo n.º 1
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            LibraryChecker.CheckLibraries();
            try {
                await ClientInfo.FetchClientVersion();
            }
            catch (FileLoadException) {
            }
            catch (Exception) {
            }

            var results = await Actions.LoadServersList();

            ListViewServers.DataContext = results;

            await Actions.PingServers(results);
        }
Exemplo n.º 2
0
        internal static void CheckLibraries()
        {
            var brokenLibs  = new List <string>();
            var missingLibs = new List <string>();

            foreach (var libraryName in LibrariesToCheck)
            {
                if (!LibraryChecker.CheckAssemblyRegistered(libraryName))
                {
                    brokenLibs.Add(libraryName);
                }
            }

            foreach (var libraryName in LibrariesToCheckSystem)
            {
                if (!LibraryChecker.CheckAssemblyRegistered(libraryName))
                {
                    missingLibs.Add(libraryName);
                }
            }

            bool registerFailed = false;

            if (brokenLibs.Count > 0 || missingLibs.Count > 0)
            {
                var message = $@"The following libraries could not be loaded:
    - {string.Join("\n    - ", brokenLibs.Union(missingLibs))}
This will likely prevent Seyerdin from running correctly.
Would you like to try to register these libraries now?";

                if (MessageBox.Show(message, "Library Load Errors", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    foreach (var libraryName in brokenLibs)
                    {
                        if (!LibraryChecker.RegisterLibrary(libraryName))
                        {
                            if (!IsRunAsAdmin())
                            {
                                if (MessageBox.Show(
                                        $"Could not register {libraryName}.  \nYou may need to run this application as an administrator,  Would you like to do that now?",
                                        "Register Library Errors",
                                        MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                                {
                                    LaunchAsAdmin();
                                }
                            }
                            registerFailed = true;
                        }
                    }

                    foreach (var libraryName in missingLibs)
                    {
                        if (!LibraryChecker.CopyLibrary(libraryName))
                        {
                            if (!IsRunAsAdmin())
                            {
                                if (MessageBox.Show(
                                        $"Could not copy {libraryName}.  \nYou may need to run this application as an administrator,  Would you like to do that now?",
                                        "Copy Library Errors",
                                        MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                                {
                                    LaunchAsAdmin();
                                }
                            }
                            registerFailed = true;
                        }
                    }
                }
                else
                {
                    missingLibs.Clear();
                    brokenLibs.Clear();
                }
            }

            if (brokenLibs.Count > 0 || missingLibs.Count > 0)
            {
                if (registerFailed)
                {
                    MessageBox.Show("Could not register libraries.  You may need to do this yourself using regsvr32.");
                }
                else
                {
                    if (MessageBox.Show("Register libraries succeeded.  Consider extracting and installing the vb6 redistributable found in /dependencies if you continue to see errors.  \nYou may need to reboot, would you like to reboot now?", "Reboot?", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
#if !DEBUG
                        System.Diagnostics.Process.Start("shutdown.exe", "-r -t 0");
#endif
                    }
                }
            }
        }