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

Abstract System.Type not being found after being directly or indirectly referenced. #81

Closed
Lionmeow opened this issue Mar 2, 2023 · 2 comments
Labels
bug Something isn't working injection
Milestone

Comments

@Lionmeow
Copy link

Lionmeow commented Mar 2, 2023

I've been working on a MelonLoader plugin for the game Slime Rancher 2. The game uses several abstract class for various behaviors like player movement, slime behavior, etc. Unhollower was unable to handle inheriting from abstract classes, but if you inherited from a class that inherited from the abstract class, you could use some Harmony patches to get it to work like it's being inherited.

When switching from Unhollower to Interop, this stopped working. Both directly inheriting from abstract classes as well as any offshoots of them are causing an error.
Offshoot:

System.NullReferenceException: Couldn't find System.Type for Il2Cpp type: SlimeSubbehaviour, Assembly-CSharp
   at Il2CppInterop.Runtime.Injection.ClassInjector.SystemTypeFromIl2CppType(Il2CppTypeStruct* typePointer) in /home/runner/work/Il2CppInterop/Il2CppInterop/Il2CppInterop.Runtime/Injection/ClassInjector.cs:line 1068
   at Il2CppInterop.Runtime.Injection.ClassInjector.RegisterTypeInIl2Cpp(Type type, RegisterTypeOptions options) in /home/runner/work/Il2CppInterop/Il2CppInterop/Il2CppInterop.Runtime/Injection/ClassInjector.cs:line 408
   at Il2CppInterop.Runtime.Injection.ClassInjector.RegisterTypeInIl2Cpp(Type type) in /home/runner/work/Il2CppInterop/Il2CppInterop/Il2CppInterop.Runtime/Injection/ClassInjector.cs:line 147
   at Il2CppInterop.Runtime.Injection.ClassInjector.RegisterTypeInIl2Cpp[T]() in /home/runner/work/Il2CppInterop/Il2CppInterop/Il2CppInterop.Runtime/Injection/ClassInjector.cs:line 142
   at MelonSRML.EntryPoint.OnInitializeMelon()
   at MelonLoader.MelonBase.LoaderInitialized() in D:\a\MelonLoader\MelonLoader\MelonLoader\Melons\MelonBase.cs:line 435

Directly:

System.ArgumentNullException: Value cannot be null. (Parameter 'name')
   at System.Type.GetMethod(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
   at Il2CppInterop.Runtime.Injection.ClassInjector.RegisterTypeInIl2Cpp(Type type, RegisterTypeOptions options) in /home/runner/work/Il2CppInterop/Il2CppInterop/Il2CppInterop.Runtime/Injection/ClassInjector.cs:line 406
   at Il2CppInterop.Runtime.Injection.ClassInjector.RegisterTypeInIl2Cpp(Type type) in /home/runner/work/Il2CppInterop/Il2CppInterop/Il2CppInterop.Runtime/Injection/ClassInjector.cs:line 147
   at Il2CppInterop.Runtime.Injection.ClassInjector.RegisterTypeInIl2Cpp[T]() in /home/runner/work/Il2CppInterop/Il2CppInterop/Il2CppInterop.Runtime/Injection/ClassInjector.cs:line 142
   at sr2melon.EntryPoint.OnGameContext(GameContext gameContext)
   at MelonSRML.Patches.GameContextModEventPatch.Prefix(GameContext __instance)

(SlimeSubbehaviour being an abstract class)
In simpler terms, vanilla class X inherits from abstract vanilla class Y. With Unhollower, while modded class Z couldn't inherit from Y, it could inherit from X. This could be used to make a sort of pseudo-inheritance via Harmony. However, in Interop, the above error throws when Z inherits from either X or Y.

I'm unsure if this is a bug with Interop, or simply a limitation that didn't exist in Unhollower. However, due to inheriting from offshoots working in Unhollower, I'd assume that it's the former.

@karaok1
Copy link

karaok1 commented Feb 20, 2024

Have you been able to solve this? I have been facing a similar issue...

@ds5678
Copy link
Collaborator

ds5678 commented Jul 15, 2024

Sounds like #135

@ds5678 ds5678 added bug Something isn't working injection labels Jul 15, 2024
@ds5678 ds5678 closed this as completed Jul 15, 2024
@ds5678 ds5678 added this to the 1.5.0 milestone Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working injection
Projects
None yet
Development

No branches or pull requests

3 participants