views:

91

answers:

4

Basically multiple instances of our application will be launched but they need to have separate user settings. We currently have use "user settings" for that, and it works fine for a single instance (per windows user) but we would like to be able to launch multiple instances with say a settings path passed in via command line. Is there a way to do this with the built-in .NET settings or will we have to roll our own?

+1  A: 

I recommend developing a class that will handle app settings and accepts a filename. I've had to do this for DLLs that needed app settings, and it also helps if you want to store your settings in a non-local location (e.g. single place on the network).

It will give you a lot more flexibility - It's definitely worth the investment!

Michael Rodrigues
A: 

.Net has a Configuration Provider API. app.config is just a predefined implementation of that API. You should look into using the API to either extend the built-in API, or create your own.

Payton Byrd
+1  A: 

The LocalFileSettingsProvider class, the one that manages the file with user settings, is quite impossible to tweak. Whomever wrote that must have been paralyzed by security concerns. Perhaps not unjustified.

If you want to stick with System.Configuration then you'll need to implement your own provider. Probably the best way to do that is to start from the RegistrySettingsProvider sample. It won't help you get the file handling right but at least you'll have something to build on. A couple of peeks with Reflector can help.

Hans Passant
A: 

I would suggest to store the config information in DB and read based on the user. Any case you have to maintain the user specific information different copies. Onload of the application read from DB and cache all the settings.

User User Personalization and profile API to retrieve the information. It is very easy to update the information in DB rather then dealing with files which are located in users systems.