Dependency injection 在StructureMap 4中,为什么使用lambda创建的默认实例会导致NotSupportedException?
我正在迁移到StructureMap 4(特别是版本4.0.1.318) 在我看来,我有适当的对象注册:Dependency injection 在StructureMap 4中,为什么使用lambda创建的默认实例会导致NotSupportedException?,dependency-injection,structuremap4,Dependency Injection,Structuremap4,我正在迁移到StructureMap 4(特别是版本4.0.1.318) 在我看来,我有适当的对象注册: For<ISomeInterface>().Use(() => GetConcreteInstance()); For<ISomeInterface>().MissingNamedInstanceIs.TheDefault(); For<ISomeOtherThing>().Add<OtherConcreteClass>() .
For<ISomeInterface>().Use(() => GetConcreteInstance());
For<ISomeInterface>().MissingNamedInstanceIs.TheDefault();
For<ISomeOtherThing>().Add<OtherConcreteClass>()
.Ctor<ISomeInterface>().IsNamedInstance("Special");
For()。使用(()=>GetConcreteInstance());
For().MissingNamedInstanceIs.TheDefault();
For().Add()
.Ctor().IsNamedInstance(“特殊”);
但是,如果没有配置ISomeInterface的“特殊”实例(如果需要,通常会出现在另一个注册表中),则不必返回到默认实例(这是我所期望的),而是进行如下调用
[Container].GetAllInstances<ISomeOtherThing>();
[Container].GetAllInstances();
结果如下:System.NotSupportedException:“StructureMap.Pipeline.DefaultInstance”类型的实例不支持ToNamedClose(),不能用作MissingInstance
我猜我的注册有问题。。。但是什么呢?根据与Jeremy Miller在StructureMap的Gitter IM频道中的对话,这似乎是当前实现中的一个疏忽,可能很快就会得到修复 对于任何其他需要它的人,可以在