No Default Instance defined solved by doing less

StructureMap threw an exception after some refactoring

StructureMap Exception Code: 202 No Default Instance defined for PluginFamily IDoSomething

Solved by removing duplicates from assembly scan:

ObjectFactory.Initialize(c =>
{
    c.Scan(s =>
    {
        s.TheCallingAssembly();
        // Already loaded with TheCallingAssembly above
        // s.AssemblyContainingType<SomethingImplementation>();
        s.ConnectImplementationsToTypesClosing(typeof(IDoSomething));
    });
});

Turned out the IDoSomething was mapped to 2 implementations (of the same type) and StructureMap could not decide which was the default.

About erictummers

Working in a DevOps team is the best thing that happened to me. I like challenges and sharing the solutions with others. On my blog I’ll mostly post about my work, but expect an occasional home project, productivity tip and tooling review.
This entry was posted in Development and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.