Search code examples
dllweb-configapplication-settings

ApplicationSettings for DLL with WCF and Console Application


My project consists of a web service (WCF) and a console application that uses a common library in other projects. This library has ApplicationSettings. With Console application, I only have to set:

<?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="MyProject.Library.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
  </configSections>
  [...]
  <applicationSettings>
    <MyProject.Library.Properties.Settings>
      <setting name="EnvironmentMask" serializeAs="String">
        <value>RCT_</value>
      </setting>
    </MyProject.Library.Properties.Settings>
  </applicationSettings>
  [...]
</configuration>

I tried to do the same side Web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <sectionGroup name="MyCompany.ConfigurationGroup">
      <section name="SignedFileConfiguration" type="MyCompany.Web.SecureFileProxy.SignedFileConfigurationHandler, Net.MyCompany.Web" />
    </sectionGroup>
    <sectionGroup name="applicationSettings">
      <section name="MyProject.Library.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
  </configSections>
  [...]
  <MyCompany.ConfigurationGroup>
    <SignedFileConfiguration Secret="SecretKey!" PatternOfGeneratedUrl="http://www.myCompany.net/cgi/getFile.aspx?volume={0}&amp;path={1}&amp;token={2}&amp;name={3}" ConfiguratorType="MyCompany.Web.SecureFileProxy.SignedFileConfiguration, Net.MyCompany.Web">
      <Volumes>
        <add Name="fallow" PhysicalPath="" />
      </Volumes>
    </SignedFileConfiguration>
  </MyCompany.ConfigurationGroup>
  <applicationSettings>
    <MyProject.Library.Properties.Settings>
      <setting name="EnvironmentMask" serializeAs="String">
        <value>DEV_</value>
      </setting>
    </MyProject.Library.Properties.Settings>
  </applicationSettings>
  [...]
</configuration>

During the execution of the web service, I get an exception : System.Configuration.SettingsPropertyNotFoundException and the object MyProject.Library.Properties.Settings is empty

the only website which talk about that is https://littletalk.wordpress.com/2008/05/07/use-applicationsettings-in-web-application/ but it isn't enought for me.

I hope you could help me. Thanks for your attention Regards


Solution

  • I found the cause of this issue.

    it's because I use log4net and it has an issue https://issues.apache.org/jira/browse/LOG4NET-398

    I have to find a new way to do it.