Jump to content

[DEPRECIATED] Stuck on "Loading Part Upgrades" bugfix


Gotmachine

Recommended Posts

THIS MOD IS DEPRECIATED AND THE KSP ISSUE IT TARGETED WAS FIXED IN KSP 1.12.3

Just update KSP to the latest version. Moreover, this mod conflicts with other mods using KSPHarmony, installing it will cause issues.

 

 

 

OP for reference :

This is a fix for the KSP 1.12.2 bug that cause the game to be stuck on Loading Part Upgrades on a modded install.

This bug happens when you have a duplicated *.dll file in you GameData folder/subfolders. In KSP 1.12, the code that is supposed to be handling that (perfectly normal, mod authors aren't doing anything wrong) situation is either :

  • Crashing with an ArgumentOutOfRangeException, causing the whole loading process to stop.
  • Silently removing random assemblies from the list of assemblies to be loaded, causing random issues.

If that is happening to you, you will see the following error near the beginning of your KSP.log file :

ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
	System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource)
	System.ThrowHelper.ThrowArgumentOutOfRangeException ()
	System.Collections.Generic.List`1[T].RemoveAt (System.Int32 index)
	AssemblyLoader.FlagDuplicatedPlugins ()

This also fix two other issues that have the same effect (but are less likely to happen, as most mod authors have already implemented workarounds)

  • AssemblyLoader crashing on attempting to load a *.dll file with an absent or non-parseable FileVersion attribute : bugtracker issue
  • AssemblyLoader crashing when an unmanaged *.dll file exists : bugtracker issue

How to fix ?

  • Download the KSP1.12.2-StuckOnLoadingPartUpgradesFix.zip file from the GitHub releases page.
  • Extract that zip content to the root KSP folder (NOT GameData) :
    • On Windows, this is the folder containing the KSP_x64.exe file
    • On Linux, this is the folder containing the KSP.x86_64 file
    • On MacOS, this is the folder containing the KSP.app file
  • Done !

Details

See corresponding KSP bugtracker issue.

Note that there is a manual workaround to this bug : search your GameData and subfolders contents for *.dll files with the exact same name, and rename the duplicates to something like *.dll.duplicate (or just delete it).

However, this is quite unpractical, so while we wait for a proper fix in an hypothetical KSP 1.12.3 release, I've attempted to to provide an easier solution. Fixing this bug can't be done from a KSP plugin, since it cause the whole KSP plugin loader to crash before any plugin has a chance to execute.

So the fix is implemented through BepInEx, a popular Unity/XNA runtime patcher and plugin framework used for many games (Valheim, Outwards, WorldBox...).

Note to modders : workaround

If you are redistributing a *.dll file that is likely to be also redistributed by another mod, you can prevent the issue by renaming that *.dll to something unique. For example rename SomeLibrary.dll to SomeLibrary_MyMod.dll. Due to the fact that mono will only load a single instance of the same assembly by internal name, this is safe to do.

The only caveat is that there will be multiple LoadedAssembly entries in PluginLoader.loadedAssemblies for the same assembly, so keep that in mind in the very unlikely case you are iterating on it.

Common cases :

  • MiniAVC (depreciated and shouldn't be used)
  • KAS-API-v2.dll (Kerbal Attachement System API)
  • CLSInterfaces.dll (Connected Living Spaces API)
  • Unity Mono/.NET libraries missing from the KSP distribution, like System.IO.Compression.dll
  • Any nuget package

Changelog

  • V1.1 : Added fixes for AssemblyLoader crashes on dlls containing no FileVersion attribute, or non-managed dlls.
  • V1.0 : Initial release

Licensing

The provided download contains :

  • BepInEx 5.4.17 : LGPL-2.1 license
  • A BepInEx plugin (source) named AssemblyLoaderFixBepInEx.dll that patch the faulty KSP 1.12.2 method : MIT license
Edited by Gotmachine
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...