-
-
Notifications
You must be signed in to change notification settings - Fork 127

Description
Hi,
We are facing such exception when calling containerResolver.Resolve<T>();
System.NullReferenceException: Object reference not set to an instance of an object.
at DryIoc.Interpreter.TryInterpretAndUnwrapContainerException(IResolverContext r, Expression expr, Object& result) in //src/DryIoc/Container.cs:line 3073
at DryIoc.Container.ResolveAndCache(Int32 serviceTypeHash, Type serviceType, IfUnresolved ifUnresolved) in //src/DryIoc/Container.cs:line 441
at DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType, IfUnresolved ifUnresolved) in //src/DryIoc/Container.cs:line 392
at DryIoc.Resolver.Resolve[OvenDashboardItem](IResolver resolver, IfUnresolved ifUnresolved) in //src/DryIoc/Container.cs:line 8602
Its in a .NET MAUI App with target frameworks
<TargetFrameworks>net8.0;net8.0-android;net8.0-ios</TargetFrameworks>
and DryIoC.dll
nuget version 5.4.3
We verified that e.g. the OvenDashboardItem
and all it's injected dependencies in .ctor
are properly registered in the container and the container is built without any error before we try to resolve that type. When we get that resolve exception we tried out to resolve all .ctor
arguments from the container resolver with success and could manually create an instance with Activator.CreateInstance(typeof(OvenDashboardItem), arg1, arg2, ...)
.
The code section with containerResolver.Resolve<T>();
is invoked by several threads (race condition ?!). To mitigate that issue we tried a static lock around the containerResolver.Resolve<T>();
and it works. Now no exception is thrown. But that's just a workaround.
I'll try to create a tiny sample, but TBH I guess it will not we that easy.
Do you have any advice what we can further try out?
Thanks,
Eric