在StructureMap 4中,为什么可能在NotSupportedException中使用lambda创建的默认实例?

时间:2016-01-29 16:38:42

标签: dependency-injection structuremap4

我正在迁移到StructureMap 4(特别是版本4.0.1.318)。

我有什么看起来像适当的对象注册:

For<ISomeInterface>().Use(() => GetConcreteInstance());
For<ISomeInterface>().MissingNamedInstanceIs.TheDefault();

For<ISomeOtherThing>().Add<OtherConcreteClass>()
    .Ctor<ISomeInterface>().IsNamedInstance("Special");

但是,如果没有配置ISomeInterface的“特殊”实例(通常会在另一个注册表中发生,如果需要发生),那么就不要回到默认实例(这是我期望的)一个调用像这样

[Container].GetAllInstances<ISomeOtherThing>();

会产生以下结果:System.NotSupportedException: Instance's of type 'StructureMap.Pipeline.DefaultInstance' does not support ToNamedClose() and cannot be used as a MissingInstance

我猜我的注册有问题......但是什么?

1 个答案:

答案 0 :(得分:0)

基于在结构地图的Gitter IM频道中与Jeremy Miller的对话,似乎这是当前实施中的疏忽,很快就会得到修复。

对于其他需要它的人,可以在https://github.com/structuremap/structuremap/issues/438

找到错误报告
相关问题