STEAM GROUP
Harmony for Games HarmonyLib
STEAM GROUP
Harmony for Games HarmonyLib
4
IN-GAME
16
ONLINE
Founded
22 March, 2021
All Discussions > Cities Skylines > Topic Details
YuLun 30 May, 2021 @ 5:38pm
Better Road Toolbar mod & Harmony (re)
Better Road Toolbar mod would break harmony once subscribed, no matter it's enabled or not.

I haven't tested to load in other orders but I assume this is not relevant
Last edited by YuLun; 30 May, 2021 @ 5:38pm
Originally posted by Chaos:
Originally posted by Darth_Jimbo:
Originally posted by Chaos:

If I misunderstood what is happening, please add more detail. The only detail I have seen so far is YuLun's description "mod would break harmony once subscribed", and a couple of complaints on the mods own comments thread.

This is a brand new mod and it hasn't been completely birthed quite yet.

Okay, trying to update you with some more information.
I'm experiencing the following situation:
1. Better Road Toolbar and Harmony redesigned:
Harmony breaks. It shows as "FAILURE" in content manager. There's no report button anymore.
The toolbar is loaded and works, though, but other mods which need harmony stop working (in my case the Moving Bridges Mod, maybe others too)
2. Better Road Toolbar and Boformers Harmony:
Everything seems to work fine.

In both cases, load order is enforced by installing Harmony locally.
I can provide output_log later some time

Aha! Thank you for this more clear description. The problem is that Better Road Toolbar includes the file "CitiesHarmony.Harmony.dll" and it should not, since this is the Harmony library and is supplied by either of the two harmony mods.

The fix

Delete the file:

steamapps\workshop\content\255710\2502526929\CitiesHarmony.Harmony.dll

Explanation
This file overrides "2399343344\CitiesHarmony.Harmony.dll" and "2040656402\CitiesHarmony.Harmony.dll" distributed by the harmonies.

Since the file 2502526929\CitiesHarmony.Harmony.dll is identical to 2040656402\CitiesHarmony.Harmony.dll, there is apparently no conflict.

Since the file 2502526929\CitiesHarmony.Harmony.dll is different from 2399343344\CitiesHarmony.Harmony.dll, the breakage is apparent.

It also breaks Felix's, but latently - ie, the breakage will only be noticed in the future, should Felix update his Harmony. At that time, this mod will also break all mods that require any Harmony, since the game will load the mod's copy of 2502526929\CitiesHarmony.Harmony.dll rather than the updated 2040656402\CitiesHarmony.Harmony.dll

Further improvements
I have made a note that in this case, the Harmony Report does not indicate a clear diagnosis, and I will improve the next version to detect and attribute the breakage to the appropriate mod. (track here: https://github.com/drok/Harmony-CitiesSkylines/issues/17)
< >
Showing 1-9 of 9 comments
Chaos 30 May, 2021 @ 6:53pm 
I see that this is a brand new mod. Several comments on its item page report crashes, and there is one particularly telling report (note TypeLoadException):

A Mod caused an error [System.Exception]

Details:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException: Could not load type 'CitiesHarmony.API.HarmonyHelper' from assembly 'BetterRoadToolbar'.
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception

This report looks to me like a smoking gun, telling that the mod suffers from the documented issue CitiesHarmony.API misuse[github.com] (issue #8 on Harmony Redesigned tracker) and/or HarmonyLib public types[github.com] (issue #9 on Harmony Redesigned tracker)

Will this mod load if subscribed after Harmony Redesigned? Ie, would it benefit from the same workaround as the other mod on the Known Issues post? It certainly look like it belongs on the "Affected Mods" list in that post.

These two issues, logged and tracked as #8 and #9 are the most common problems plagueing mods that use Harmony, and they happen because the old harmony documentation, which most mod authors use, is quite poorly written.

Thank you for the report, and I'd appreciate your feedback.
Chaos 30 May, 2021 @ 7:06pm 
Additionally, in the log file posted on the Better Road Toolbar comments by Zephylr, I see another exception caused by that mod:
FormatException: Input string was not in the correct format
at int.Parse (string) <0x00061>
at BetterRoadToolbar.SpawnButtonEntryPatch.Postfix (ColossalFramework.UI.UITabstrip,string,string,bool,string,string,string,bool,bool,ColossalFramework.UI.UIButton&) <0x00105>
at (wrapper dynamic-method) GeneratedGroupPanel.GeneratedGroupPanel.SpawnButtonEntry_Patch1 (GeneratedGroupPanel,ColossalFramework.UI.UITabstrip,string,string,bool,string,string,string,bool,bool) <0x006fa>
at GeneratedGroupPanel.CreateGroupItem (GeneratedGroupPanel/GroupInfo,string) <0x000fb>
at GeneratedGroupPanel.PopulateGroups (GeneratedGroupPanel/GroupFilter,System.Comparison`1<GeneratedGroupPanel/GroupInfo>) <0x0008e>
at GeneratedGroupPanel.RefreshPanel () <0x0009a>
at MainToolbar.SpawnSubEntry (ColossalFramework.UI.UITabstrip,string,string,string,string,bool) <0x003d5>
at GameMainToolbar.RefreshPanel () <0x0074b>
at MainToolbar.OnLevelLoaded (SimulationManager/UpdateMode) <0x0001b>
at (wrapper delegate-invoke) LoadingManager/LevelLoadedHandler.invoke_void__this___SimulationManager/UpdateMode (SimulationManager/UpdateMode) <0x0004f>
at (wrapper delegate-invoke) LoadingManager/LevelLoadedHandler.invoke_void__this___SimulationManager/UpdateMode (SimulationManager/UpdateMode) <0x00083>
at (wrapper delegate-invoke) LoadingManager/LevelLoadedHandler.invoke_void__this___SimulationManager/UpdateMode (SimulationManager/UpdateMode) <0x00083>
at (wrapper delegate-invoke) LoadingManager/LevelLoadedHandler.invoke_void__this___SimulationManager/UpdateMode (SimulationManager/UpdateMode) <0x00083>
at LoadingManager/<LoadLevelComplete>c__Iterator9.MoveNext () <0x000ac>
at LoadingManager.Update () <0x0010a>

This looks to me like the type of error an untested mod would throw when iit encounters unexpected input (which it should have expected).

Your Harmony Report probably contains some exception summaries for this mod that its author might find useful while debugging.

As I see it, this is just a new mod with new mod bugs.
Darth_Jimbo 31 May, 2021 @ 2:53am 
Originally posted by Chaos:

This looks to me like the type of error an untested mod would throw when iit encounters unexpected input (which it should have expected).

Your Harmony Report probably contains some exception summaries for this mod that its author might find useful while debugging.

As I see it, this is just a new mod with new mod bugs.

Stupid question, but what does this mean now?
Can you fix it? Do you fix it?
I'm afraid, that the mod author won't fix as long as it is working with Boformers harmony...
(Saying like: Use Boformers or f**k off!)
Chaos 31 May, 2021 @ 3:15am 
Originally posted by Darth_Jimbo:
Originally posted by Chaos:

This looks to me like the type of error an untested mod would throw when iit encounters unexpected input (which it should have expected).

Your Harmony Report probably contains some exception summaries for this mod that its author might find useful while debugging.

As I see it, this is just a new mod with new mod bugs.

Stupid question, but what does this mean now?
Can you fix it? Do you fix it?
I'm afraid, that the mod author won't fix as long as it is working with Boformers harmony...
(Saying like: Use Boformers or f**k off!)

If I understand the bugs correctly, none of them can be fixed by either myself or boformer, and occur equally with either harmony.

There are 2 bugs, or more.
  1. The "TypeLoadException" bug can be worked around by subbing this mod after Harmony Redesigned has already been subbed. It's not something I can fix, and it would happen with boformer's harmony too if the mod was subbed before boformer's.
  2. The "FormatException: Input string was not in the correct format" also happens while boformer's harmony is in use. However, this bug is independent of harmony, and it's just a straight-up bug. No harmony can fix it, only the author can fix it, and I have no doubt that he will; the mod would be trash without this bugfix.

If I misunderstood what is happening, please add more detail. The only detail I have seen so far is YuLun's description "mod would break harmony once subscribed", and a couple of complaints on the mods own comments thread.

This is a brand new mod and it hasn't been completely birthed quite yet.
Last edited by Chaos; 31 May, 2021 @ 3:19am
Chaos 31 May, 2021 @ 3:21am 
The info on this thread would help Delta 5-1 debug his mod quicker, if someone would point it out to him.
Darth_Jimbo 31 May, 2021 @ 5:37am 
Originally posted by Chaos:

If I misunderstood what is happening, please add more detail. The only detail I have seen so far is YuLun's description "mod would break harmony once subscribed", and a couple of complaints on the mods own comments thread.

This is a brand new mod and it hasn't been completely birthed quite yet.

Okay, trying to update you with some more information.
I'm experiencing the following situation:
1. Better Road Toolbar and Harmony redesigned:
Harmony breaks. It shows as "FAILURE" in content manager. There's no report button anymore.
The toolbar is loaded and works, though, but other mods which need harmony stop working (in my case the Moving Bridges Mod, maybe others too)
2. Better Road Toolbar and Boformers Harmony:
Everything seems to work fine.

In both cases, load order is enforced by installing Harmony locally.
I can provide output_log later some time
A moderator of this forum has indicated that this post answers the original topic.
Chaos 31 May, 2021 @ 2:43pm 
Originally posted by Darth_Jimbo:
Originally posted by Chaos:

If I misunderstood what is happening, please add more detail. The only detail I have seen so far is YuLun's description "mod would break harmony once subscribed", and a couple of complaints on the mods own comments thread.

This is a brand new mod and it hasn't been completely birthed quite yet.

Okay, trying to update you with some more information.
I'm experiencing the following situation:
1. Better Road Toolbar and Harmony redesigned:
Harmony breaks. It shows as "FAILURE" in content manager. There's no report button anymore.
The toolbar is loaded and works, though, but other mods which need harmony stop working (in my case the Moving Bridges Mod, maybe others too)
2. Better Road Toolbar and Boformers Harmony:
Everything seems to work fine.

In both cases, load order is enforced by installing Harmony locally.
I can provide output_log later some time

Aha! Thank you for this more clear description. The problem is that Better Road Toolbar includes the file "CitiesHarmony.Harmony.dll" and it should not, since this is the Harmony library and is supplied by either of the two harmony mods.

The fix

Delete the file:

steamapps\workshop\content\255710\2502526929\CitiesHarmony.Harmony.dll

Explanation
This file overrides "2399343344\CitiesHarmony.Harmony.dll" and "2040656402\CitiesHarmony.Harmony.dll" distributed by the harmonies.

Since the file 2502526929\CitiesHarmony.Harmony.dll is identical to 2040656402\CitiesHarmony.Harmony.dll, there is apparently no conflict.

Since the file 2502526929\CitiesHarmony.Harmony.dll is different from 2399343344\CitiesHarmony.Harmony.dll, the breakage is apparent.

It also breaks Felix's, but latently - ie, the breakage will only be noticed in the future, should Felix update his Harmony. At that time, this mod will also break all mods that require any Harmony, since the game will load the mod's copy of 2502526929\CitiesHarmony.Harmony.dll rather than the updated 2040656402\CitiesHarmony.Harmony.dll

Further improvements
I have made a note that in this case, the Harmony Report does not indicate a clear diagnosis, and I will improve the next version to detect and attribute the breakage to the appropriate mod. (track here: https://github.com/drok/Harmony-CitiesSkylines/issues/17)
Chaos 31 May, 2021 @ 3:14pm 
This also shows that load order can't be guaranteed by copying mods locally.

The game loads assembly files from wherever it's able to find them, preferring workshop versions where an assembly exists both locally and in the workshop.

After all assemblies are loaded into memory, each mod is "OnEnable()", ie, started in a defined order: built-in mods first (alphabetical), then local mods (alphabetical order), and finally workshop mods (subscription order).

It doesn't matter that local mods are "OnEnable()"'d first, if the wrong assembly files are used (ie, the workshop assemblies).

The whole mess works most of the time if none of the mods contain files with conflicting names. As soon as the first mod appears that brings a conflicting filename, the ecosystem starts failing. If the behaviour of the conflicting file is similar to that of the intended file, the failure might be subtle at first.

Harmony Redesigned checks that its loaded assemblies are positively the expected versions, and when it is loaded wrong, it detects this and fails unambiguosly, even flagging the failure in the description with capital "FAILURE" text, to prevent whatever the problem is, to linger and propagate.

While this "FAILURE" may be inconvenient to the early adopters of buggy mods, it helps clean up the malaise quicker, thus cleaning up the ecosystem for the benefit of the community.

The old harmony and also the game is oblivious to bugs, which is why much of the community must be bothered with endless, seemingly random, unexplained errors.
Madisonian 31 May, 2021 @ 8:44pm 
Thanks for the info, the inclusion of Harmony in Better Road Toolbar is what was causing RICO Revisited to detect a Harmony error and disable itself on load.
< >
Showing 1-9 of 9 comments
Per page: 1530 50

All Discussions > Cities Skylines > Topic Details