question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove the Hacks where you access Chocolatey's SimpleInjector.Container

See original GitHub issue

Is 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 to GetInstance, etc.

Details

  1. Once the Container is loaded, you cannot add new things to it.
  2. ChocolateyService.GetSources() is one of the first things to run in the subprocess - note it makes a call to the Hacks file which accesses SimpleInjector.Container.
  3. 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.
  4. 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:closed
  • Created 6 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
ferventcodercommented, May 14, 2017
0reactions
RichiCoder1commented, May 14, 2017

Awesome!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[API] provide a way to see configuration · Issue #1267
Being about to return the config back would be helpful. ... Remove the Hacks where you access Chocolatey's SimpleInjector.Container ...
Read more >
Chocolatey GUI v0.15.0 released
Chocolatey GUI v0.15.0 released ... #440 NullRefEx on launch; #436 Remove the Hacks where you access Chocolatey's SimpleInjector.Container ...
Read more >
Remove registered decorator in Simple Injector
It's impossible to remove a registration in Simple Injector. You can replace an existing registration, but that method does not work when ...
Read more >
Using Simple Injector
An instance of Container is used to register mappings between each abstraction (service) and its corresponding implementation (component). Your application code ...
Read more >
Chocolatey 0.10.7
Chocolatey is software management automation for Windows that wraps installers, executables, zips, and scripts into compiled packages.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found