Location of app.config file used by referenced library for My.Settings?

后端 未结 2 1348
情话喂你
情话喂你 2021-01-22 02:36

If I have a class library with an app.config file (I know it\'s not ideal, just bear with me for a moment) which has settings values created by using the projects S

2条回答
  •  攒了一身酷
    2021-01-22 03:05

    but that returns the application's config file. How can I determine which .config file the library is reading from when it calls My.Settings...?

    • By default, it will be always the main.exe.config.

      Take a look at this for detailed answer C# DLL config file for more informations

    • You can use external config files. This article on MSDN explains how.

    EDIT

    You're misunderstanding the situation, reread this line: The settings from the app.config file of the library project are definitely not copied into the app.config file of the application but I can sti retrieve the My.Settings from the libraries app.config.

    You are correct. Your settings in the dll.config will not be copied automatically in the app.config.

    Concerning the value that you are able to get from your dll, I am still looking for more official answer, but the answer seems to be:

    the 'old' values (the ones you define at development time) are hard coded. If the franework isn't able to access or open the config file it will use the defaults instead. This will always happen if you use settings in a dll.

    Take a look at this Settings.Default. always returns default value instead of value in persistant storage (XML file)

提交回复
热议问题