What use has the default (assembly).dll.config file for .NET-Assemblies? What use has the default (assembly).dll.config file for .NET-Assemblies? xml xml

What use has the default (assembly).dll.config file for .NET-Assemblies?


The default values are built into the .dll file. You can of course still change those settings, but you do that in the program.exe config instead by referring to the assembly settings with a section in configSeconds/sectionGroup. The assembly settings can then be changed in the applicationSettings by creating a XML block with the same name as the section.

The section tag in the section group can simply be copied from the app.config file of your assembly project. That way the token, name, etc. will be correct. The same goes for the applicationSettings part. Just copy it from the app.config in the assembly project and into the app.config file of the program.exe project.

example program.exe.config:

<configuration>  <configSections>    ... references to all dll settings ...    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">      <section name="MyAssemblyNamespace.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />  </configSections>  ... more config stuff...  <applicationSettings>    ... override your dll settings ...    <MyAssemblyNamespace.Properties.Settings>       <setting name="MaxUserNameLength" serializeAs="String">          <value>100</value>       </setting>    </MyAssemblyNamespace.Properties.Settings>  </applicationSettings>


It's valid for an assembly to open any config file it likes using the OpenExeConfiguration method. This way that can access their own config rather than the one implicitly available from the executing assembly. This isn't commonly done, but there's nothing to stop you doing it.

If your assembly is functioning correctly without the config file then it sounds like it has a sensible set of default value that it uses when it cant find the appropriate configuration.