2

I would like consumers of my nuget package to be able to inject an optional IConfiguration implementation. I'm using it along with Umbraco, so it's wired up automatically with Lightinject 5.4.

I've created a property with the optional config:

[Inject]
public IConfiguration OptionalInjectedConfiguration { get; set; }

The docs state:

Note:* LightInject considers all read/write properties a dependency, but implements a loose strategy around property dependencies, meaning that it will NOT* throw an exception in the case of an unresolved property dependency.

Yet it throws Unresolved dependency for the property. How should I pass this optional dependency?

dymanoid
  • 14,771
  • 4
  • 36
  • 64
Johan
  • 35,120
  • 54
  • 178
  • 293
  • I suppose, all properties annotated with the `[Inject]` attribute are required dependencies. The optional dependencies should be declared as settable properties without any annotations. – dymanoid Jul 28 '20 at 12:24
  • @dymanoid Yeah I tried that but it didn't get injected, let me double check... Yep it's null – Johan Jul 28 '20 at 12:25

0 Answers0