0

在对 Windows 服务进行细微更改并将这些更改部署到生产暂存 (Windows Server 2008) 后,Windows 服务无法启动。

事件日志仅说明

Windows 检测到您的注册表文件仍在被其他应用程序或服务使用。现在将卸载该文件。保存您的注册表文件的应用程序或服务之后可能无法正常运行。

其中一项更改是 NLog 配置文件条目,由于Slow Cheetah的魔力,该条目仅适用于生产构建设置。

4

1 回答 1

0

事实证明,Production NLog 配置中有一个非法的 NLog 配置设置。

NLog 没有将任何诊断信息写入事件日志。在控制台模式下运行服务(我使用一种模式来检查 /console 标志以作为控制台应用程序而不是作为服务运行),抛出了一个有用的异常:

Unhandled Exception: System.TypeInitializationException: The type initializer for 'My.Service' threw an exception.
NLog.NLogConfigurationException: Exception occurred when loading configuration from C:\MyService\NLog.config 
---> System.NotSupportedException: Parameter levels not supported on FileTarget   

经验教训:如果使用 NLog 的 Windows 服务在没有有意义的 EventLog 条目的情况下无法启动,请仔细检查 NLog 配置。

共享问答风格,希望这可以节省我整理的 15 分钟。

于 2012-07-03T16:31:41.733 回答