hadashiA / VContainer

The extra fast, minimum code size, GC-free DI (Dependency Injection) library running on Unity Game Engine.
https://vcontainer.hadashikick.jp
MIT License
1.88k stars 163 forks source link

[Critical] Container is null when trying to Resolve from the Start() of LifetimeScope in specific scenario #610

Open Watcher3056 opened 8 months ago

Watcher3056 commented 8 months ago

Simple reproducible project: https://drive.google.com/file/d/1UChz1CGHh5nDtnP7QhuOKodUUqAd9s_f/view?usp=sharing

Steps to reproduce:

What you see:

Error:

NullReferenceException: Object reference not set to an instance of an object
VContainer.IObjectResolverExtensions.Resolve[T] (VContainer.IObjectResolver resolver) (at Library/PackageCache/jp.hadashikick.vcontainer@af7bd4ecab/Runtime/IObjectResolverExtensions.cs:10)
Game.Source.LevelScope.Start () (at Assets/Scripts/LevelScope.cs:23)

UPD: This issue comes when we want to use RootScope for our scopes but at the same time selecting "Parent Scope" as "RootScope" when it should be just "None". Simply need to replace "None" with the "RootScope" VContainer-sdie to avoid misunderstandings.

Now to fix the issue user need just to select "None" as the "ParentScope" in order to use "RootScope" as a "ParentScope".