0

The problem is that whatever I put in the config file (Service1.exe.config) or even delete it - Windows Service simply doesn't care, it still pulls data from somewhere. I also noticed when I was searching for a value in files (searching for a string), I found it in the exe file of the service!? How is this possible? What can I do to change this behaviour? Thanks

    SMARTService.Properties.Settings propRemote;
    SMARTService.LocalSettings propLocal;
    SMARTService.smtp propSmtp;

    protected override void OnStart(string[] args)
    {

            propRemote = SMARTService.Properties.Settings.Default;
            propLocal = SMARTService.LocalSettings.Default;
            propSmtp = SMARTService.smtp.Default;
    }

And later I used them throughout code.

The settings file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <section name="SMARTService.smtp" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
            <section name="SMARTService.LocalSettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
            <section name="SMARTService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
        </sectionGroup>
    </configSections>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    </startup>
    <applicationSettings>
        <SMARTService.smtp>
        ....
        </SMARTService.smtp>

        <SMARTService.LocalSettings>
        ....
        </SMARTService.LocalSettings>
        <SMARTService.Properties.Settings>
        ....
        </SMARTService.Properties.Settings>
    </applicationSettings>

</configuration>
Dejan Dozet
  • 948
  • 10
  • 26
  • An exe is a binary. How did you find your text in it? – Praveen Paulose Apr 09 '18 at 19:41
  • TWrapNonExceptionThrows SMARTService Copyright © 2018 ) $ca79b006-429a-4458-9e81-2d56cbb572da 1.0.0.0 G .NETFramework,Version=v4.0 TFrameworkDisplayName.NET Framework 4Y KMicrosoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator15.5.0.0 – Dejan Dozet Apr 09 '18 at 19:46
  • Can you paste the code where you are accessing the config settings? – Praveen Paulose Apr 09 '18 at 19:48
  • What does your settings file look like? – Matt Apr 09 '18 at 19:55
  • I've added config file and the way I used it throughout code – Dejan Dozet Apr 09 '18 at 19:59
  • I'm not familiar with SMARTService, but if its anything like the out-of-the-box settings, there will be default values compiled into the generated code, for exactly the scenario like the config file goes missing. Try going to the definition of `Default`, or expanding the Properties folder in Solution Explorer. – Richardissimo Apr 09 '18 at 20:17
  • This is actually answered here: https://stackoverflow.com/questions/25060519/how-to-get-properties-settings-default-with-a-string – Dejan Dozet Apr 13 '18 at 14:36

0 Answers0