seesharper/LightInject — pull request #70 by nishmaster2k (2014-05-13 21:13:05+00:00)
Title: Singleton instance with broken dependency constructor will erroneously throw a cycle exception on the second resolution.

We noticed an issue when a dependency of one of our singleton instances was throwing an exception in its constructor. LightInject does not properly pop the emitter for that dependency off the stack, and since the instance still exists in the container, the emitter will be added more than once, causing a cycle exception to be thrown.

Technically, the called code is the piece that's failing, so not exactly LightInject's fault, but the case that's causing the exception in the constructor may be transient, but the container will not properly resolve it after this state is hit.

I'm not sure this is the best way to handle this, but this seemed relatively safe given the context. I've attached a test to demonstrate the issue.