Skip to content

Il2CppSystem.Func<string> does not return a valid string #221

@idea149

Description

@idea149

Using the following code snippit results in a memory error.
Il2CppInterop Version = 1.5.0-ci.625+51abbdd5e95447d4450eb82bde1b77ecff3cea74
This seems to happen in both MelonLoader and BepInEx.

Func<string> fn_sys = () => { return "My Text"; };
Il2CppSystem.Func<string> fn_il2cpp = fn_sys;
string myStr = fn_il2cpp.Invoke();
LoggerInstance.Msg($"Invoked result: {myStr}");

Log

[12:04:07.136] [Il2CppInterop] Class::Init signatures have been exhausted, using a substitute!
[12:04:07.234] [Il2CppInterop] Registered mono type Il2CppInterop.Runtime.DelegateSupport+Il2CppToMonoDelegateReference in il2cpp domain
[12:04:07.262] [Il2CppInterop] Registered mono type MelonLoader.Support.MonoEnumeratorWrapper in il2cpp domain
[12:04:07.269] [Il2CppInterop] Registered mono type MelonLoader.Support.SM_Component in il2cpp domain
[12:04:07.275] Support Module Loaded: C:\Program Files (x86)\Steam\steamapps\common\Pipistrello and the Cursed Yoyo\MelonLoader\Dependencies\SupportModules\Il2Cpp.dll
Fatal error. Internal CLR error. (0x80131506)
   at System.Buffer._Memmove(Byte ByRef, Byte ByRef, UIntPtr)
   at System.String.Ctor(Char*, Int32, Int32)
   at Il2CppInterop.Runtime.IL2CPP.Il2CppStringToManaged(IntPtr)
   at Il2CppInterop.Runtime.IL2CPP.PointerToValueGeneric[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](IntPtr, Boolean, Boolean)
   at Il2CppSystem.Func`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Invoke()
   at CustomMapSelector.Core.OnInitializeMelon()
   at MelonLoader.MelonBase.LoaderInitialized()
   at MelonLoader.MelonEvent+<>c.<Invoke>b__1_0(MelonLoader.LemonAction)
   at MelonLoader.MelonEventBase`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Invoke(System.Action`1<System.__Canon>)
   at MelonLoader.MelonEvent.Invoke()
   at MelonLoader.Core.Start()
   at MelonLoader.InternalUtils.BootstrapInterop.Start()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions