tags:

views:

398

answers:

3

Hi,

Is there a way to configure an assembly in GAC? I want to add a custom configuration to my assembly with System.Configuration.

Mher

+2  A: 

If I understand your question right, no, there is no way to do this.

An assembly uses the configuration file of the application that loads it.

Joe
A: 

Depending on what scenario you are trying to achieve, you could include your App.config file as an embedded resource and when required extract to somewhere on disk and load using the advice given to this question.

Obviously this removes the ability to actually change the config without recompiling, so kind of defeats the purpose.

Another option might be to have the config file intalled into either the Application Data or Common Application Data folder, and use the same technique as above.

Chris Ballard
A: 

There's no easy way to do this in the standard .NET framework. If you use the Enterprise Library configuration components, the FileConfigurationSource class will allow you to target a configuration file in another location. There's also a sneaky way to use the standard ConfigurationManager's OpenExeConfiguraion method to do it. I wrote a post on my blog called Creating Dummy Targets For Configuration Objects that describes how it's done.

dthrasher