5

I have written an application in C# with a settings file (which is used to create an app.config file at compile time). This application uses a C# DLL which also has a settings file.

I read the following from this post:

If you build a project that references your DLL, you would add the same .settings file to that project and those settings would appear in the app.config file for the app and the DLL would be able to read those values. IF those values aren't in the app.config, the dll will fall back on the defaults.

I observed the DLL storing default values as this indicates it should. I right clicked on my application's project and selected Add Existing Item. Then I found the settings file from my DLL's project and added it to the application's project. My hope was that both the DLL settings file and the application settings file would be included in the application's app.config file. This way, the application's app.config file would override the defaults stored in the DLL. Unfortunately, this isn't happening.

So, my question is after adding the settings from the DLL project to the application project, how do I make the application project recognize the file and add its settings to the app.config file at compile time?

Community
  • 1
  • 1
Brian
  • 1,201
  • 2
  • 14
  • 26
  • The .NET configuration system isn't designed and intended to be able to use multiple config files - its basic assumption is that you will put all relevant config entries into the config of the main app – marc_s Jul 14 '10 at 16:59
  • I understand that there can only be one config file. My intention is that two settings files would be combined in a single config file. One settings file comes from the same project as the config file while the other settings file comes from an external project. – Brian Jul 14 '10 at 17:10

1 Answers1

1

I'm unsure what you mean. Have you tried including it in a similar way to the following?

<appSettings file="dataSettings.config"/>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Phil C
  • 3,687
  • 4
  • 29
  • 51
  • 1
    If you post code or XML, **please** highlight those lines in the text editor and click on the "code" button (101 010) on the editor toolbar to nicely format and syntax highlight it! It's especially for XML because otherwise, it might just not show up (like your line just wasn't visible).... – marc_s Jul 14 '10 at 17:09
  • 1
    My app.config file is being automatically generated by the C# compiler. The compiler readings by Settings.settings file and uses it to generate XML to include in the app.config file. My objective here is to have one Settings.settings file (in the DLL project) set up so that if I make a change in that Settings.settings file, the change will cause the app.config file to be updated in both locations. I could simply create a copy of the Settings.settings file in the application project, but I'm trying avoid needing to change two files each time I adjust a setting. – Brian Jul 14 '10 at 17:21