简体   繁体   中英

Windows Service does not start on some local systems

I have created a windows service and installed it on 3 computers in a network.

It works fine on 2 of them but it has problem with the third one.

I have used Event Log to find out where the problem is, however it inserts logs just for the first time that i restart the system and also i have found that it just performs InitializeComponent() command in its constructor.

Note: My service should insert the login and logout of all accounts in a network and needs 3 dependencies that they start successfully before my service starts.

Edit: I have followed this article to create my service.The following code is just the constructor of the service.

ComAdminCatalogClass comAdmin = new ComAdminCatalogClass();
ICatalogCollection subCollection;

//Service Constructor
Public Service1()
{
   try
   {
      EventLog.WriteEntry("Service1","1");
      InitializeComponent();
      EventLog.WriteEntry("Service1","2");

      subCollection = (ICatalogCollection)comAdmin.GetCollection("TransientSubscriptions");

      SubScribToEvent(subCollection, "Logon");
      SubScribToEvent(subCollection, "Logoff");
   }
   catch (Exception exp)
   {
      EventLog.WriteEntry("Service1",exp.Message);
   }
}

Thanks a lot @akton, I have found the solution by run the exe of my service!!

It was too foolishly.The Event Viewer of the third system was full!!! I cleared all logs from it and my service works fine now in all three systems.

You can follow these steps to clear all Events

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM