none
System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize.

    Question

  •  

     

    Hello,

     

    I'm trying to create a windows service that will execute a gui application when windows start.  I created the service and added the installer, but when I try to install the service via the command line I get the following exception:

     

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

     

    I have researched the web and I find that a lot of people talk about the app.config.  Do I need one of those?  What do I place in this config file that will get my service to install? 

     

    Any help would be greatly appreciated.

     

    Thank you!

     

    MJ

     

    P.S. I searched for a C++ .NET forum, but I didn't see one.  I hope this is in the right place.  If not, please let me know the appropriate place to post this question.  Thanks!

    Friday, May 23, 2008 1:20 PM

All replies

  • Hi James,

     

    Can you tell me how you install the Windows Service? Do you use installutil.exe? Also, where do you get this exception? Can you provide the stack trace of this exception? This will help us to analysis this problem.

     

    Additionally, I see one issue which is caused by wrong encoding of system web.config file. I think you may to check determine if it helps to resolve this problem:

    http://kb.parallels.com/en/3986 

     

    Thanks.

     

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

     

    Monday, May 26, 2008 2:52 AM
    Moderator
  • Hello,

     

    Thanks for your reply.  I tried installing the service using the installutil.exe in the Visual Studio 2005 command prompt.  I get the exception when I try to install the service.  The code compiles without any errors or warnings.  Here is what I get in the command prompt after trying to install.

     

    Setting environment for using Microsoft Visual Studio 2005 x86 tools.

     

    C:\Program Files\Microsoft Visual Studio 8\VC>C:\SimpleService\Debug\SimpleService.exe -Install

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

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

     

    C:\Program Files\Microsoft Visual Studio 8\VC>

     

    Thanks.

    Wednesday, May 28, 2008 12:22 PM
  • Hi James,

    Thanks for your feedback.

    From your pasted output, it seems that did not use installutil.exe to install your service. You should install the service like this:
    "installutil.exe C:\SimpleService\Debug\SimpleService.exe"

    This should not generate any exception since it will not run the target service untile we run it at later time.

    Thanks.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Jeffrey Tan - MSFT
    Friday, June 06, 2008 2:44 AM
    Moderator
  • Hello,

    Thanks for your reply.  I tried using the installutil.exe command, but unfortunately I get the same error.  I'm not sure what could be causing this problem.  I tried creating a service using Visual Studio 2003 and it installs properly.  The problem there is it will not load a managed executable created using VS 2005.  I get a System.BadImageFormatException.  I also tried loading an executable created in VS 2003, but I get a . System.IO.FileLoadException: Unverifiable image  exception.  In the 2003 service, I try using ExecuteAssembly and that causes the problem.  When I take out that function the service runs fine.

    Thanks for your help.
    • Proposed as answer by Bryan Miller Monday, February 11, 2013 9:58 PM
    Friday, June 06, 2008 1:17 PM