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

The test code works in C# console app,but not in Unity #70

Open
Ribosome2 opened this issue Mar 31, 2023 · 1 comment
Open

The test code works in C# console app,but not in Unity #70

Ribosome2 opened this issue Mar 31, 2023 · 1 comment

Comments

@Ribosome2
Copy link

image
first I put the dlls in Unity's plugin folder:

And then I copy paste the code in C# console app
image

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()

@bbsuuo
Copy link

bbsuuo commented May 30, 2023

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.

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