Vectorial1024 / ExpressBusServices

Buses skip stops whenever possible.
https://steamcommunity.com/sharedfiles/filedetails/?id=2262054175
MIT License
9 stars 0 forks source link

ReflectionTypeLoadException when Harmony is missing #6

Open drok opened 3 years ago

drok commented 3 years ago

Hi Vectorial, I think I found a bug in this mod. The technical detail of why this happens is described at drok/Harmony-CitiesSkylines#9

It happens in corner cases like the user not having Harmony installed yet. See the issue post above for more scenarios in which it happens.

I found this by using my new Harmony mod, which sniffs out issues like this.

Loading D:\Users\Radu\AppData\Local\Colossal Order\Cities_Skylines\Addons\Mods\PopulationDemographics\CitiesHarmony.API.dll  [Mods - Internal]

Non platform assembly: data-0000000016098CC0 (this message is harmless)
Fallback handler could not load library q:/SteamLibrary/steamapps/common/Cities_Skylines/Cities_Data/Mono/data-0000000016098CC0.dll
Assembly CitiesHarmony.API, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null loaded.  [Mods - Internal]

Loading D:\Users\Radu\AppData\Local\Colossal Order\Cities_Skylines\Addons\Mods\PopulationDemographics\PopulationDemographics.dll  [Mods - Internal]

Non platform assembly: data-00000000160A3D00 (this message is harmless)
Fallback handler could not load library q:/SteamLibrary/steamapps/common/Cities_Skylines/Cities_Data/Mono/data-00000000160A3D00.dll
Assembly PopulationDemographics, Version=1.0.7746.31976, Culture=neutral, PublicKeyToken=null loaded.  [Mods - Internal]

Assembly resolution failure. No assembly named 'CitiesHarmony.Harmony, Version=2.0.4.0, Culture=neutral, PublicKeyToken=null' was found.  [Serialization]

ReflectionTypeLoadException: The classes in the module cannot be loaded.
  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
  at System.Reflection.Assembly.GetExportedTypes () [0x00000] in <filename unknown>:0 
  at ColossalFramework.Plugins.PluginManager+PluginInfo.AddAssembly (System.Reflection.Assembly asm) [0x00000] in <filename unknown>:0 
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
ColossalFramework.Plugins.PluginInfo:AddAssembly(Assembly)
ColossalFramework.Plugins.PluginManager:LoadDependenciesRecursive(Assembly, Dictionary`2, Dictionary`2, List`1)
ColossalFramework.Plugins.PluginManager:LoadDependencies(Dictionary`2, Dictionary`2)
ColossalFramework.Plugins.PluginManager:LoadAssemblies(Dictionary`2)
ColossalFramework.Plugins.PluginManager:LoadPlugins()
Starter:Awake()
Vectorial1024 commented 3 years ago

Hi there!

Yes, I am already aware of the TypeLoadExceptions when users have not yet installed Harmony before loading this mod. Such error is allowed here (or even allowed in my other Cities Skylines mods) because, as I utilized CitiesHarmony to get HarmonyLib in the past, CitiesHarmony did not offer any middle ground and I was unable to think of a good way of solving it.

CitiesHarmony's auto-self-subscription goes against my personal philosophy, and, knowing that they only offer these two options:

it was too much work trying to implement this, which is what I desired:

Still, I'm glad to hear about a new Harmony provider in CSL that may work better than CitiesHarmony. I will investigate that in detail some time later when I have more time for other things.

Leaving this open for now.

Vectorial1024 commented 3 years ago

Still, as some additional info, with me only interested in HarmonyLib and not the fancy compulsory wrapper libraries that came with it, all my CSL mods right now were built with the assumption that CitiesHarmony is the only provider of HarmonyLib, which is not necessarily sound now that we have an alternative Harmony provider.

drok commented 3 years ago

I understand your concern about auto-subscription, and have taken it as a feature request (drok/Harmony-CitiesSkylines#14) to provide an API method to get the Harmony ready callback without triggerring auto-subscription.

If you have other feature requests, please add them as issues on my Harmony Repo: https://github.com/drok/Harmony-CitiesSkylines/issues

Vectorial1024 commented 3 years ago

Thank you very much! I am looking forward to the release of your version of Harmony provider!

Edit: Apparently it is already released here lol, but still! Thank you very much! I'll look into it some time later.

https://steamcommunity.com/sharedfiles/filedetails/?id=2399343344