Harmony
Harmony copied to clipboard
PatchFunctions.UpdateWrapper NotImplementedException on MacOS
This exception occurs when launching from Rider:
We don't have this problem on Windows or inside asp.net linux docker containers.
The exception occurs even when launching without debugging.
The patch code:
[HarmonyPatch(typeof(ClassName), "MethodName")]
[UsedImplicitly]
static class Patch
{
[UsedImplicitly]
[HarmonyPrefix]
static bool Prefix(ClassName __instance)
{
if (__instance.Property is AnotherClass { AnotherProperty: true })
return false;
return true;
}
}
Runtime environment (please complete the following information):
- OS: MacOS Ventura 13.3.1 (a)
- .NET version 7.0.402
- Harmony version 2.3.3 (thin)
Our host application is ASP.NET Web Api app.
Does this happen with the non-thin version too? If so, you are not supplying the correct dependencies.
For reference, I am as I type, using Harmony 2.3.3 on my MacBook Air M2 with RimWorld just fine.
The non-thin version doesn't work for us (exception when debugging from Rider on Windows). https://github.com/pardeike/Harmony/issues/585
What are the dependencies? The docs mentions that one may need to add them but what exactly to add?
If you use an IDE (like Visual Studio, don’t know about Rider, never used it) it will automatically download the dependencies. The nuget package also lists the dependencies as does a decompiler like dnSpy
These are nuget package dependencies:
<dependencies>
<group targetFramework=".NETFramework3.5">
<dependency id="MonoMod.Core" version="1.1.0" exclude="Build,Analyzers" />
</group>
<group targetFramework=".NETFramework4.5.2">
<dependency id="MonoMod.Core" version="1.1.0" exclude="Build,Analyzers" />
</group>
<group targetFramework=".NETFramework4.7.2">
<dependency id="MonoMod.Core" version="1.1.0" exclude="Build,Analyzers" />
</group>
<group targetFramework=".NETFramework4.8">
<dependency id="MonoMod.Core" version="1.1.0" exclude="Build,Analyzers" />
</group>
<group targetFramework=".NETCoreApp3.0">
<dependency id="MonoMod.Core" version="1.1.0" exclude="Build,Analyzers" />
</group>
<group targetFramework=".NETCoreApp3.1">
<dependency id="MonoMod.Core" version="1.1.0" exclude="Build,Analyzers" />
</group>
<group targetFramework="net5.0">
<dependency id="MonoMod.Core" version="1.1.0" exclude="Build,Analyzers" />
<dependency id="System.Text.Json" version="5.0.2" exclude="Build,Analyzers" />
</group>
<group targetFramework="net6.0">
<dependency id="MonoMod.Core" version="1.1.0" exclude="Build,Analyzers" />
<dependency id="System.Text.Json" version="6.0.9" exclude="Build,Analyzers" />
</group>
<group targetFramework="net7.0">
<dependency id="MonoMod.Core" version="1.1.0" exclude="Build,Analyzers" />
<dependency id="System.Text.Json" version="7.0.4" exclude="Build,Analyzers" />
</group>
<group targetFramework="net8.0">
<dependency id="MonoMod.Core" version="1.1.0" exclude="Build,Analyzers" />
<dependency id="System.Text.Json" version="8.0.1" exclude="Build,Analyzers" />
</group>
<group targetFramework=".NETStandard2.0">
<dependency id="Lib.Harmony.Ref" version="2.3.3" exclude="Build,Analyzers" />
<dependency id="MonoMod.Core" version="1.1.0" exclude="Build,Analyzers" />
</group>
</dependencies>
The assembly explorer shows more:
So for .NET 7 I need to manually add the nuget packages System.Text.Json and MonoMod.Core, correct?
We've found the cause of this exception. MonoMod doesn't support ARM architecture on MacOS. Is there something we can do to make it work there?
Contribute to the complex task of patching low level architecture in the MonoMod repository? Or simply use MacCatalyst for now?
Excuse me, what do you mean by using MacCatalyst? I'm not a Mac user so I'm not familiar with MacCatalyst, how it can help?
Do you know any Harmony-like library that supports MacOS ARM?
You missed my comment earlier: https://github.com/pardeike/Harmony/issues/607#issuecomment-2061115901
Perhaps RimWorld works because Unity uses its own fork of dotnet runtime based on Mono and it may also use something like rosetta emulation. I haven't found a way to do it with dotnet.
I close this issue as the real work has to be done in MonoMod (and is picking up a bit lately)