Exception for resolving a graph with unsatisfied dependencies
16 views
Skip to first unread message
Ervin Nagy
unread,
Apr 5, 2025, 7:14:49 AMApr 5
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Spring4D
Is it possible to raise an exception at Resolve if some dependencies are not registered?
Stefan Glienke
unread,
Apr 5, 2025, 7:18:34 AMApr 5
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Spring4D
It already does - the case you probably face is that it falls back to another ctor that it can satisfy - often that is the default ctor.
If you don't want the container to fall back to a ctor of a base class then add the extension from Spring.Container.ActivatorExtension.pas to the container. This changes the way the container looks for eligible ctors.
The second way you can force a ctor to be taken is to annotate it with the [Inject] attribute. Then the container will look no further and raises if it cannot satisfy all its parameters.