chocolatey / ChocolateyGUI

A delicious GUI for Chocolatey
https://docs.chocolatey.org/en-us/chocolatey-gui/
Apache License 2.0
1.61k stars 249 forks source link

Unable to load Chocolatey GUI assembly. Type initiator exception 'ChocolateyGui.Common.Windows.Bootstrapper' #960

Closed JacekJagosz closed 1 year ago

JacekJagosz commented 1 year ago

What You Are Seeing?

When I launch Chocolatey GUI from start menu or powershell (admin), after an UAC prompt I see: obraz When I click ok, I the same prompt appears, and I need to close like 8 windows for it to disappear.

What is Expected?

GUI should just launch, or at least some more detailed error on the terminal.

How Did You Get This To Happen? (Steps to Reproduce)

  1. I run the Windows install script for https://github.com/black7375/Firefox-UI-Fix . I run it many times previously on other devices, but there I had choco already installed. Here on this fresh install I did it before manually installing choco.
  2. Tried installing chocolatey via the official way, it returned it is already installed
  3. Tried installing sdio not as an administrator, aborted, then did it as admin
  4. Installed chocolateygui, I never managed to launch it
  5. Tried choco upgrade chocolateygui -y --force and choco upgrade chocolatey -y --force, didn't work
  6. Checked AppData\Local\Chocolatey GUI is empty

System Details

Output Log

No output log when launching the GUI

corbob commented 1 year ago

@JacekJagosz Could you confirm if there are any logs at C:\ProgramData\Chocolatey GUI\Logs? And if there's a directory at C:\ProgramData\Chocolatey GUI\Config? If the Config directory doesn't exist, you could try creating it. I've noticed that if the Config directory isn't there it doesn't launch at least for the debugger, and never delved too far into what caused it at the time.

Another place to look for clues is the Event Viewer under Windows Logs > Application. You may see Error level entries from a Source of either Application Error, or .NET Runtime. In either entry it should state ChocolateyGui.exe or choco.exe as the cause.

JacekJagosz commented 1 year ago

In C:\ProgramData\Chocolatey GUI\ there is only Config folder, no Logs folder. The Config is empty. Fortunately there are logs in the event viewer: Chronologically:

Full Log Output

~~~xml Kod XML zdarzenia: 1026 0 2 0 0 0x80000000000000 2009 Application Czuwi-windows Aplikacja: chocolateygui.exe Wersja architektury: v4.0.30319 Opis: proces został przerwany z powodu nieobsłużonego wyjątku. Informacje o wyjątku: System.ArgumentNullException w Autofac.ResolutionExtensions.ResolveService(Autofac.IComponentContext, Autofac.Core.Service, System.Collections.Generic.IEnumerable`1<Autofac.Core.Parameter>) w Autofac.ResolutionExtensions.Resolve[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](Autofac.IComponentContext, System.Collections.Generic.IEnumerable`1<Autofac.Core.Parameter>) w ChocolateyGui.Common.Windows.Theming.ThemeAssist..cctor() Informacje o wyjątku: System.TypeInitializationException w System.Reflection.RuntimeAssembly.GetExportedTypes(System.Reflection.RuntimeAssembly, System.Runtime.CompilerServices.ObjectHandleOnStack) w System.Reflection.RuntimeAssembly.GetExportedTypes() w Caliburn.Micro.AssemblySourceCache+<>c.<.cctor>b__4_0(System.Reflection.Assembly) w Caliburn.Micro.BootstrapperBase+<>c__DisplayClass7_0.<Initialize>b__0(System.Reflection.Assembly) w System.Linq.Enumerable+<SelectManyIterator>d__17`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext() w Caliburn.Micro.EnumerableExtensions.Apply[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<System.__Canon>, System.Action`1<System.__Canon>) w Caliburn.Micro.AssemblySourceCache+<>c.<Install>b__3_0(System.Object, System.Collections.Specialized.NotifyCollectionChangedEventArgs) w System.Collections.ObjectModel.ObservableCollection`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs) w Caliburn.Micro.BindableCollection`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs) w Caliburn.Micro.BindableCollection`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].OnUIThread(System.Action) w Caliburn.Micro.BootstrapperBase.StartRuntime() w Caliburn.Micro.BootstrapperBase.Initialize() w ChocolateyGui.Common.Windows.Bootstrapper..ctor() Informacje o wyjątku: System.IO.FileLoadException w ChocolateyGui.Common.Windows.Bootstrapper..cctor() Informacje o wyjątku: System.TypeInitializationException w ChocolateyGui.App.Main(System.String[]) Kod XML zdarzenia: 1000 0 2 100 0 0x80000000000000 2010 Application Czuwi-windows chocolateygui.exe 1.1.0.0 631a5fe3 KERNELBASE.dll 10.0.22000.918 b42fa627 e0434352 000000000004474c 28c4 01d8d030f80a1e3f c:\program files (x86)\chocolatey gui\chocolateygui.exe C:\WINDOWS\System32\KERNELBASE.dll fef216ba-90a9-49aa-a597-60e21fa6ffec Kod XML zdarzenia: 1001 0 4 0 0 0x80000000000000 2011 Application Czuwi-windows 2077251535718161431 5 CLR20r3 Niedostępny 0 chocolateygui.exe 1.1.0.0 631a5fe3 Autofac 4.6.1.0 ad4fed58 d8 17 System.ArgumentNullException \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER.c0f3d964-cee5-4d82-9f65-f2f8f6eaaf90.tmp.dmp \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER.8d36ad44-590d-4044-9e2e-3cbfbf1d8651.tmp.WERInternalMetadata.xml \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER.db6f576d-f241-4fec-bb72-714f673b5a06.tmp.xml \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER.3c8531e0-fc83-4f8e-aa31-6292b0125f8b.tmp.csv \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER.1e47b88a-b7e6-423e-87e8-8efd54369c75.tmp.txt \\?\C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_chocolateygui.ex_4a26ca40ca7ba0ae3d4e356f8481e9c08498a657_fddac005_fe585e1c-d1a5-4a76-a110-c2e40c962875 0 fef216ba-90a9-49aa-a597-60e21fa6ffec 268435456 230a267bfb4fce343cd3e144179d9c17 0 ~~~

Any additional logs I could attach that could help? (I am a Linux guy, this is all dark magic to me)

corbob commented 1 year ago

@JacekJagosz thanks for including that. Part of me wants to suggest just completely removing Chocolatey GUI and trying a fresh install, but the other part wants to get to the bottom of the issue so we can get it fixed.

So, a happy medium:

  1. Check for these files: C:\ProgramData\Chocolatey GUI\Config\data.db (IIRC you said this directory existed, but was empty), C:\Users<User>\AppData\Local\Chocolatey GUI\data.db (IIRC same for this one), C:\Users<User>\AppData\Local\Chocolatey\ChocolateyGui.exe_StrongName_qgbusv5dfgkxx33orw4dqzgj3f5c3jne\0.19.0.0\user.config (This one may be in a different location... I suspect the version number to be 1.1.0, but the StrongName I believe should be the same).
  2. If any of them exist, please make a copy of them (noting exactly where they came from), and remove them from the original location.
  3. Then try running Chocolatey GUI again.

If this solves the issue, could you get us a copy of all of those files (off the top of my head, I'm not 100% sure on the contents of them, so maybe start with letting us know if this fixes the issue, and then we can work on getting the files in a private manner if needed).

If that doesn't work, then my suggestion would be the complete uninstall and reinstall, but that's not likely to provide us the details of what caused the issue 😦

JacekJagosz commented 1 year ago

This is really weird. C:\ProgramData\Chocolatey GUI\Config\ is empty, C:\Users<User>\AppData\Local\Chocolatey GUI\ is empty, and C:\Users<User>\AppData\Local\Chocolatey\ doesn't exist at all. I also tried choco upgrade chocolateygui -y --force and choco upgrade chocolatey -y --force to reinstall them, with no change. I would love to do a full clean reinstall if that would help

corbob commented 1 year ago

@JacekJagosz I would probably start with just a reinstall of Chocolatey GUI. The easiest way to do that would be with Chocolatey CLI: choco uninstall chocolateygui -y followed by choco install chocolateygui -y. This should uninstall it, then reinstall it.

If that doesn't work, then you're probably looking at a full uninstall of Chocolatey itself, which is a little more involved, and definitely not recommended if you have many packages installed.

I don't have the directions to do this in front of me, but from memory it is something along the lines of: rename C:\ProgramData\Chocolatey to C:\ProgramData\Chocolatey.bak and then re-run the installation from an elevated PowerShell window: Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

corbob commented 1 year ago

@JacekJagosz I was debugging a different issue, and I found some output that if you're still having an issue might actually help isolate it better than the logs we've already found. If you try to run chocolateyguicli it should also error, but in my experience it may give a more actionable error message.

JacekJagosz commented 1 year ago
Wyjątek nieobsłużony: System.IO.FileLoadException: Nie można załadować pliku lub zestawu 'chocolatey, Version=1.0.0.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb' lub jednej z jego zależności. Nieprzechwycony wyjątek podczas inicjowania typu. (Wyjątek od HRESULT: 0x80131534) ---> System.TypeInitializationException: Inicjator typów zgłosił wyjątek dla typu 'ChocolateyGuiCli.Bootstrapper'. ---> System.IO.FileLoadException: Nie można załadować pliku lub zestawu 'chocolatey, Version=1.0.0.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb' lub jednej z jego zależności. Nieprawidłowy wskaźnik. (Wyjątek od HRESULT: 0x80004003 (E_POINTER)) ---> System.NullReferenceException: Odwołanie do obiektu nie zostało ustawione na wystąpienie obiektu.
   w ChocolateyGuiCli.Program.<>c.<AddAssemblyResolver>b__2_0(Object sender, ResolveEventArgs args)
   w System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
   --- Koniec śladu stosu wyjątków wewnętrznych ---
   w ChocolateyGuiCli.Bootstrapper..cctor()
   --- Koniec śladu stosu wyjątków wewnętrznych ---
   w ChocolateyGuiCli.Bootstrapper.get_Logger()
   w ChocolateyGuiCli.Program.<>c.<AddAssemblyResolver>b__2_0(Object sender, ResolveEventArgs args)
   w System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
   --- Koniec śladu stosu wyjątków wewnętrznych ---
   w ChocolateyGuiCli.Runner.Run(String[] args)
   w ChocolateyGuiCli.Program.Main(String[] args)

Which would translate to:

Unhandled exception: System.IO.FileLoadException: Couldn't load file or toolkit 'chocolatey, Version=1.0.0.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb' or one of the dependencies. Unhandled exception during type initialisation. (Exception HRESULT: 0x80131534) ---> System.TypeInitializationException: Type initiator reported exception 'ChocolateyGuiCli.Bootstrapper'. ---> System.IO.FileLoadException: Couldn't load file or toolkit 'chocolatey, Version=1.0.0.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb' or one of its dependencies. Incorrect pointer. (Exception HRESULT: 0x80004003 (E_POINTER)) ---> System.NullReferenceException: Reference to object was not set for object appearance.
   w ChocolateyGuiCli.Program.<>c.<AddAssemblyResolver>b__2_0(Object sender, ResolveEventArgs args)
   w System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
   --- Koniec śladu stosu wyjątków wewnętrznych ---
   w ChocolateyGuiCli.Bootstrapper..cctor()
   --- Koniec śladu stosu wyjątków wewnętrznych ---
   w ChocolateyGuiCli.Bootstrapper.get_Logger()
   w ChocolateyGuiCli.Program.<>c.<AddAssemblyResolver>b__2_0(Object sender, ResolveEventArgs args)
   w System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
   --- Koniec śladu stosu wyjątków wewnętrznych ---
   w ChocolateyGuiCli.Runner.Run(String[] args)
   w ChocolateyGuiCli.Program.Main(String[] args)
corbob commented 1 year ago

🤔 That's interesting. I got a very similar error yesterday when working with a locally built Chocolatey. Could you run choco list -lo and advise what it reports?

JacekJagosz commented 1 year ago
Chocolatey v1.1.0
chocolatey 1.1.0
chocolatey-compatibility.extension 1.0.0
chocolatey-core.extension 1.4.0
chocolatey-dotnetfx.extension 1.0.1
chocolateygui 1.1.0
dotnetfx 4.8.0.20220524
git.commandline 2.11.0.20170203
git.portable 2.37.3
KB2919355 1.0.20160915
KB2919442 1.0.20160915
sdio 1.12.8.748
11 packages installed.
corbob commented 1 year ago

What environment variables do you have set? In particular, do you have a ChocolateyInstall and is it pointing to the Chocolatey location?

JacekJagosz commented 1 year ago

I don't have this variable, only those related to Chocolatey obraz

corbob commented 1 year ago

Try setting an environment variable called ChocolateyInstall to C:\ProgramData\chocolatey. You may need to reboot or log off and back in once it's set.

JacekJagosz commented 1 year ago

After setting it and rebooting I am still getting the same error with both ChocolateyGui and guicli

JacekJagosz commented 1 year ago

But in the end simply doing choco uninstall chocolateygui -y followed by choco install chocolateygui -y fixed it. So sorry for the whole mess, I have no idea why it didn't work in the first place, and why my reinstallation using different commands didn't fix it either. Oh, and the error log is interesting, it said the GUI wasn't installed?!

PS C:\Users\Jacek> choco uninstall chocolateygui -y
Chocolatey v1.1.0
Directory 'C:\ProgramData\chocolatey\lib' does not exist.
Uninstalling the following packages:
chocolateygui
chocolateygui is not installed. Cannot uninstall a non-existent package.

Chocolatey uninstalled 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - chocolateygui - chocolateygui is not installed. Cannot uninstall a non-existent package.

If a package uninstall is failing and/or you've already uninstalled the
 software outside of Chocolatey, you can attempt to run the command
 with `-n` to skip running a chocolateyUninstall script, additionally
 adding `--skip-autouninstaller` to skip an attempt to automatically
 remove system-installed software. Only the packaging files are removed
 and not things like software installed to Programs and Features.

If a package is failing because it is a dependency of another package
 or packages, then you may first need to consider if it needs to be
 removed as packages have dependencies for a reason. If
 you decide that you still want to remove it, head into
 `$env:ChocolateyInstall\lib` and find the package folder you want to
 be removed. Then delete the folder for the package. You should use
 this option only as a last resort.

PS C:\Users\Jacek> choco install chocolateygui -y
Chocolatey v1.1.0
Directory 'C:\ProgramData\chocolatey\lib' does not exist.
Installing the following packages:
chocolateygui
By installing, you accept licenses for the packages.
Progress: Downloading chocolatey 1.1.0... 100%
Progress: Downloading ChocolateyGUI 1.1.0... 100%

chocolatey v1.1.0
chocolatey package files install completed. Performing other installation steps.
Creating ChocolateyInstall as an environment variable (targeting 'Machine')
  Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
WARNING: It's very likely you will need to close and reopen your shell
  before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to 'C:\ProgramData\chocolatey\lib'
  (i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
  and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.

Creating Chocolatey folders if they do not already exist.

WARNING: You can safely ignore errors related to missing log files when
  upgrading from a version of Chocolatey less than 0.9.9.
  'Batch file could not be found' is also safe to ignore.
  'The system cannot find the file specified' - also safe.
PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding...
WARNING: Not setting tab completion: Profile file does not exist at 'C:\Users\Jacek\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'.
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
 first prior to using choco.
Environment Vars (like PATH) have changed. Close/reopen your shell to
 see the changes (or in powershell/cmd.exe just type `refreshenv`).
 The install of chocolatey was successful.
  Software install location not explicitly set, it could be in package or
  default install location of installer.

chocolatey-compatibility.extension v1.0.0 [Approved]
chocolatey-compatibility.extension package files install completed. Performing other installation steps.
 Installed/updated chocolatey-compatibility extensions.
 The install of chocolatey-compatibility.extension was successful.
  Software installed to 'C:\ProgramData\chocolatey\extensions\chocolatey-compatibility'

chocolatey-core.extension v1.4.0 [Approved]
chocolatey-core.extension package files install completed. Performing other installation steps.
 Installed/updated chocolatey-core extensions.
 The install of chocolatey-core.extension was successful.
  Software installed to 'C:\ProgramData\chocolatey\extensions\chocolatey-core'

chocolatey-dotnetfx.extension v1.0.1 [Approved]
chocolatey-dotnetfx.extension package files install completed. Performing other installation steps.
 Installed/updated chocolatey-dotnetfx extensions.
 The install of chocolatey-dotnetfx.extension was successful.
  Software installed to 'C:\ProgramData\chocolatey\extensions\chocolatey-dotnetfx'

KB2919442 v1.0.20160915 [Approved]
kb2919442 package files install completed. Performing other installation steps.
Skipping installation because this hotfix only applies to Windows 8.1 and Windows Server 2012 R2.
 The install of kb2919442 was successful.
  Software install location not explicitly set, it could be in package or
  default install location of installer.

KB2919355 v1.0.20160915 [Approved]
kb2919355 package files install completed. Performing other installation steps.
Skipping installation because this hotfix only applies to Windows 8.1 and Windows Server 2012 R2.
 The install of kb2919355 was successful.
  Software install location not explicitly set, it could be in package or
  default install location of installer.

dotnetfx v4.8.0.20220524 [Approved]
dotnetfx package files install completed. Performing other installation steps.
Microsoft .NET Framework 4.8 or later is already installed.
 The install of dotnetfx was successful.
  Software install location not explicitly set, it could be in package or
  default install location of installer.

ChocolateyGUI v1.1.0 [Approved]
chocolateygui package files install completed. Performing other installation steps.
Installing ChocolateyGUI...
ChocolateyGUI has been installed.
Added C:\ProgramData\chocolatey\bin\chocolateygui.exe shim pointed to 'c:\program files (x86)\chocolatey gui\chocolateygui.exe'.
Added C:\ProgramData\chocolatey\bin\chocolateyguicli.exe shim pointed to 'c:\program files (x86)\chocolatey gui\chocolateyguicli.exe'.
 The install of chocolateygui was successful.
  Software installed as 'msi', install location is likely default.

Chocolatey installed 8/8 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Installed:
 - kb2919355 v1.0.20160915
 - chocolatey-core.extension v1.4.0
 - dotnetfx v4.8.0.20220524
 - chocolatey v1.1.0
 - kb2919442 v1.0.20160915
 - chocolateygui v1.1.0
 - chocolatey-compatibility.extension v1.0.0
 - chocolatey-dotnetfx.extension v1.0.1
corbob commented 1 year ago

Thanks for the confirmation @JacekJagosz, it's unfortunate we weren't able to get to the root of the issue, but at least we got it solved.

RRDAWLX commented 1 year ago
  1. restart system
  2. install
  3. success
R4cOOn commented 1 year ago

Just wanted to add my twopence here: I landed on that page when I had the same issue.
A reinstall of chocolateygui dit nothing.

I forced a reinstall with choco install chocolatey --force and that fixed it.

I then noticed that the chocolateygui package version was 2.0.0.0 while the chocolatey package (before the force reinstall) was 1.3.1.
After the reinstall it matches the GUI version and everything works.

No idea what happened to make the main package go out of sync.

cecilyen commented 1 year ago

@R4cOOn You just saved my day. My problem went away after a forced reinstallation.

GsynthChris commented 1 year ago

I can also confirm that choco install chocolatey --force also fixed the same issue for me.

This is the second PC I had this happen on. All started after running Update all from Chocolateygui. Chocolatey gets updated, gui closes, wont launch again. even after trying to also update chocolateygui from chocolateycli.

piflixe commented 11 months ago

In my case, i could resolve the issue by upgrading chocolatey via the powershell command line. choco upgrade chocolatey

It seems I had chocolatey v2.0.0 installed. It was then upgrade to v2.1.0 and afterwards the gui would load without problems.

Maybe I upgraded the GUI before chocolatey and thereby broke dependencies?