配置文件在GAC集会 [英] Config files for assemblies in GAC

查看:140
本文介绍了配置文件在GAC集会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有需要读取它的配置设置,从它的配置文件,一个.NET的DLL。通常情况下,配置文件放在同一个目录中的DLL。但我怎么读取配置文件,如果DLL是GAC'ed,因为我可以只放了的DLL在GAC中,而不是它的配置文件。

I have a .NET dll which needs to read it's config settings from it's config file. Usually, the config file is placed in the same directory as the DLL. But how do i read the config file if the DLL is GAC'ed, because I can put only the DLLs in the GAC, and not it's config files.

推荐答案

难道用户需要配置DLL?如果是这样的话,DLL应使用的配置设置从app.config文件,而不是它自己的配置。 app.config文件应该被存储在同一目录中的应用程序。如果没有,那么你可以去几个不同的方式。你可以更改Machine.config文件,使您的DLL可以找到他们。我不会这么做。另外,也可以存储在设置类的配置。这些可以通过配置进行改写,但你的默认值将在生成的code的设置类通过属性来设置,因此没有一个配置文件不会影响您的DLL时,默认是所有需要。

Does the user need to configure the Dll? If so, then the DLL should be using configuration settings from the app.config file, not it's own config. The app.config file should be stored in the same directory as the application. If not, then you could go a couple of different ways. You could make changes to the machine.config file so that your Dll can find them there. I would not do this. Alternatively, you can store the configuration in a settings class. These can be overridden via configuration, but your defaults will be set in the generated code for the settings class via attributes and so the absence of a configuration file will not affect your Dll when the defaults are all that are required.

这篇关于配置文件在GAC集会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆