views:

561

answers:

3

Typically we keep our config values in web.config/app.config and for the environment global config varialbes (and not application specific) in server machine.config file.

When deploying an object to the GAC where is the best location to keep these config type values? It seems that the best location would be a linked resource file.

Does anyone have any experience/recommendation with this approach? (sample code?)

thx

+1  A: 

The configuration values need to be in the application configuration of the executing assembly. It is the responsibility of the application to have the configuration values so that your assembly will have access to them when it is loaded into the AppDomain.

Andrew Hare
A: 

I've had a need for assembly-specific config files (as opposed to executing assembly config files) in the past.

For an assembly in the GAC, it is possible (but not recommended) to physically copy a config file to the assembly dll folder.

The solution I've used for creating a config file that can be shared across assemblies regardless of AppDomain is a a simple registry entry for my application that defines a shared config file location. This way, any assembly can retrieve configuration settings from a shared location, regardless of which executing assembly launched it. (especially useful for scripting - otherwise, you'd have to deploy a config file named wscript.exe.config in the windows\system32 folder - UGH!)

J Davis
+1  A: 

if you dont care of having specific configuration for each application using your dll you can place the configuration in the machine.config file inside the framework folder.

%systemRoot%/Windows/Microsoft.Net/Framework/[Version]/Machine.config

Oscar Cabrero
As mentioned this is an option however, I am looking for recommendation for storing config variables that use the gac object. These variables do not need to be accessible to every application (web) on the server.
David