简体   繁体   中英

Config files for GAC objects

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

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.

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 aa 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!)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM