Remove the Hacks where you access Chocolatey's SimpleInjector.Container
See original GitHub issueIs there a chance we can remove this? https://github.com/chocolatey/ChocolateyGUI/blob/13d0d0f08d5b0eabc108a21f42337b8a7f05a76e/Source/ChocolateyGui.Subprocess/Hacks.cs#L47-L87
Took me awhile to discover this one - accessing internals from something else can lead to really hard to find bugs. Here’s a hint on the bug - https://github.com/chocolatey/choco/commit/61cd0847d4198828965626f32c4a3461bb4ee604
This fixes calls to
RegisterContainerComponents
complaining that components cannot be registered after calls toGetInstance
, etc.
Details
- Once the Container is loaded, you cannot add new things to it.
ChocolateyService.GetSources()
is one of the first things to run in the subprocess - note it makes a call to the Hacks file which accessesSimpleInjector.Container
.- Later,
Lets.GetChocolatey()
is called and then tries to load licensed code registration into the container, however it can’t because the container has already been accessed. - And then nothing works like you would expect it to.
Workaround
The fix I have for this now is to call Lets.GetChocolatey()
in Program.Main()
when the process is setting up so that everything gets registered properly prior to calling GetInstance
.
Fix
I may not fully be aware of the reasoning here, is there a reason this is being used over setting those items up in a container specifically for the GUI?
I spent more time that I want to admit wrestling with why I could not get the Licensed code to set up properly.
Other Thoughts
I did spend quite a bit of time making the lib code a bit more robust, so at least there is that.
I’ll be pushing back some PRs once I get all of this cleaned up.
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (12 by maintainers)
Top GitHub Comments
https://github.com/chocolatey/choco/issues/1294 and https://github.com/chocolatey/choco/issues/1267
Should remove most of the hacks code.
Awesome!