Closed TonyValenti closed 9 months ago
Both
ResolveOptional()
andTryResolve()
revolve around the conditional nature of a specific service being registered. If the service is registered, resolution will be attempted. If resolution fails (e.g., due to lack of a dependency being registered), you will still get a DependencyResolutionException. If you need conditional resolution around a service where the condition is based on whether or not the service can successfully resolve, wrap theResolve()
call with a try/catch block.
Describe the Bug
Maybe my expectaions are wrong, but I expect
TryResolve
to return false and never throw.Scope.TryResolve(Type, out var Instance)
will throw an exception if the type has a required property that is not fulfilled.Expected Behavior
It should not throw.
Dependency Versions
I'm using the latest version of AutoFac.