通过将配置数据放入web.config中,我可以在几个Web应用程序中使用Castle Windsor。Windows服务无法访问app.config中的Castle Windsor配置数据
因此,当我决定在Windows服务中使用它时,我认为它会很小。我的app.config文件如下所示:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler,Castle.Windsor" />
</configSections>
...various other stuff...
<castle>
<components>
...component listings...
</components>
</castle>
</configuration>
我创建我的容器是这样的:
WindsorContainer windsorContainer = new WindsorContainer(new XmlInterpreter());
但是疯狂,当应用程序运行时,我得到
Could not find section 'castle' in the configuration file associated with this domain.
at Castle.Core.Resource.ConfigResource..ctor(String sectionName)
at Castle.Core.Resource.ConfigResource..ctor()
at Castle.Windsor.Configuration.Interpreters.AbstractInterpreter..ctor()
at Castle.Windsor.Configuration.Interpreters.XmlInterpreter..ctor()
...application stack trace...
我'有点朦胧。任何人有任何提示?
干杯
大卫
该应用从app.config中读取其他配置数据就好了,但Castle有可能在您提到的位置查找。我会检查一下并看看。 – David 2010-08-13 08:55:51
我现在有另一个错误,哈哈!我认为这意味着你的建议奏效了。你已经回答了我的问题,但这是我无法接受的解决方法,因此我将考虑其他配置选项。 – David 2010-08-13 09:24:10
我通过将windsor配置文件的位置传递给XmlInterpreter的构造函数(请参阅代码)来解决此问题。 – David 2011-06-30 12:12:53