How can I determine if StructureMap has loaded the

2019-04-15 10:25发布

问题:

We are diagnosing an issue which seems to be related to StructureMap and a Registry. A large application of ours is loading a registry, but is experiencing some interesting side-effects.

Without going into all the details, we are seeing issues which we can reproduce by adding the same registry to StructureMap twice. Our assumption is that our application is doing the same, perhaps adding one instance as part of a scan and a second as an explicit registration.

How can I determine if StructureMap has loaded multiple/duplicate instances of this registry?

回答1:

I would run:

container.WhatDoIHave();

and check its output. If you see multiple registrations for object then you know you have a problem.

Alternatively add logging code to the registry to see if its being called multiple times.