NeighTools / UnityDoorstop

Doorstop -- run C# before Unity does!
GNU Lesser General Public License v2.1
419 stars 62 forks source link

Doorstop does not work on Valheim #10

Closed BlueAmulet closed 3 years ago

BlueAmulet commented 3 years ago

Valheim is a 64bit Unity 2019.4.16 game. With Doorstop_x64_3.0.2.2, the game just crashes immediately With Doorstop_x64_3.1.0.0, the game starts, but the targetAssembly appears to not be running at all I have tested with BepInEx (with the newer 3.1.0.0 dll) and the example Doorstop.dll (moved to the game folder per the path in doorstop_config.ini), doorstop_is_alive.txt did not appear I have tested Doorstop as winhttp.dll and version.dll, neither worked Doorstop itself appears to work, setting redirectOutputLog=true does result in an output_log.txt, just not the targetAssembly

ghorsington commented 3 years ago

Greetings!

Doorstop and BepInEx are known to work with Valheim. The problem is that current builds of the game come with stripped mono base class library assemblies. In other words, some unused code was removed from game assemblies. In case of Valheim, many types used by BepInEx (and even example assembly in this repo) are stripped away which. Doorstop itself does its job fine.

At the moment, the fix is to restore the stripped assemblies by taking them directly from Unity Editor 2019.4.16.
I already did that as an example for Valheim:

unstripped_managed.7z

Simply extract this archive into Valheim_Data\Managed folder and overwrite when asked. After that BepInEx will indeed boot:

image


In general, I would suggest to contact the game developer and ask them to disable assembly stripping when building. Assembly stripping is not enabled by default in Unity which means that a developer for Valheim explicitly enabled it.

If you are a Unity game developer (or if you contact a developer for a Unity game): There are many reasons why assembly unstripping is not a good option for Unity games. Here is a list of them:

All in all, if you're a developer, please do not enable assembly unstripping in Unity. If you are unsure how, it is extremely easy to do in Player settings:

image


I will close this issue as it is confirmed not to be Doorstop one. I'll however also pin this one for other Valheim modders to see until the developer stop shipping their assemblies stripped.

opl- commented 3 years ago

It seems that the unstripped_managed.7z file you sent is missing some dlls from it that prevent using MonoMod with the game. In my case, as a Linux user, the missing dlls were System.Security.dll, System.Numerics.dll, and Mono.Posix.dll. Someone else running on Windows apparently has copied all files from Unity and didn't find System.Security.dll nor Mono.Posix.dll in there, so it's possible Windows uses slightly different dlls.

As I already have mono installed, I was able to find the aforementioned files under /usr/lib/mono/4.5/. I'm including them below for the convenience of anyone reading, but feel free to get them yourself from a source more trustworthy than a random stranger online. missing-unstripped-linux.zip

BlueAmulet commented 3 years ago

In the Windows Unity installation they're in 2019.4.16f1\Editor\Data\MonoBleedingEdge\lib\mono\4.5

ghorsington commented 3 years ago

It seems that the unstripped_managed.7z file you sent is missing some dlls from it that prevent using MonoMod with the game.

Thanks for the info. I updated the archive in the original message to include those missing DLLs.