Is there a way to configure an assembly in GAC? I want to add a custom configuration to my assembly with System.Configuration.
有没有办法在GAC中配置程序集?我想使用System.Configuration向我的程序集添加自定义配置。
Mher
3 个解决方案
#1
3
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.
程序集使用加载它的应用程序的配置文件。
#2
0
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.
根据您尝试实现的方案,您可以将App.config文件包含为嵌入式资源,并在需要时提取到磁盘上的某个位置并使用给出此问题的建议加载。
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.
另一种选择可能是将配置文件安装到Application Data或Common Application Data文件夹中,并使用与上面相同的技术。
#3
0
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.
在标准的.NET框架中,没有简单的方法可以做到这一点。如果使用Enterprise Library配置组件,则FileConfigurationSource类将允许您在另一个位置定位配置文件。还有一种偷偷摸摸的方式来使用标准的ConfigurationManager的OpenExeConfiguraion方法来实现它。我在我的博客上写了一篇文章,名为Creating Dummy Targets For Configuration Objects,描述了它是如何完成的。
#1
3
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.
程序集使用加载它的应用程序的配置文件。
#2
0
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.
根据您尝试实现的方案,您可以将App.config文件包含为嵌入式资源,并在需要时提取到磁盘上的某个位置并使用给出此问题的建议加载。
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.
另一种选择可能是将配置文件安装到Application Data或Common Application Data文件夹中,并使用与上面相同的技术。
#3
0
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.
在标准的.NET框架中,没有简单的方法可以做到这一点。如果使用Enterprise Library配置组件,则FileConfigurationSource类将允许您在另一个位置定位配置文件。还有一种偷偷摸摸的方式来使用标准的ConfigurationManager的OpenExeConfiguraion方法来实现它。我在我的博客上写了一篇文章,名为Creating Dummy Targets For Configuration Objects,描述了它是如何完成的。