3

I using c#. At this time I using Windows 7.My question is ; When I running my code, that's gives me errors etc 193:0xc1 error , Services started but after stopped , 1053 services errors. Here is my code.

    public RupdaterService()
    {
        InitializeComponent();
        this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
    } 
      protected override void OnStart (string[] args)
    {
        timer1.Enabled=true;
        this.DBEntry("Service Started");
    }
      protected override void OnStop()
    {            
        this.timer1.Enabled = false;
        this.DBEntry("Service Stopped");
    }

    private void timer1_Elapsed(object sender,System.Timers.ElapsedEventArgs e)
    {

        this.DBEntry("Service Running");
        }


 Here is my App.Config.

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<configSections>

    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c5***9" >
        <section name="HedefliRUpdater.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5***9" requirePermission="false" />
    </sectionGroup>
</configSections>

<system.serviceModel>

</system.serviceModel>

<applicationSettings>
    <HedefliRUpdater.Properties.Settings>
        <setting name="HedefliRUpdater_srvHedefli_wsrvHermesHedefliMesaj"
            serializeAs="String">
            <value>http://***.com/hedefli/srvHedefli.asmx</value>
        </setting>
    </HedefliRUpdater.Properties.Settings>
</applicationSettings>

Thanks in advance,

Arbelac
  • 1,698
  • 6
  • 37
  • 90

3 Answers3

3

Some things to check. These happened to me, off the top of my head:

  1. Is there anything in the Event Logs? They can sometimes give you a clue.

  2. Is the Event Log full? If Windows can't write to it, it won't start the service. Try clearing the Application event log and see if it starts.

  3. Are there any syntax errors in the .config file? We once had a problem with an .msi installer that put an <endpoint> tag after the end of </configuration>

  4. It looks like you're writing to a database. Does the user that the service runs under have access to that database?

  5. Try putting Debugger.Break() at the beginning of your OnStart() to prompt Windows to connect an instance of Visual Studio when it starts up. At the very least, it'll tell you if the fault is happening before it gets to your OnStart, or after.

  6. Do you have more than one <endpoint> specified in the app.config/web.config file that matches the same contract? Try removing the superfluous endpoint

Chris Wenham
  • 23,679
  • 13
  • 59
  • 69
  • First of all , thanks for your answer.I tried all your suggestions.Also ,I ran in the local system my service.But , if I install to server , that's gives me error .(My reference web site:http://www.dotnetspider.com/resources/869-How-schedule-task-using-windows-Services.aspx) Here is my error. Description: Error =An endpoint configuration section for contract 'SrvhedefliServRef.wsrvHermSoap' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name. 24.01.2011 15:08:33 – Arbelac Jan 24 '11 at 15:20
  • Sounds like you may have more than one in your app.config that matches the same binding and/or interface. Try removing the extra endpoint and see if your service starts. – Chris Wenham Jan 24 '11 at 15:29
  • But none endpoint.The Service starting ,but as i mentioned gives same error. My App.Config is in my post.Thanks again. – Arbelac Jan 24 '11 at 16:13
  • It looks like you don't have anything in . Are you configuring the ServiceHost in code? Also: is the error actually coming from the client? – Chris Wenham Jan 24 '11 at 16:19
  • As you said , it's not configured ServiceHost in code.What should I do?Also , I find this the web site.(http://msdn.microsoft.com/en-us/library/system.servicemodel.servicehost.aspx) – Arbelac Jan 24 '11 at 18:16
  • Can you post the code you use to initialize the ServiceHost? I can't tell what to do next from what's in your question. – Chris Wenham Jan 24 '11 at 18:28
  • I'm not created ServiceHost in code.I'm newbie about WinServices.I tell just doing to you;My webservices have class library.I required to run one of this webservices.All my codes wrote in local system.After , I'm copying only .dll file to server.(required to path file)But , WebService not working.what require exactly I do ? – Arbelac Jan 25 '11 at 09:35
  • I think that your config file should probably have something in the section, but yours is empty. Did you forget to open the WCF Config Editor and set up your implementation as a service? – Chris Wenham Jan 25 '11 at 20:34
1

I had a similar issue and found the following link to be useful: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q325680

In my case the exe was in C:\Documents ans Settings.... and there was a file named C:\Documents. Deleting this file helped, but I am still looking for a way to solve this programatically.

Yuval Rimar
  • 1,055
  • 12
  • 22
  • The MS support URL in this answer seems to be dead but, a decade later, the last sentence made me realise that we had a junk file lying around with the same name as the first part of the containing folder name (which happens to contain spaces). I deleted the junk file, the service now starts. Fantastic! – Michael12345 May 02 '23 at 03:44
1

I don't know what your problem is, but this question Easier way to debug a Windows service provides excellent tips to allow you to debug the startup of your service.

Community
  • 1
  • 1
btlog
  • 4,760
  • 2
  • 29
  • 38