This service on local computer started and then stopped. some services stop automatically if then are not in use by other servces or programs
Like PoweredByOrange alreadys said, in your app.config
is almost no configuration and also no endpoint defined. You should have a system.servicemodel
element in your app.config
that defines your service including which contract, endpoint, binding, etc
Here you can see a Simple configuration on MSDN
user3056831
Updated on August 16, 2020Comments
-
user3056831 over 3 years
After building installing windows service I got first error "windows could not start service on local computer error 5 access is denied" when I try to start a windows service. I resolved first error by following these steps of solution : Cannot Start Windows Service in NetworkService account .After this the notification of first error Vanished but another notification for error appeared "This service on local computer started and then stopped. some services stop automatically if then are not in use by other servces or programs". How i can solve this issue?
Note : I have visited many posted answer but they didn't solved problem .
Windows service on Local Computer started and then stopped error
Windows Event Viewer notification :
Service cannot be started. System.InvalidOperationException: Service 'CustomerServiceLibrary.CustomersService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element. at System.ServiceModel.Description.DispatcherBuilder.EnsureThereAreApplicationEndpoints(ServiceDescription description) at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) at System.ServiceModel.ServiceHostBase.InitializeRuntime() at System.ServiceModel.ServiceHostBase.OnBeginOpen() at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open() at WindowsServiceHost.WCFService.OnStart(String[] a...
Edited:
namespace WindowsServiceHost { public partial class WCFService : ServiceBase { public WCFService() { InitializeComponent(); } private ServiceHost host = null; protected override void OnStart(string[] args) { System.Diagnostics.Debugger.Launch(); host = new ServiceHost(typeof(CustomersService)); host.Open(); } protected override void OnStop() { if (host != null) { host.Close(); } host = null; } } }
app .config file :
<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> </configuration>
-
Tim over 10 yearsOP is hosting the service in a Windows Service - they don't have (and couldn't use) a Web.config.