Jef*_*Fay 8 c# dll configuration
我正在编写一个类库作为抽象,用于登录我编写的任何应用程序,服务等.我通过使其非常可配置以满足我对大多数应用程序/服务日志记录方案的需求而使其变得非常强大.
配置旨在指定以下内容:
我已经阅读了一些关于DLL程序集配置的其他stackoverflow问题,它导致了托管程序集/ app的app.config之间的冲突.我相信我的程序集只是提供配置文件.
这是一个很好的场景吗?将我自己的配置烘焙到我的项目中可能是一个更好的主意,以便我的记录器从XML文件读取以检索配置值?
What you could do is
create a custom configuration section (using e.g. the COnfiguration Section Designer tool)
put your assembly's configuration into a separate MyAssembly.config file
reference that assembly config file from your host app's config:
<configuration>
<configSections>
<section name="YourAssembly"
type="YourAssembly.ConfigSection, YourAssembly" />
</configSections>
<YourAssembly configSource="MyAssembly.config" />
</configuration>
Run Code Online (Sandbox Code Playgroud)That way, you can "externalize" your configuration into a separate config file which you have only once (in your assembly's project), and any project needing it just needs those settings in its own config file.
| 归档时间: |
|
| 查看次数: |
10418 次 |
| 最近记录: |