views:

340

answers:

2

I have a .NET assembly for a COM-visible component that I want to use some configurations. I know that applications use the app.config, but is it a violation of best practices to create and use an app.config for my assembly??

+1  A: 

If your configuration is simple, and your component is COM visible, then it might be easier just to use either a small configuration file in the Program data (users or machine) or just put something in the registry.

In our products I have registry keys that allow for overriding settings for a development machine, or a customer needs assistance from one of the developers

Paul Farry
+1  A: 

My understanding is that if when you build the assembly, you have an app.config file then it will be turned into assmeblyName.dll.config by the compiler. If this present in the same directory as the assmebly at runtime, then it will be loaded whenever you try and read app.config. This explains it a bit clearer.

I see it as being a sensible way of partitioning the configuration data so that the data relevant to the assembly is kept with the assmebly.

EDIT This technique applies to appSettings, not sure if other data in app.config can be shared in the same way.

Colin Desmond
@Colin: This technique appears to require a custom class, so it wouldn't work with an existing assembly.
Steven Sudit