ssannandeji / Zenject-2019

Dependency Injection Framework for Unity3D
MIT License
2.53k stars 366 forks source link

ZenjectException- Previous Binding or Multiple Creation Bindings #649

Open swustyc opened 4 years ago

swustyc commented 4 years ago

Env

Problem

1

If the code is:

Container.Bind<Foo>()->WithId("TestID").AsSingle();
Container.Bind<Foo>();

I will meet the ZenjectException: Assert hit! Scope must be set for the previous binding! Please either specify AsTransient, As Cached, or AsSingle.

2

If the code is:

Container.Bind<Foo>()->WithId("TestID").AsSingle();
Container.Bind<Foo>()->AsCached();

I will meet the ZenjectException: Assert hit! Found multiple creation bindings for type 'Foo' in addtion to AsSingle.

3

If the code is:

Container.Bind<Foo>()->WithId("TestID").AsSingle();
Container.Bind<Foo>()->AsTransient();

I will meet the ZenjectException: Assert hit! Found multiple creation bindings for type 'Foo' in addtion to AsSingle.