C# 在迁移到Windsor 3之后,从xml注册不同的实现并为一个接口注册代码是失败的

C# 在迁移到Windsor 3之后,从xml注册不同的实现并为一个接口注册代码是失败的,c#,castle-windsor,windsor-3.0,C#,Castle Windsor,Windsor 3.0,我们正在将一个稳定的项目从Castle Windsor 2.5.2迁移到3.0 我们使用混合xml/api注册。切换到3.0后,通过ctor注入并在xml中定义的参数将无法再解析 举例说明: <?xml version="1.0" encoding="utf-8" ?> <configuration> ... <properties> <frontEnd.url>http://site.com</frontEnd.url>

我们正在将一个稳定的项目从Castle Windsor 2.5.2迁移到3.0

我们使用混合xml/api注册。切换到3.0后,通过ctor注入并在xml中定义的参数将无法再解析

举例说明:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
...
  <properties>
    <frontEnd.url>http://site.com</frontEnd.url>
    <admin.email>admin@site.com</admin.email>
  </properties>

  <components>
    ...
    <component id="ServicesBootstrapperAction"
   service="SomeNS.Startup.IBootstrapperAction"
        type="SomeNS.Service.ServicesBootstrapperAction, Project-Service"
        >
      <parameters>
        <frontEndUrl>#{frontEnd.url}</frontEndUrl>
        <adminEmail>#{admin.email}</adminEmail>
        <prohibitedLogins>Assets/prohibited-logins.txt</prohibitedLogins>
      </parameters>
    </component>
    ...
  </components>
</configuration>
尝试解决此组件后,我们得到:

'SomeNS.Service.ServicesBootstrapperAction' is waiting for the following dependencies:
- Parameter 'frontEndUrl' which was not provided. Did you forget to set the dependency?
- Parameter 'adminEmail' which was not provided. Did you forget to set the dependency?
- Parameter 'prohibitedLogins' which was not provided. Did you forget to set the dependency?
同样,这是一个在2.5中完美运行的东西,所以我想这可能是一些未记录的(或者我们没有理解/没有理解)破坏性的变化

鉴别诊断,有人吗

更新: 我解决了问题,找到了解决办法。我不喜欢,但它很管用

对于所有好奇的人,以下是说明问题的项目链接:


请随时告诉我我错了,我应该使用其他漂亮的解决方案(什么?)。

尝试从节点名称中去掉句点。这不要紧,但这是我唯一能看到的潜在问题(主要是因为,除了XAML之外,我还没有看到在XML节点名称中使用太多句点)。

我认为解决这个问题是公平的,因为我已经找到了解决原始问题的方法

我真正的问题是一个接口有几个实现(并且需要全部实现)。但是,一些实现需要参数(简单值),这些参数自然地被移动到xml配置文件中,而其他实现则使用代码中的约定进行注册

现在,为了避免双重注册,我使用了3.0之前的.except(container.Kernel.HasComponent),它现在被认为已经过时了,但是编译得很好

令人惊讶的是,.except(t=>container.Kernel.HasComponent(t.Name))和以前一样工作得很好

我相信这是可以解释的,但我想不出任何解释


我真的很喜欢城堡,也很喜欢使用它。但45 kb的破坏性更改并不酷,抱歉,伙计们。

我也考虑过,也尝试过这样做,但没有成功。你能创建一个独立的失败测试吗?@MauricioScheffer,我正打算这么做。但是我注意到有一段代码涉及.except(),它停止了工作,但仍然被允许。长话短说,有些服务注册了两次,在运行时选择了最后一个注册的实现。温莎允许这种行为,真是令人伤心。我还有168个测试要修复。然后我将回到ranting。Windsor使用第一个注册的服务,而不是最后一个,这并不令人难过,它是有用的,而且是经过设计的。不知何故,它在我们的案例中使用了最后一个服务(在使用api之前,我已经注册了xml)。但我很难过,除非()表现得像是过时的,但仍然是windsor api的一部分
'SomeNS.Service.ServicesBootstrapperAction' is waiting for the following dependencies:
- Parameter 'frontEndUrl' which was not provided. Did you forget to set the dependency?
- Parameter 'adminEmail' which was not provided. Did you forget to set the dependency?
- Parameter 'prohibitedLogins' which was not provided. Did you forget to set the dependency?