2011-01-22 67 views
3

我使用c#。这时我使用Windows 7.我的问​​题是;当我运行我的代码时, 这给我错误等193:0xc1错误,服务启动但停止后,1053服务错误。 这是我的代码。C中的Windows服务错误#

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> 

由于提前,

+1

在EventViewer中检查应用程序事件日志。 DBEntry方法调用中最可能的一些例外。 – 2011-01-22 16:02:17

+0

那么除了调试,我应该怎么做? – Arbelac 2011-01-22 16:33:21

回答

2

有些事情要检查。这些发生在我身上,离开了我的头顶:

  1. 事件日志中是否有任何内容?他们有时可以给你一个线索。

  2. 事件日志是否已满?如果Windows无法写入,它将不会启动该服务。尝试清除应用程序事件日志并查看它是否启动。

  3. .config文件中是否存在任何语法错误?我们曾经有一个问题,与把一个<端点>标签的< /配置>

  4. 末它看起来像你写入数据库后.msi安装。运行该服务的用户是否可以访问该数据库?

  5. 尝试在您的OnStart()的开头放置Debugger.Break()以提示Windows在启动时连接Visual Studio实例。至少,它会告诉你,如果故障发生在它到达OnStart之前或之后。

  6. 您是否有多个<端点>在app.config/web.config文件中指定的匹配相同的合同?尝试删除多余的端点

0

我也有类似的问题,发现下面的链接有用: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q325680

在我的情况下的exe是在C:\文件ANS设置....和有一个名为C:\ Documents的文件。删除这个文件有帮助,但我仍然在寻找一种方法来解决这个编程问题。