Configuration System failed to initialize - Windows Service .NET

喜你入骨 提交于 2019-12-11 01:27:20

问题


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>

回答1:


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




回答2:


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




回答3:


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).



来源:https://stackoverflow.com/questions/1991779/configuration-system-failed-to-initialize-windows-service-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!