Dependency injection Spring.net ContextRegistry.GetContext因2个接口实现而失败

Dependency injection Spring.net ContextRegistry.GetContext因2个接口实现而失败,dependency-injection,spring.net,Dependency Injection,Spring.net,我有一个.net应用程序,它使用Spring.net。 还有一个接口的两种实现。应该使用哪一个-它基于配置文件 Spring的引导程序已启动 <objects> <object id="Impl1" name="Impl1" type="namespace.Impl1, IInterface" > </object> <object id="Impl2" name="Impl2" type="namespace.Impl2, IInterfac

我有一个
.net应用程序
,它使用Spring.net。 还有一个
接口的两种实现。应该使用哪一个-它基于
配置文件

Spring的
引导程序已启动

<objects>
 <object id="Impl1" name="Impl1" type="namespace.Impl1, IInterface" >
  </object>
  <object id="Impl2" name="Impl2" type="namespace.Impl2, IInterface" >   
  </object>
</objects>
错误消息是:

类型的未处理异常 中出现“System.Configuration.ConfigurationErrorsException” Spring.Core.dll

附加信息:未满足的依赖关系通过 索引为2且类型为[namespace.IInterface]的构造函数参数:否 定义了类型为[namespace.IInterface]的唯一对象:应为 单个匹配对象,但找到2个: System.Collections.Specialized.OrderedDictionary


我找到了另一个配置,其中autowire设置设置为autodetect

<object id="workspaceExportService" type="namespace.Imp3, Namespace"
          autowire="autodetect" />

此类
Imp3
有一个带
IInterface
参数的构造函数。因此,它试图解决
IInterface
的实现,但找到了其中两个

作为解决方案,您可以向对象节点添加
lazy init=“true”
属性

<object id="workspaceExportService" type="namespace.Imp3, Namespace"
          autowire="autodetect" />