我正在使用c#.目前,我使用Windows 7.当我运行代码时,这给了我错误,例如193:0xc1错误,服务已启动,但停止后出现1053服务错误.这是我的代码.public RupdaterService(){InitializeComponent();this.timer1.Elapsed += n...
我正在使用c#.目前,我使用Windows 7.当我运行代码时,
这给了我错误,例如193:0xc1错误,服务已启动,但停止后出现1053服务错误.
这是我的代码.
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>
提前致谢,
解决方法:
一些事情要检查.这些事发生在我头上:
>事件日志中有任何内容吗?他们有时可以为您提供线索.
>事件日志是否已满?如果Windows无法对其进行写入,它将无法启动该服务.尝试清除应用程序事件日志,看看它是否开始.
> .config文件中是否有语法错误?我们曾经遇到过一个.msi安装程序的问题,该安装程序将< endpoint> < / configuration>结束后的标记.
>好像您正在写数据库.服务运行所在的用户是否有权访问该数据库?
>尝试将Debugger.Break()放在OnStart()的开头,以提示Windows在启动Visual Studio实例时连接它.至少,它会告诉您故障是在OnStart之前还是之后发生.
>您是否有多个< endpoint>在与相同合同匹配的app.config / web.config文件中指定?尝试删除多余的端点
本文标题为:C#中的Windows服务错误


- C# 将 Stream 保存到文件的方法 2023-06-27
- C#实现五子棋游戏 2022-12-06
- C#中Linq的去重方式Distinct详解 2023-06-21
- c# 实现子窗口关闭父窗口也关闭的简单实例 2022-10-27
- c# 如何自己实现一个ORM框架 2023-04-09
- C#开发WinForm项目实现HTML编辑器 2023-06-14
- C# 枚举Color并展示各种颜色效果的示例 2023-04-22
- 通过 C#/VB.NET 代码将 Excel 工作表拆分为单独的文件 2023-07-04
- C#使用dynamic类型访问JObject对象 2022-12-11
- C#异步编程的三种模式 2023-05-30