.NET App.Config Issues in Multiple Projects

I have a solution containing two projects. One project is the Windows service, which contains several classes for performing various functions. Another project is a Windows Form application designed to perform various testing and execution tasks that a service performs on demand. For example, a service will perform several different tasks over a specified period of time, but if you want to complete one of these tasks before the time runs out, you can download the Windows Forms application and immediately complete one of the tasks. A Windows Form application (henceforth referred to as a tester) refers to a Windows service project (here called Service). When the Tester is loaded, it creates an instance of one of the classes from the Service. Whenever buttons are pressed to complete a task, it refers to that instance,which was created, and calls the various methods of the class. The service uses application settings for configuration and therefore has app.config. Configuration settings are accessed using [ProjectName] .Properties.Settings.Default. [SettingName]. When the configuration settings for the tester are changed in their own app.config (or exe.config after release), the settings are updated without problems. If the tester is closed, the configuration changes and then opens again, the new settings will be filled. If the Reload method is called in the settings, the configuration is updated without problems. The service does the same. Configuration settings can be updated without problems.Configuration settings are accessed using [ProjectName] .Properties.Settings.Default. [SettingName]. When the configuration settings for the tester are changed in their own app.config (or exe.config after release), the settings are updated without problems. If the tester is closed, the configuration changes and then opens again, the new settings will be filled. If the Reload method is called in the settings, the configuration is updated without problems. The service does the same. Configuration settings can be updated without problems.Configuration settings are accessed using [ProjectName] .Properties.Settings.Default. [SettingName]. When the configuration settings for the tester are changed in their own app.config (or exe.config after release), the settings are updated without problems. If the tester is closed, the configuration changes and then opens again, the new settings will be filled. If the Reload method is called in the settings, the configuration is updated without problems. The service does the same. Configuration settings can be updated without problems.If the Reload method is called in the settings, the configuration is updated without problems. The service does the same. Configuration settings can be updated without problems.If the Reload method is called in the settings, the configuration is updated without problems. The service does the same. Configuration settings can be updated without problems.

The problem is that if the service needs to make configuration changes when the service methods are called from the tester, the configuration does not accept the new settings. Any settings that were built in the project will be used. I cannot force the tester to admit that app.config / exe.config for the service has changed, and the new configuration should be reloaded and used instead of any configuration when the project was built in the visual studio. I may not be sufficiently aware of this topic, but it seems to me that app.config is minimized to the .exe file created by the Service when it is built.

I tried to encapsulate the Reload method for the Service and call it, and that doesn't seem to matter.

, , , . - exe.config " ", - . , , :

. .

Update

, , . app.config, , Configuration Manager App Settings, , . , ; , app.config, Configuration Manager app.config.

+3

Source: https://habr.com/ru/post/1786799/


All Articles