title: Windows Service Starting Failure
body: <p>I have a windows service written in C# and installed on my machine by using the installUtil.exe utility. After the installation completes successfully, I am trying to start the service. However it is giving me a 1053 error. </p>
  
  <p>Now the truly weird thing is that when I delete the Config file the service starts just fine (Although then it stops because of a null pointer Exception, which is to be expected since there is no config file).</p>
  
  <p>Any insights on this? I'm at loss here I've installed another service on the same machine which works just fine.</p>
  
  <p>Note: the OS is Windows 7 Home Premium x64</p>
  
  <p>edit ======= </p>
  
  <p>To make it clear, I tried logging (using the event Viewer) in the <code>OnStart()</code> Method. When the log file is deleted I can see all the log entries and the service works fine up to the point where it needs to get data from the config file.</p>
  
  <p>The problem seems to be when the config file is still present. The first line of the <code>OnStart()</code> Method makes a log entry, HOWEVER, the program is not reaching this point.</p>
  
  <p>edit 2 ========================</p>
  
  <pre><code>protected override void OnStart(string[] args)
      {
          try
          {
              this.EventLog.WriteEntry("Starting Focus Stock Service");
  </code></pre>
  
  <p>This log entry is being logged only if the config file is not present otherwise it will not get to this point.</p>
  
  <pre><code>&gt; &lt;?xml version="1.0"?&gt; &lt;configuration&gt;   &lt;appSettings&gt;
  &gt;     &lt;add key="Directory" value="C:\Logs\FocusCommon"/&gt;
  &gt;     &lt;add key="FileName" value="log"/&gt;
  &gt;     &lt;add key="LogLevel" value="3"/&gt;
  &gt;     &lt;add key="StockRemotingServerPort" value="10001"/&gt;
  &gt;     &lt;add key="StockRemotingServerName" value="FocusStockServer"/&gt;
  &gt;     &lt;add key="SQLServerConnStringTemplate" value="server=$server$;uid=$username$;pwd=$password$;database=$database$;MultipleActiveResultSets=True;Pooling=False;"/&gt;
  &gt;     &lt;add key="AccountingSynchIntervalMinutes" value="1"/&gt;
  &gt;     &lt;add key="LocalImageDirectory" value="C:\Focus360_Image_Dir"/&gt;
  &gt;     &lt;add key="LocalBrandImageDirectory" value="C:\Focus360_Image_Dir\Brands"/&gt;
  &gt;     &lt;add key="LocalAttachmentDirectory" value="C:\Focus360_Attachment_Dir"/&gt;
  &gt;     &lt;add key="EmailServer" value="maltanet.net" /&gt;
  &gt;     &lt;add key="EmailPort" value="25" /&gt;
  &gt;     &lt;add key="EmailUserName" value="" /&gt;
  &gt;     &lt;add key="EmailPassword" value="" /&gt;
  &gt;     &lt;add key="EmailUseSSL" value="false" /&gt;   &lt;/appSettings&gt;
  &lt;runtime&gt;
          &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
              &lt;dependentAssembly&gt;
                  &lt;assemblyIdentity name="FSS_SQLConnPool" publicKeyToken="40FEE7F833FAA042" culture="neutral"/&gt;
                  &lt;bindingRedirect oldVersion="0.0.0.0-1.0.4525.28539" newVersion="1.0.4525.28539"/&gt;
              &lt;/dependentAssembly&gt;
          &lt;/assemblyBinding&gt;
      &lt;/runtime&gt;
  &lt;startup&gt;&lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/&gt;&lt;/startup&gt;&lt;/configuration&gt;
  </code></pre>