Closed Fube closed 1 year ago
@Fube You need to inject a value into the root container. The Inject()
functionality was strictly a workaround for frameworks like MassTransit at that time that needed to add specific services to a nested (scoped) container. What you're seeing is expected behavior, but also, the Inject() wasn't meant to be used quite like you're trying to do there.
Thank you for your response!
I ended up recreating the container for the tests that needed that kind of injection and injected the problematic service into the root container like you mentioned.
C# Version: 8.0 Target: .NET Core 3.1 Lamar version: 8.0.1
When marking something as injectable on a container then getting a nested container and injecting the implementation on that nested container and resolving a singleton dependent from said nested container, the injectable dependency is always null.
However:
Below is an example of a non-working configuration
I am uncertain if this is expected behavior or not. I am trying to use this in a testing scenario where I would like to inject some services at runtime.
Here is the repo of the above example: https://github.com/Fube/lamar_injectable_singleton_issue