views:

46

answers:

1

I have a c# class library that builds into a DLL.

I have some setting values, like paths to directories, that I use inside the class library.

I would like to make it so, that whomever references the DLL has a chance to edit the default values of the settings (preferably through a file). Like,

[In the class library] Default value would be FooDir = "C:/Program files/"

[Project X references the library] We would like to change the FooDir's value to "C:/Program files(x86)/".

It would be neat, if Visual Studio would generate a XML file containing the FooDir config/setting and then copy it to Project X's output directory. And then we could change the FooDir's value there and this new value of FooDir would be reflected when running Project X.

How can I achieve this?

A: 

Your best bet here is to create a Custom COnfiguration section for your application, set defaults for everything, then if the users want to override anything they can add the configuration section to their app.config or web.config file.

It is very easy, and quick to do. Here is a step-by-step tutorial.

This follows standards that have been established with .NET and should be very familiar for any users.

Mitchel Sellers