Solved

"configuration system failed to initialize" in windows service

Posted on 2010-09-19
2
1,865 Views
Last Modified: 2012-06-22
Hi,

I created a windows service and installed successfully using setup project. However, it throws an exception when I try to start the service. The exception is "configuration system failed to initialize". My app.config has been attached as below. it seems the service could not get the connection string correctly.

this the code throwing exception:
        protected override void OnStart(string[] args)
        {
            string x = ConfigurationManager.ConnectionStrings["LDConnectionString"].ConnectionString;
         }

any idea?
<?xml version="1.0" encoding="utf-8" ?>

<configuration>

  <connectionStrings>

    <add name="LDConnectionString" connectionString="Data Source=.;Initial Catalog=LDIntranet;Persist Security Info=True;User ID=ldIntranetUser;Password=XXXXX" providerName="System.Data.SqlClient" />

  </connectionStrings>

  <appSettings>

    <add key="EmailFromAddress" value="customer@ld.com.au" />

  </appSettings>

  <log4net>

    <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">

      <file value="c:\trace.log" />

      <appendToFile value="true" />

      <maximumFileSize value="100KB" />

      <maxSizeRollBackups value="2" />

      <layout type="log4net.Layout.PatternLayout">

        <conversionPattern value="%level %thread %logger - %message%newline" />

      </layout>

    </appender>

    <root>

      <level value="ALL" />

      <appender-ref ref="RollingFile" />

    </root>

  </log4net>

</configuration>

Open in new window

0
Comment
Question by:viola123
2 Comments
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 33713701
0
 
LVL 6

Author Comment

by:viola123
ID: 33713831
i already figured out the problem. it was missing configSection part for log4net, thx
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now