protected override void OnStart(string[] args) { try { if (_useWCF) { if (_wcfServer != null) { _wcfServer.Close(); } SearchHost.ValidateConfig(); // since we want our searchhost object to last as long as the process does // (keep files open), we make one instance of it and give that to the ServiceHost _searcher = new SearchHost(); _wcfServer = new ServiceHost(_searcher); var binding = Toolkit.GetSearchEngineBinding(null); var address = Toolkit.GetSearchEngineAddress(null); if (binding != null && address != null) { _wcfServer.AddServiceEndpoint(typeof(ISearchHost), binding, address.Uri); _wcfServer.Open(); } else { throw new InvalidOperationException(getDisplayMember("onstart{nowcf}", "No valid WCF end points are defined. Check SearchEngineBindingType and SearchEngineBindingUrl configuration settings.")); } } else { if (_tcpServer != null) { _tcpServer.Stop(); } SearchHost.ValidateConfig(); var port = _address != null && _address.Uri != null ? _address.Uri.Port : 2012; _searcher = new SearchHost(); _tcpServer = new TcpSearchServer(port, _searcher); _tcpServer.Start(); } base.OnStart(args); } catch (Exception ex) { EventLog.WriteEntry("Error starting GRIN-Global Search Engine: " + ex.Message, EventLogEntryType.Error); throw; } }