knah/Il2CppAssemblyUnhollower

System.ArgumentException: Base class UnityEngine.MonoBehaviour is value type and can't be inherited from

LelouBil opened this issue · 3 comments

I'm trying class injection but I keep having this error.

System.ArgumentException: Base class UnityEngine.MonoBehaviour is value type and can't be inherited from
  at UnhollowerRuntimeLib.ClassInjector.RegisterTypeInIl2Cpp[T] () [0x000c3] in <e23489bf60bd4989ae101f3462221c4c>:0
  at MyMods0c6c997e473c4c9fa6c7c23c8ef04755.Init.Setup () [0x00071] in <fca399b1c8814998958ecbbee0151af9>:0

What am I doing wrong ?
Class being injected

public class ModMain : UnityEngine.MonoBehaviour
    {
        
        private void OnEnable()
        {
            System.Console.WriteLine("enabled yes");
        }

        public ModMain(IntPtr pointer) : base(pointer)
        {
        }
    }

Injector code

UnityVersionHandler.Initialize(2019, 4, 9);
ClassInjector.RegisterTypeInIl2Cpp<ModMain>();
knah commented

This is caused by the same struct mismatch issues as #8 - while there is a PR for some of these (#9) I'll likely rewrite that part for a more flexible approach in general

okay thanks

knah commented

99a080d includes a rewrite of struct handling and fixes #8, so this one might be fixed be fixed in 0.4.10.0 aswell. In general, native struct handling is a bit more streamlined now, so PRs for other specific version support would be welcome.