public void start() { try { WCFHost = new ServiceHost(typeof(WCFTEST), new Uri[] { new Uri("net.tcp://localhost:9999") }); WCFHost.AddServiceEndpoint(typeof(IWCFContract), new NetTcpBinding(), "WCFService"); WCFHost.Open(); } catch (Exception e) { WCFHost = null; logger.Error("WCF open error ", e); } sqlTaskScheduler.Start(); }
protected override void OnStart(string[] args) { IUnityContainer unity = DependencyConfig.Initialize(); logger = ServiceLocator.Current.GetInstance <ISLogger>(); resourceManager = ServiceLocator.Current.GetInstance <IResourceManager>(); connManager = ServiceLocator.Current.GetInstance <IConnectionManager>(); encryptionManager = ServiceLocator.Current.GetInstance <IEncryptionManager>(); logger.Debug("collection service started"); unitOfWork = unity.Resolve <IUnitOfWork>(new ParameterOverride("context", new MsSqlMonitorEntities())); try { WCFHost = new ServiceHost(this, new Uri[] { new Uri(WCFADRESS) }); var behaviour = WCFHost.Description.Behaviors.Find <ServiceBehaviorAttribute>(); behaviour.InstanceContextMode = InstanceContextMode.Single; WCFHost.AddServiceEndpoint(typeof(IWCFContract), new NetTcpBinding(), WCFSERVICE); WCFHost.Open(); } catch (Exception e) { WCFHost = null; logger.Error("WCF open error ", e); } try { sqlTaskScheduler = new SQLTaskScheduler(logger, resourceManager, unitOfWork, connManager, encryptionManager); sqlTaskScheduler.Start(); } catch (Exception e) { logger.Error("start service error ", e); } // }