/// <summary> /// When overridden in a derived class, removes an installation. /// </summary> /// <param name="savedState">An <see cref="T:System.Collections.IDictionary"/> that contains the state of the computer after the installation was complete.</param> /// <exception cref="T:System.ArgumentException"> /// The saved-state <see cref="T:System.Collections.IDictionary"/> might have been corrupted. /// </exception> /// <exception cref="T:System.Configuration.Install.InstallException"> /// An exception occurred while uninstalling. This exception is ignored and the uninstall continues. However, the application might not be fully uninstalled after the uninstallation completes. /// </exception> public override void Uninstall(IDictionary savedState) { base.Uninstall(savedState); CASApplicationInstance.UnInstallServer(Context.Parameters["AssemblyPath"]); }
static void Main() { string m_cmmdLine = Environment.CommandLine; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (m_cmmdLine.ToLower().Contains(str_debug_install_argument)) { CASApplicationInstance.InstallServer(Assembly.GetExecutingAssembly().Location); } if (m_cmmdLine.ToLower().Contains(str_debug_uninstall_argument)) { CASApplicationInstance.UnInstallServer(Assembly.GetExecutingAssembly().Location); } CASApplicationInstance application = new CASApplicationInstance(); ConfigurationEditorMain config = new ConfigurationEditorMain(); try { if (!Environment.UserInteractive) { Directory.SetCurrentDirectory(new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName); if (application.ProcessCommandLine()) { return; } application.StartAsService(new UAServer()); return; } } catch (Exception e) { Utils.Trace(e, "Unexpected error starting service."); return; } #if DEBUG MessageBox.Show("Attach debug point"); #endif if (m_cmmdLine.ToLower().Contains(str_installic_argument)) { try { LibInstaller.InstallLicense(true); } catch (Exception ex) { MessageBox.Show("License installation has failed, reason: " + ex.Message); } } UAServer server = new UAServer(); try { FileInfo configFI = RelativeFilePathsCalculator.GetAbsolutePathToFileInApplicationDataFolder(Settings.Default.ConfigurationFilePath); config.ReadConfiguration(configFI); if (config.Configuration == null) { throw new ArgumentNullException("Cannot read configuration"); } BaseDirectoryHelper.Instance.SetBaseDirectoryProvider(new BaseDirectoryProvider(configFI.DirectoryName)); ApplicationCertificate.CheckApplicationInstanceCertificate(config.Configuration, 1024, (x, y) => true, true); //TODO add logging function or user interface. ApplicationCertificate.OverrideUaTcpImplementation(config.Configuration); server.Start(config.Configuration); Application.Run(new ServerForm(server, config.Configuration, application)); } catch (Exception e) { HandleException("UA Server", e); } finally { server.Stop(); } }