How to set a config/property on a program without recompiling to change a setting on GUI

Hello every1,

I have a current program where I added a setting in the config where it hides some tabs and file menus depending on a boolean value. I would like to be able to turn this config setting on/off without having to recomplile and republish the program. What would be the best way to do something in this nature? What would you guys suggest? Maybe an external XML file and and set the property: Copy to Output = Copy Always?

In a diff program I created a debug log txt file and once I published and installed the program the log is no where to be found. So I am just curious where this would go after I installed the program and so a user without technical knowledge could easily change this file and that would adjust the settings on the program.

My current setting I put in -
Properties.Settings.Default.SystemManualDir;
But I cant find this file after installing the published program.

Do you want the change to take affect right away (if changed when the app is running) or just on next start of the application?

If you are ok with it being the next time the application starts, then I would add a config file with that setting, and make sure that it gets deployed with the app.

Hello,

In my projects I have a configuration file with extension .config and internal xml configuration.

Every time a user logs on to a web application or a windows service or console application they start, the file is read and deserialized into a custom class with various properties.

The class can contain properties where to store configuration of databases, roles, users, … This class would be static and can be read from any point of the application and apply it to the authenticated user or started service.

I hope it helps.

Hello guys thank you for the feedback. I’m still not 100% sure about this. I would like the input to be able to read right away, as soon as it is changed. I’m currently using the ‘Properties-Settings-Default’ to hold some data in variables for the program. 1 of my settings is a simple boolean and it displays certain Menu Items and Tabs on the program whether the user has access to this or not. Is this the right way to do such a thing? Using the default properties-settings on the program are those being read on runtime? if the program is running and 1 of those properties change will it take affect right away? or would the application have to restart? I also have another variable in the settings which stores a file directory path and this is the location of a vault. If the user changes this path I would like the treeview (vault) to be able to change. Maybe this will help you guys understand what i’m looking for.public string VaultPath { get; set; } = Properties.Settings.Default.PDFVault;

Hello,

First of all, is your application web or desktop application?

  1. If the application is web, any change in the application on the server side: change of web.config, properties file, … will cause a restart to the users to refresh the cache and obtain the new configuration values.

  2. If your application is desktop, a change in the properties file can force the value to be refreshed using: ApplicationSettingsBase.Reload. Causes the configuration reload. You could put the previous function in the functionalities that you need to read and have the properties live the configured value. More info: https://docs.microsoft.com/en-us/dotnet/api/system.configuration.applicationsettingsbase.reload?view=dotnet-plat-ext-3.1

regards

It’s a desktop App.
I’ll try that applicationSettingsBase.Reload after a config property is saved. That would be exactly what I’m looking for if it refreshes the program and takes the new settings!

.NET Foundation Website | Blog | Projects | Code of Conduct