配置系统无法初始化 - Windows Service .NET

发布于 2024-08-16 09:44:37 字数 1058 浏览 3 评论 0原文

我创建了一个 .NET Windows 服务,在开发计算机上安装时没有任何问题。在只有.NET框架(并且没有安装VS)的服务器上,由于我没有VS 2008提示符,所以我执行了以下操作。

  1. 我打开了命令提示符
  2. cd C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727
  3. 我尝试使用 installutil.exe 安装该服务“路径service .exe”

我收到以下异常:

Microsoft (R) .NET Framework Installation utility Version 2.0.50727.1433
Copyright (c) Microsoft Corporation.  All rights reserved.

Exception occurred while initializing the installation:
System.Configuration.ConfigurationErrorsException: 
Configuration system failed to initialize

此服务在我的本地主机上安装/卸载没有任何问题。有什么帮助吗?

service.exe.config 如下所示:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <!-- Should process conversions -->
    <add key="Service.EnableConversions" value="true"/>
    <!-- Poll Interval-->
    <add key="Service.Interval" value="10000" /> <!-- Set to 10 seconds -->
  </appSettings>
</configuration>

I created a .NET windows service that installs without any issues on the dev machine. On the server that has only the .NET framework (and no VS installed), since I don't have the VS 2008 prompt, I did the following.

  1. I opened the command prompt
  2. I did cd C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727
  3. I attempted to install the service using installutil.exe "Path to the service .exe"

I get the following exception:

Microsoft (R) .NET Framework Installation utility Version 2.0.50727.1433
Copyright (c) Microsoft Corporation.  All rights reserved.

Exception occurred while initializing the installation:
System.Configuration.ConfigurationErrorsException: 
Configuration system failed to initialize

This service installs/uninstalls without any issues on my local host. Any help?

The service.exe.config looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <!-- Should process conversions -->
    <add key="Service.EnableConversions" value="true"/>
    <!-- Poll Interval-->
    <add key="Service.Interval" value="10000" /> <!-- Set to 10 seconds -->
  </appSettings>
</configuration>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

眼藏柔 2024-08-23 09:44:37

这是服务器上的 machine.config 损坏的问题。重新安装后这个问题就解决了。

It was an issue with a corrupt machine.config on the server. After reinstalling it this issue was resolved.

拥抱我好吗 2024-08-23 09:44:37

从 C:\Windows\Microsoft.NET\Framework\v4.0.30319 文件夹运行 InstallUtil.exe 时收到此错误。要修复此问题,请尝试将 machine.config.default 复制到 machine.config(如果当前的 machine.config 实际上存在于 Config 目录中,则可以备份它)。

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config
copy machine.config.default machine.config

现在切换到父目录并运行InstallUtil.exe /?查看它是否显示使用信息。

cd..
InstallUtil.exe /?

希望这有帮助。
保罗

Received this error running InstallUtil.exe from the C:\Windows\Microsoft.NET\Framework\v4.0.30319 folder. To fix, try copying the machine.config.default to machine.config (maybe backup your current machine.config if it is actually present in the Config directory).

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config
copy machine.config.default machine.config

Now change to the parent directory and run InstallUtil.exe /? to see if it displays the usage info.

cd..
InstallUtil.exe /?

Hope this helps.
Paul

一抹苦笑 2024-08-23 09:44:37

不确定为什么您的配置会引起任何麻烦...

您可以尝试使用 sc.exe 工具创建并安装您的服务吗?它是 Windows 的一部分,应该出现在所有更新的 Windows 版本中。

执行 sc -? 以获取有关所有参数的完整信息。

基本上,要创建和安装该服务,您需要:

sc create (service name) binPath= (path to your exe) DisplayName= (display name)

注意“=”符号后的空格!它们是必需的 - 没有它们,它就无法工作(我知道这很奇怪 - 但这就是语法 - 相信我)。

Not sure why your config should cause any trouble....

Can you try to create and install your service with the sc.exe tool instead? It's part of Windows and should be present on all more recent Windows versions.

Do a sc -? to get the full info about all the parameters.

Basically to create and install the service, you need:

sc create (service name) binPath= (path to your exe) DisplayName= (display name)

Watch for the spaces after the "=" sign! They're needed - without them, it won't work (I know it's odd - but that's the syntax - trust me).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文