-
-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.NullReferenceException: Object reference not set to an instance of an object #642
Comments
@ericbrunner Hi here, Yes, the separated example/test is very much appreciated. Meanwhile I would suggest to try out the DryIoc v6.0.0-preview-07. |
thank you very much for your kind reply @dadhi :-) We will try the |
Hi @dadhi I tried to mimic our situation in a test: https://github.com/ericbrunner/DryIoCResolverExploration/blob/6dc9478bd20c22a6cb22dfebd0f3a3991da8ddf5/DryIoCResolverExploration/TestProject/UnitTest1.cs#L41 Sadly, I could not reproduce the exception I get at line: https://github.com/ericbrunner/DryIoCResolverExploration/blob/6dc9478bd20c22a6cb22dfebd0f3a3991da8ddf5/DryIoCResolverExploration/DashboardConnectors.Library/Connectors/Base/ApplianceModelDashboardConnector.cs#L26 Full Project is here: https://github.com/ericbrunner/DryIoCResolverExploration/tree/main I'll try some further tests to reproduce our situation but I allready informed the colleague to update to what you suggested. |
Colleague of mine tested with suggested version
for some reason it's using the |
Nice. Thanks for the testing. I will fix it and return back with the new version to try. |
@dadhi have you pushed a new version to nuget with this fix? I'm still getting this error with
|
Hmm. I will double check. |
Hi,
We are facing such exception when calling
containerResolver.Resolve<T>();
Its in a .NET MAUI App with target frameworks
<TargetFrameworks>net8.0;net8.0-android;net8.0-ios</TargetFrameworks>
and
DryIoC.dll
nuget version5.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 withActivator.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 thecontainerResolver.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
The text was updated successfully, but these errors were encountered: