开发者

Configuring GAC-placed assemblies. Best practice

I have to implement .net assembly that would be put into GAC. It re开发者_Python百科lies on RDBMS connection string and some additional params - what is the best place I should put it? Machine.config, registry or something more appropriate?

Such information should be placed into application configuration file (app.config/web.config) that uses component (as noticed Marek Grzenkowicz), but what if application config is untouchable for some reasons?

Thank you in advance!


You should put such information into app.config / web.config file of application that uses the assembly. This way it will be possible to specify different settings for each such application.


I would think it would depend on how involved you want dependent assemblies to be in managing the settings.

A set-once-don't-think-about-it-anymore approach could be satisfied very well by the registry. A disadvantage of using the registry is lack of built-in support for retrieving the connection string in ADO.NET classes.

A this-might-be-different-on-a-per-application-basis approach might be satisfied better by demanding settings be in the application's app.config or web.config. The config files offer the added benefit of builtin connection string support for many ADO.NET-related classes.

I'm always a little leery of modifying the machine.config. I cannot explain why, really, except that the setting is global. Every connection string name used in a machine.config is a name that propagates to other configs and must either be used, ignored, or removed. It also complicates syncing development environments with production. That said, I do not suppose these reasons are super-compelling reasons to avoid the machine.config. Just weigh the tradeoffs before making a decision.

Custom files in isolated storage is another viable option, though it is typically used in limited trust environments; since the GAC is full trust, isolated storage may not be as compelling an option.


A 'component' that uses a specific database probably should not be in the GAC in the first place.

If you really need this, the Connectionstring is not a configuration in the normal sense. You should probably hard-code it into your assembly.

And please remind me never to install your software.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜