开发者

Windows Services Error in C#

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 , 105开发者_如何转开发3 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,


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜