Best Practice for storing settings for a .NET Windows Service: Service Property Settings, Serialization,
Tag : chash , By : user183289
Date : March 29 2020, 07:55 AM
this one helps. I've had problems with using Settings.settings. For instance, if you need to make changes at run-time, there can be problems with the settings being overridden by those that were initially stored in the settings.settings file as opposed to what's shown should be stored per the app/web.config. Consequently I make all my Web Service proxy settings "static" in the properties and pull them manually from the app/web.config via a helper method and programmatically set them. This circumvents any problems. An example of the issue we had: I pointed my development machine to a web service on a test server to test the code that consumed the web service. When the code was moved to our test server, no problems manifested - as the test server was still pointed at the same web service on the same test server. However, when we moved the application to the production server and reconfigured the web.config to point at the production server we started getting screwy results. It took quite a bit of effort to pinpoint that even though we had reconfigured the application to point at the production server's implementation of the web service, it was still connecting to the web service on the test server. It wasn't until we changed settings.settings on my development machine and recompiled the application that it worked. Further to this, we also noted that if there were DNS problems connecting to the production web service, rather than fail, it fell back to the original settings that were specified in the settings.settings from when we created the web service proxy in our application - the proxy generator actually hard codes them. Consequently when there were network outages, instead of getting easily diagnosed connection failures, it simply fell back to the test server and we started getting incomprehensible data issues. I'm not sure if this was a known problem or if it's been fixed, but it's certainly something you should be aware of.
|
Storing Settings for C#?
Date : March 29 2020, 07:55 AM
hope this fix your issue Settings.settings works. However it sounds like you would be better off making your own serialization format for this type of data. Keep in mind that the Settings.settings class is good for trivial user and application settings. Nested, complex, or large structures that can change should use an application specific format. Use settings.settings for window locations and color preferences (as an example).
|
Storing settings in configFile
Tag : chash , By : Lucyberad
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Try to save all data in to config file, and then read it and apply to my program during running - as user preference. Whats done: create new config file (using Add new element-> add congif file). In this file put simple code , try this: <?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Volume" value="100" />
</appSettings>
</configuration>
return Convert.ToInt32(ConfigurationManager.AppSettings["Volume"]);
|
Storing / Modify / Using app settings
Tag : chash , By : user107021
Date : March 29 2020, 07:55 AM
Hope that helps You are on the right track and already answered most of your question. For a web app, it is a fairly standard practice to load a user's settings into a session var upon login (unless you have multiple servers set up as a web farm). Setting up a class, to wrap your settings, is good design too, because you can use strong types and add mechanisms for storing settings to your session & db. If you ever change that approach, having it wrapped in a class will make it easier to refactor/re-engineer your approach.
|
Storing settings in Properties.Settings.Default vs the Registry
Tag : chash , By : abuiles
Date : March 29 2020, 07:55 AM
|