using System.ServiceModel; using System.ServiceProcess; namespace BatchCoreService { public partial class BatchCoreService : ServiceBase { public ServiceHost serviceHost = null; public BatchCoreService() { InitializeComponent(); } protected override void OnStart(string[] args) { if (serviceHost != null) { serviceHost.Close(); } // Create a ServiceHost for the CalculatorService type and // provide the base address. serviceHost = new ServiceHost(typeof(DAService)); // Open the ServiceHostBase to create listeners and start // listening for messages. serviceHost.Open(); } protected override void OnStop() { if (serviceHost != null) { serviceHost.Close(); serviceHost = null; } } } }