Question General Guidance Regarding Configuration Properties

talamar

New member
Joined
Dec 30, 2011
Messages
2
Programming Experience
5-10
Hi all.

I am new to this community, but am not new to coding for WinForms or Web Applications. That said, I have been tasked with creating an enterprise technician scheduling application for the service industry that will have two components - the first, a windows service that will run continually on a server, and a second component that will have a WinForms UI to enable multiple users to interact with the database and the scheduling board in the event something has to be scheduled manually. This application will be used by multiple companies, that may have different databases, different tables, and different properties for field items.

My query is this: what is the best way to create and store mapping for these configuration items? I considered My.Settings, but these are applied on a per-user basis, and I need global configuration values. App.Config has read-only properties after deployment, so this is not a possibility. I thought about storing everything in an external XML file that is created on the first-run as part of the setup process.

What are the best practices in this regard? I have extensively searched the internet, but almost everything points to My.Settings and App.Config. Any advice will be greatly appreciated.

With regards,
talamar
 
The config file is actually not read-only unless you're a restricted user. Admin users can edit its contents, although it's not completely intuitive. Check this out as an example of how it can be edited:

[.NET 2.0+] Protected Configuration (Encrypting Config Files)

The encryption part is probably irrelevant to you but the editing part is possibly exactly what you need.

If only administrators will be using this app then you can go that way. If restricted users will be using it too then that's not an option. In that case you might consider using XML serialization to save and load a class instance in an XML file in a common location accessible to all users. The Public Documents folder is the logical choice for that.
 
Unfortunately, we have to plan for restricted users being able to use the app. I was sure that XML serialization was the way to go, but I just wanted confirmation from someone more knowledgeable than myself. Thanks for the input.
 

Latest posts

Back
Top