c#编写windows服务在开机是OnStart启动超时

1、编写服务对应的config文件,

比如我的服务叫ModbusAgent.exe,对应的文件叫ModbusAgent.exe.config

文件内容:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <generatePublisherEvidence enabled="false"/>
  </runtime>
</configuration>

2、配置程序签名

右键项目"属性"-->"签名"新建任意证书

网上说托管资源配置成系统服务需要程序签名

本地程序使用.net framework 4.5,管理员用户组,经过以上配置,服务器启动成功,eventvwr打开日志,程序里就没有错误日志了。

原文地址:https://www.cnblogs.com/passedbylove/p/9675980.html