unity-mod-manager icon indicating copy to clipboard operation
unity-mod-manager copied to clipboard

Mods that have more than one DLL do not load

Open AMacro opened this issue 1 year ago • 8 comments

When a mod loads a DLL from the mod directory, it does not appear to load and throws a `System.IO.FileNotFoundException: Could not load file or assembly '' exception.

For example, RuntimeUnityEditor has 2 DLLs 'RuntimeUnityEditor.UMM.dll' and 'RuntimeUnityEditor.Core.dll' - the RUE.UMM dll has a static reference to the RUE.Core dll.

When UMM attempts to load RUE, the error occurs and the following log is produced:

[Manager] Starting.
[Manager] Parsing mods.
[Manager] Reading file 'C:\Program Files (x86)\Steam\steamapps\common\Railroader\Mods\RuntimeUnityEditor\Info.json'.
[Manager] Sorting mods.
[Manager] Loading mods.
[RuntimeUnityEditor] Version '5.2.1.0'. Loading.
[RuntimeUnityEditor] [Error] Error loading file 'C:\Program Files (x86)\Steam\steamapps\common\Railroader\Mods\RuntimeUnityEditor\RuntimeUnityEditor.UMM.dll'.
[RuntimeUnityEditor] [Exception] ReflectionTypeLoadException - Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.
Could not load file or assembly 'RuntimeUnityEditor.Core, Version=5.2.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
Could not load file or assembly 'RuntimeUnityEditor.Core, Version=5.2.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
System.Reflection.ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.
Could not load file or assembly 'RuntimeUnityEditor.Core, Version=5.2.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
Could not load file or assembly 'RuntimeUnityEditor.Core, Version=5.2.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
  at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes(System.Reflection.Assembly,bool)
  at System.Reflection.Assembly.GetTypes () [0x00000] in <7e05db41a20b45108859fa03b97088d4>:0 
  at UnityModManagerNet.UnityModManager+ModEntry.Load () [0x00593] in <41afed0fd6f44664b4330828e6d4dd7c>:0 
System.IO.FileNotFoundException: Could not load file or assembly 'RuntimeUnityEditor.Core, Version=5.2.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
File name: 'RuntimeUnityEditor.Core, Version=5.2.1.0, Culture=neutral, PublicKeyToken=null'
System.IO.FileNotFoundException: Could not load file or assembly 'RuntimeUnityEditor.Core, Version=5.2.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
File name: 'RuntimeUnityEditor.Core, Version=5.2.1.0, Culture=neutral, PublicKeyToken=null'
[RuntimeUnityEditor] Loading time 0.09 s.
[Manager] FINISH. SUCCESSFUL LOADED 0/1 MODS.

In this instance, moving the Core dll into the game's 'managed folder' resolves the issue. Using ILRepack to merge the two dlls into a single dll also resolves the issue. Both "solutions" feel like hacks/bandaids rather than a real solution.

The same behaviour has been observed on one other mod that uses a multi-dll config.

I don't have any experience with dynamically loading assemblies, but I suspect the issue occurs when the dependencies are resolved, with the resolver looking to the wrong folder.

There might be a better way to fix this, but this StackOverflow answer looks like a starting point.

AMacro avatar Jan 23 '24 02:01 AMacro

For the net framework, this should be the default behavior of searching in the same directory. It works fine in other games. I need to dig.

newman55 avatar Jan 23 '24 09:01 newman55

Hi @newman55, was just testing this in Railroader. If using Doorstop proxy, it does search the mod directory, but if using the Assembly method, it does not.

Edit: This appears not to be case. I still need to copy the other DLL's to Managed folder when using Doorstop.

mricher-git avatar Feb 07 '24 05:02 mricher-git

@newman55 was trying to look into this to help out but I'm not sure what the issue is. When using same UMM version and mod version, Derail Valley happily opens extra DLL's in mod folder, but Railroader does not. In case you don't own RR, let me know if there's anything I can test on my end. Cheers.

mricher-git avatar Feb 08 '24 09:02 mricher-git

Fixed

newman55 avatar Mar 26 '24 07:03 newman55

the issue persists

t0stiman avatar Apr 01 '24 16:04 t0stiman

Give me a link to the mod so I can check it out

newman55 avatar Apr 01 '24 16:04 newman55

It's Runtime Unity Editor, can't find RuntimeUnityEditor.Core.dll and the associated MonoMod/Mono.Cecil, etc

Need to copy all .dll's except RuntimeUnityEditor.UMM.dll into game's Managed folder to make it run. For me, this is only happening in Railroader game, same UMM/RUE work fine in Derail Valley for example.

mricher-git avatar Apr 05 '24 09:04 mricher-git

With the latest fix, RuntimeUnityEditor in Railroader started working. Are there any other mods/games that don't work? Or is this problem persisting?

newman55 avatar Apr 05 '24 12:04 newman55