You need to apply the changes to the exe assembly configuration file at the entry point. Assembly library (dll) configuration files are never used. They are created using Visual Studio, so you can easily copy the settings into exe configuration files, if necessary.
The following is an example configuration file for an exe assembly that has both parameters from the ClassLibrary1 class ClassLibrary1 and settings from the exe assembly MainAssembly . You can see that both connection strings are in the same connectionStrings setting. However, if you need to set other settings, next to the connection string you need to add an additional section.
If you are already using this technique, this is the right way. This method is flexible. For example, if in one window there are several projects with the same connection strings, you can specify the connection strings in the machine.config file. You can also override settings in some projects.
<?xml version="1.0"?> <configuration> <configSections> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <section name="ClassLibrary1.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> <section name="MainAssembly.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </sectionGroup> </configSections> <connectionStrings> <add name="MainAssembly.Properties.Settings.MainAssemblyConnectionString" connectionString="MainConnectionStringValue" /> <add name="ClassLibrary1.Properties.Settings.LibraryConnectionString" connectionString="LibraryConnectionStringValue" providerName="" /> </connectionStrings> <applicationSettings> <ClassLibrary1.Properties.Settings> <setting name="LibrarySetting" serializeAs="String"> <value>LibrarySettingValue</value> </setting> </ClassLibrary1.Properties.Settings> <MainAssembly.Properties.Settings> <setting name="MainAssemblySetting" serializeAs="String"> <value>MainSettingValue</value> </setting> </MainAssembly.Properties.Settings> </applicationSettings> </configuration>
Alex aza
source share