And I got this error:
System.TypeInitializationException: An exception was thrown by the type initializer for HarmonyLib.AccessTools ---> System.TypeInitializationException: An exception was thrown by the type initializer for MonoMod.Utils.DynamicMethodDefinition ---> System.TypeInitializationException: An exception was thrown by the type initializer for MonoMod.Utils.ReflectionHelper ---> System.NullReferenceException: Object reference not set to an instance of an object
at MonoMod.Utils.ReflectionHelper..cctor () [0x00000] in :0
--- End of inner exception stack trace ---
at MonoMod.Utils.DynamicMethodDefinition..cctor () [0x00000] in :0
--- End of inner exception stack trace ---
at HarmonyLib.MethodInvoker.GetHandler (System.Reflection.MethodInfo methodInfo, Boolean directBoxValueAccess) [0x00000] in :0
at HarmonyLib.AccessTools..cctor () [0x00000] in :0
--- End of inner exception stack trace ---
at HarmonyLib.Internal.RuntimeFixes.StackTraceFixes.Install () [0x00000] in :0
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes()
It is caused by inconsistent target frameworks. It seems like you are using a target framework that is not supported by Unity. When developing plugins, it is advisable to use .NET 3.5 as the target framework.
first I put the dlls in Unity's plugin folder:
And then I copy paste the code in C# console app
And I got this error: System.TypeInitializationException: An exception was thrown by the type initializer for HarmonyLib.AccessTools ---> System.TypeInitializationException: An exception was thrown by the type initializer for MonoMod.Utils.DynamicMethodDefinition ---> System.TypeInitializationException: An exception was thrown by the type initializer for MonoMod.Utils.ReflectionHelper ---> System.NullReferenceException: Object reference not set to an instance of an object at MonoMod.Utils.ReflectionHelper..cctor () [0x00000] in:0
--- End of inner exception stack trace ---
at MonoMod.Utils.DynamicMethodDefinition..cctor () [0x00000] in :0
--- End of inner exception stack trace ---
at HarmonyLib.MethodInvoker.GetHandler (System.Reflection.MethodInfo methodInfo, Boolean directBoxValueAccess) [0x00000] in :0
at HarmonyLib.AccessTools..cctor () [0x00000] in :0
--- End of inner exception stack trace ---
at HarmonyLib.Internal.RuntimeFixes.StackTraceFixes.Install () [0x00000] in :0
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes()