I’m using StructureMap 2.6.1
This is the code from Bootstrapper.cs:
ObjectFactory.Initialize(x => x.For<IFoo>().Use<Foo>());
When I run application, I get the following exception:
No Default Instance defined for
PluginFamily
IFoo,
Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
I don’t get an exception when I use this obsolete code:
ForRequestedType<IFoo>()
.TheDefault.Is.OfConcreteType<Foo>();
Can anyone tell me the latest syntax for ObjectFactory’s initializer?
Thank you.
Each time you call Initialize, you’re resetting the ObjectFactory. I.e. in the following scenario:
You’ve only actually mapped out
IBaztoBaz.You should use an ApplicationRegistry instead:
And use that in your Initialize method: