开发者

Configuration System failed to initialize - Windows Service .NET

开发者 https://www.devze.com 2022-12-15 19:26 出处:网络
I created a .NET windows service that installs without any issues o开发者_如何学运维n the dev machine. On the server that has only the .NET framework (and no VS installed), since I don\'t have the VS

I created a .NET windows service that installs without any issues o开发者_如何学运维n 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>


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


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号