问题
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.
- I opened the command prompt
- I did
cd C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727
- 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