Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Upgrading the Unity.Container dependency will cause a NullReferenceException when starting up #108
All customers upgrading to Unity 5.10.x and higher
Upgrading Unity to a newer minor (e.g. v5.11.1 but not limited to this version) has broken the factory resolution. The current nuget range allows people to upgrade to this version and that will cause a NullReferenceException cascade at startup
Downgrade unity to previous versions
A customer reported that when they bumped up the Unity to 5.10.3 the following exception occurred:
We are experiencing the same issue with all versions back to at least Unity 5.9.7. We have been waiting in version 5.8.13 until all our third parties had fixed the breaking changes in Unity in their own dependencies. The same code but with the MS Dependecy Injection implementation works just fine.
We have already bumped all our packages to the latest versions of both Unity and NServiceBus, since we considered it solved and stable. And I would really prefer not to go through the process of rolling everything back.
Please keep us posted on any progress, if you need any input from us and if not able to solve the problem at least give us a hint regarding what could give this error.
Thanks in advance.
I have investigated the problem further and kept on trying to isolate the problem and making sure that the problem really is in your and not our code.
I have now and established that it most certainly is in your code and that the problem most likely lies in differences in what Endpoint.Create(endpointConfiguration), IStartableEnpoint.Start() in NServiceBus expects and what endpointConfiguration.UseContainer() hands them.
I have ruled everything specific to our code and the following test case reproduces the issue.
I would really appreciate some feedback on how things is progressing on your side and when we can expect a fix rolled out for this given that you can find what causes it.
Thanks in advance!
hi @gustavnyberg can you please let me know what NServiceBus.Unity version are you using while encountering errors with previous errors of Unity (pre 5.10.3)?
We are aware of this issue exist in NServiceBus.Unity 10.0.0 and Unity 5.10.3. The latest NServiceBus.Unity version should work for supported Unity packages lower than 5.10.3
I am using NServiceBus.Unity 10.0.0.
The problem is present at least as far back as Unity (5.9.7).
I have tried every version of Unity from 5.9.7 up to 5.10.3 and I am getting the same error.
Due to other chained dependencies I can't go back further than Unity 5.9.7.
But the last working version for us was Unity 5.8.13 which was before the first severe breaking change in Unity.
The same goes for NServiceBus.
Last working versions were:
@gustavnyberg thank you for your response. Unfortunately, I was unable to encounter errors on the version that you specified.
I copied the code from our Samples and changed the transport to ASB, feel free to try it out: https://github.com/WojcikMike/UnitySample
On my end the only combination of versions that it doesn't work for is NServiceBus.Unity 10.0.0
The reason why I got hung up on that is that what you say (that Unity throws an exception on every version from 5.9.7) is something new to us and I would like to verify this before moving forward with this issue.
The code requires connection string to ASB.
I have tried the samples you sent.
The .Net Framework project works.
The Core version does not build. You are missing two Nuget packages:
You also need to replace transport.UseForwardingTopology() since that extension method is a part of the NServiceBus.Azure.Transports.WindowsAzureServiceBus Nuget package, which seems to be missing a Core implementation.
I have made some alterations to fix the build errors in the Core project and been able to build it and once able to build and run it, it also works.
I have also tried running our test case and the sample projects and they are working too.
Unfortunately we haven't been able to wait for the feedback from you risking having a late release and last minute fixes.
So we have proceeded by replacing Unity with an in-house .Net Framework compatible implementation of Microsoft's .Net Core Dependency Injection Framework.
I have tried recreating the old conditions by reverting these changes, but I am not 100% sure I have managed to do so.
Anyway, now I am not able to reproduce the error for any other combinations than NServiceBus.Unity 10.0.0 and Unity.Container 5.10.3.
Since we have been able to completely replace Unity and since we no longer can reproduce the error I don't see that there is much left to do but to make the changes I suggested to your sample projects (which are very nice to have when troubleshooting) and maybe add a .Net Standard sample too, then close this particular issue and to fix it for NServiceBus.Unity 10.0.0 and Unity.Container 5.10.3.