You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
This bug already exists since a while and also has been mentioned in modesttree#19.
When a binding is marked as AsSingle() it can not be unbound/rebound.
ZenjectException: Assert hit! Attempted to use AsSingle multiple times for type 'string'. As of Zenject 6+, AsSingle as can no longer be used for the same type across different bindings. See the upgrade guide for details.
Expected behavior
No exception should be thrown.
Extenject and Unity info (please complete the following information):
Zenject version: master
Unity version: 2021.3.8f1
Additional context
From what I have seen in the code it makes sense that this doesn't work. When a provider is registered it will call this at some point:
But when unbinding the provider will just be removed from the list, but types which were registered as singleton at some point are never removed from the _boundSingletons list.
The text was updated successfully, but these errors were encountered:
EDITED:
If you're having the same issue, replace .AsSingle() by .AsCached() and it will work just fine, as .AsCached() also works with a single instance.
Hello! Any update on this? We're having the exact same issue when doing:
I have the same problem, rebind doesn't work if I use rebind after awake. But it's working in InstallBindings before awake.
I didn't find a solution to this problem, so my plan just to change inject logic for components with rebind by logic without zenject.
Describe the bug
This bug already exists since a while and also has been mentioned in modesttree#19.
When a binding is marked as AsSingle() it can not be unbound/rebound.
To Reproduce
Expected behavior
No exception should be thrown.
Extenject and Unity info (please complete the following information):
Additional context
From what I have seen in the code it makes sense that this doesn't work. When a provider is registered it will call this at some point:
Extenject/UnityProject/Assets/Plugins/Zenject/Source/Runtime/Main/SingletonMarkRegistry.cs
Line 20 in 7ba9fcf
But when unbinding the provider will just be removed from the list, but types which were registered as singleton at some point are never removed from the
_boundSingletons
list.The text was updated successfully, but these errors were encountered: