Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReflectionTypeLoadException when Harmony is missing #6

Open
drok opened this issue Mar 17, 2021 · 4 comments
Open

ReflectionTypeLoadException when Harmony is missing #6

drok opened this issue Mar 17, 2021 · 4 comments

Comments

@drok
Copy link

drok commented Mar 17, 2021

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
Copy link
Owner

Vectorial1024 commented Mar 19, 2021

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:

  • Auto-subscribe to CitiesHarmony, and resolve reference
  • If CitiesHarmony is loaded, resolve HarmonyLib reference

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

  • If CitiesHarmony is not loaded, display a dialog box and prompt subscription

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
Copy link
Owner

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
Copy link
Author

drok commented Mar 19, 2021

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
Copy link
Owner

Vectorial1024 commented Mar 20, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants