使用多个配置文件的 Unity 配置

发布于 2024-09-26 15:01:19 字数 433 浏览 1 评论 0原文

有没有办法在多个配置文件中配置一个容器?

例如,我想在位于根目录的 web.config 文件中注册容器的类型,并在子文件夹的 web.config 文件中注册相同容器(和其他容器)的类型。

并且还在路径 C:\Company\Framework\Configs 的 company.config 文件中为其他容器注册其他类型。

当我尝试执行此操作时,我收到一个 ConfigurationError ,指出容器的条目已被添加。

编辑:这里有任何建议 http://unity.codeplex.com/Thread/View.aspx?ThreadId=23230

对于示例代码还有更多建议吗?

Is there a way to configure a container in multiple configuration files?

For instance, I want to register types for a container in a web.config file located at the root and also register types for the same container (and others containers) in the web.config file of sub-folders.

And also register other types for others containers in a company.config file in path C:\Company\Framework\Configs.

When I try to do this I get a ConfigurationError stating that the entry for the container has already been added.

EDIT: any suggestions here
http://unity.codeplex.com/Thread/View.aspx?ThreadId=23230

any more suggestions for sample code ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

坦然微笑 2024-10-03 15:01:19

我在这里发布了类似的问题: WCF + Unity 嵌套 web.config 问题

我有一个带有子目录“Services”的 Web 应用程序' 其中包含 WCF 服务。
此服务文件夹还有一个包含我的 WCF 配置的 web.config 文件。这对于 WCF 来说似乎不是问题。

相同的 web.config 还具有在我的服务中使用的统一配置。但我无法使用“GetSection”加载此配置

如果我将统一配置移至根 web.config,一切正常。

I have a similar question posted here: WCF + Unity nested web.config problem

I have a web application with a subdirectory 'Services' which contains WCF services.
This services folder also has a web.config file containing my WCF configuration. That doesn't seem to be a problem for WCF.

The same web.config also has unity configuration for use inside my services. But i'm unable to load this configuration using 'GetSection'

If I move my unity configuration to the root web.config, everythings works fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文