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

MonoRT1: [...] cannot create a delegate on private/internal method [...] (). #3138

Closed
Keyinator opened this issue Feb 6, 2025 · 3 comments
Closed
Labels
bug crash ScRT: C# Issues/PRs related to either C# scripting runtimes

Comments

@Keyinator
Copy link
Contributor

Keyinator commented Feb 6, 2025

What happened?

For some reasons private/internal methods cannot be accessed anymore on MonoRT1 which used to work before.

Registering Tick failed: System.MethodAccessException: Transparent method CitizenFX.Core.BaseScript:InitializeOnAdd () cannot create a delegate on private/internal method GamboCityClient.AntiCheatModule:DelayedTicks ().
Full stacktrace
[     36047] [b3095_GTAProce]             MainThrd/ Registering Tick for attributed method DelayedTicks
[     36047] [b3095_GTAProce]             MainThrd/ Registering Tick failed: System.MethodAccessException: Transparent method CitizenFX.Core.BaseScript:InitializeOnAdd () cannot create a delegate on private/internal method GamboCityClient.AntiCheatModule:DelayedTicks ().
[     36047] [b3095_GTAProce]             MainThrd/   at (wrapper managed-to-native) System.Delegate:CreateDelegate_internal (System.Type,object,System.Reflection.MethodInfo,bool)
[     36047] [b3095_GTAProce]             MainThrd/   at System.Delegate.CreateDelegate (System.Type type, System.Object target, System.String method, System.Boolean ignoreCase, System.Boolean throwOnBindFailure) [0x0002b] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     36047] [b3095_GTAProce]             MainThrd/   at System.Delegate.CreateDelegate (System.Type type, System.Object target, System.String method, System.Boolean ignoreCase) [0x00000] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     36047] [b3095_GTAProce]             MainThrd/   at System.Delegate.CreateDelegate (System.Type type, System.Object target, System.String method) [0x00000] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     36047] [b3095_GTAProce]             MainThrd/   at CitizenFX.Core.BaseScript.InitializeOnAdd () [0x0008d] in C:\gl\builds\cfx-fivem-0\code\client\clrcore\BaseScript.cs:397 
[     36063] [b3095_GTAProce]             MainThrd/ Registering EventHandler onClientResourceStop for attributed method OnClientResourceStop, with parameters System.RuntimeType
[     36063] [b3095_GTAProce]             MainThrd/ Registering EventHandler failed: System.MethodAccessException: Transparent method CitizenFX.Core.BaseScript:InitializeOnAdd () cannot create a delegate on private/internal method GamboCityClient.AntiCheatModule:OnClientResourceStop (string).
[     36063] [b3095_GTAProce]             MainThrd/   at (wrapper managed-to-native) System.Delegate:CreateDelegate_internal (System.Type,object,System.Reflection.MethodInfo,bool)
[     36063] [b3095_GTAProce]             MainThrd/   at System.Delegate.CreateDelegate (System.Type type, System.Object target, System.String method, System.Boolean ignoreCase, System.Boolean throwOnBindFailure) [0x0002b] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     36063] [b3095_GTAProce]             MainThrd/   at System.Delegate.CreateDelegate (System.Type type, System.Object target, System.String method, System.Boolean ignoreCase) [0x00000] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     36063] [b3095_GTAProce]             MainThrd/   at System.Delegate.CreateDelegate (System.Type type, System.Object target, System.String method) [0x00000] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     36063] [b3095_GTAProce]             MainThrd/   at CitizenFX.Core.BaseScript.InitializeOnAdd () [0x001dd] in C:\gl\builds\cfx-fivem-0\code\client\clrcore\BaseScript.cs:421 
[     36063] [b3095_GTAProce]             MainThrd/ Loaded GamboCity Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null into ScriptDomain_1531160072
[     36078] [b3095_GTAProce]             MainThrd/ Instantiated instance of script GamboCityClient.BackgroundModule.
[     36078] [b3095_GTAProce]             MainThrd/ Registering Tick for attributed method MapTick
[     36078] [b3095_GTAProce]             MainThrd/ Registering Tick failed: System.MethodAccessException: Transparent method CitizenFX.Core.BaseScript:InitializeOnAdd () cannot create a delegate on private/internal method GamboCityClient.BackgroundModule:MapTick ().
[     36078] [b3095_GTAProce]             MainThrd/   at (wrapper managed-to-native) System.Delegate:CreateDelegate_internal (System.Type,object,System.Reflection.MethodInfo,bool)
[     36078] [b3095_GTAProce]             MainThrd/   at System.Delegate.CreateDelegate (System.Type type, System.Object target, System.String method, System.Boolean ignoreCase, System.Boolean throwOnBindFailure) [0x0002b] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     36078] [b3095_GTAProce]             MainThrd/   at System.Delegate.CreateDelegate (System.Type type, System.Object target, System.String method, System.Boolean ignoreCase) [0x00000] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     36078] [b3095_GTAProce]             MainThrd/   at System.Delegate.CreateDelegate (System.Type type, System.Object target, System.String method) [0x00000] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     36078] [b3095_GTAProce]             MainThrd/   at CitizenFX.Core.BaseScript.InitializeOnAdd () [0x0008d] in C:\gl\builds\cfx-fivem-0\code\client\clrcore\BaseScript.cs:397 
[     36078] [b3095_GTAProce]             MainThrd/ Registering EventHandler Keyinator:Background:MessageTooSoon for attributed method MessageTooSoon, with parameters System.RuntimeType
[     36078] [b3095_GTAProce]             MainThrd/ Registering EventHandler failed: System.MethodAccessException: Transparent method CitizenFX.Core.BaseScript:InitializeOnAdd () cannot create a delegate on private/internal method GamboCityClient.BackgroundModule:MessageTooSoon (int16).
[     36078] [b3095_GTAProce]             MainThrd/   at (wrapper managed-to-native) System.Delegate:CreateDelegate_internal (System.Type,object,System.Reflection.MethodInfo,bool)
[     36078] [b3095_GTAProce]             MainThrd/   at System.Delegate.CreateDelegate (System.Type type, System.Object target, System.String method, System.Boolean ignoreCase, System.Boolean throwOnBindFailure) [0x0002b] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     36094] [b3095_GTAProce]             MainThrd/   at System.Delegate.CreateDelegate (System.Type type, System.Object target, System.String method, System.Boolean ignoreCase) [0x00000] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     36094] [b3095_GTAProce]             MainThrd/   at System.Delegate.CreateDelegate (System.Type type, System.Object target, System.String method) [0x00000] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     36094] [b3095_GTAProce]             MainThrd/   at CitizenFX.Core.BaseScript.InitializeOnAdd () [0x001dd] in C:\gl\builds\cfx-fivem-0\code\client\clrcore\BaseScript.cs:421 
[Tick]
private async Task DelayedTicks() {
    await Delay(200);
    if (!FirstSpawnModule.done) return;

    Tick += Check5;
    Tick += Check13;
    Tick += Check17;
    Tick += Check23;
    Tick += Check31;
    Tick -= DelayedTicks;
}

This also impacts Newtonsoft.JSON a popular serialization library for C#:

Newtonsoft.Json.JsonSerializationException: Error getting value from 'type' on '<>f__AnonymousType10`3[System.String,System.Int32,System.Int32]'. ---> System.MethodAccessException: Transparent method Newtonsoft.Json.Utilities.ReflectionUtils:GetMemberValue (System.Reflection.MemberInfo,object) cannot create a delegate on private/internal method <>f__AnonymousType10`3<string, int, int>:get_type ().
Full stacktrace
[     55563] [b3095_GTAProce]                25820/ Unhandled task exception: 
[     55563] [b3095_GTAProce]                25820/ Newtonsoft.Json.JsonSerializationException: Error getting value from 'type' on '<>f__AnonymousType10`3[System.String,System.Int32,System.Int32]'. ---> System.MethodAccessException: Transparent method Newtonsoft.Json.Utilities.ReflectionUtils:GetMemberValue (System.Reflection.MemberInfo,object) cannot create a delegate on private/internal method <>f__AnonymousType10`3<string, int, int>:get_type ().
[     55563] [b3095_GTAProce]                25820/   at (wrapper managed-to-native) System.Delegate:CreateDelegate_internal (System.Type,object,System.Reflection.MethodInfo,bool)
[     55563] [b3095_GTAProce]                25820/   at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, System.Boolean throwOnBindFailure, System.Boolean allowClosed) [0x002f0] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     55563] [b3095_GTAProce]                25820/   at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method, System.Boolean throwOnBindFailure) [0x00000] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     55563] [b3095_GTAProce]                25820/   at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method) [0x00000] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     55563] [b3095_GTAProce]                25820/   at System.Reflection.MonoProperty.CreateGetterDelegate (System.Reflection.MethodInfo method) [0x0005e] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     55563] [b3095_GTAProce]                25820/   at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) [0x00053] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[     55563] [b3095_GTAProce]                25820/   at Newtonsoft.Json.Utilities.ReflectionUtils.GetMemberValue (System.Reflection.MemberInfo member, System.Object target) [0x00036] in <f7098f0ee85e4369974e6b04aa6d6c62>:0 
[     55563] [b3095_GTAProce]                25820/   at Newtonsoft.Json.Serialization.ReflectionValueProvider.GetValue (System.Object target) [0x00032] in <f7098f0ee85e4369974e6b04aa6d6c62>:0 
[     55563] [b3095_GTAProce]                25820/    --- End of inner exception stack trace ---
[     55563] [b3095_GTAProce]                25820/   at Newtonsoft.Json.Serialization.ReflectionValueProvider.GetValue (System.Object target) [0x00068] in <f7098f0ee85e4369974e6b04aa6d6c62>:0 
[     55563] [b3095_GTAProce]                25820/   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContainerContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.Serialization.JsonContract& memberContract, System.Object& memberValue) [0x00066] in <f7098f0ee85e4369974e6b04aa6d6c62>:0 
[     55563] [b3095_GTAProce]                25820/   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x0008d] in <f7098f0ee85e4369974e6b04aa6d6c62>:0 
[     55563] [b3095_GTAProce]                25820/   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000b0] in <f7098f0ee85e4369974e6b04aa6d6c62>:0 
[     55563] [b3095_GTAProce]                25820/   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00079] in <f7098f0ee85e4369974e6b04aa6d6c62>:0 
[     55563] [b3095_GTAProce]                25820/   at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x0023a] in <f7098f0ee85e4369974e6b04aa6d6c62>:0 
[     55563] [b3095_GTAProce]                25820/   at Newtonsoft.Json.JsonSerializer.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in <f7098f0ee85e4369974e6b04aa6d6c62>:0 
[     55563] [b3095_GTAProce]                25820/   at Newtonsoft.Json.JsonConvert.SerializeObjectInternal (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00028] in <f7098f0ee85e4369974e6b04aa6d6c62>:0 
[     55563] [b3095_GTAProce]                25820/   at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00007] in <f7098f0ee85e4369974e6b04aa6d6c62>:0 
[     55563] [b3095_GTAProce]                25820/   at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value) [0x00000] in <f7098f0ee85e4369974e6b04aa6d6c62>:0 
[     55563] [b3095_GTAProce]                25820/   at GamboCityClient.HudModule.UpdateHudHealth () [0x0002a] in C:\Users\Imman\source\repos\GamboCity\Keyinator-FiveM-FFA-v1\KeyinatorClient\Module\HudModule.cs:64 
[     55563] [b3095_GTAProce]                25820/   at GamboCityClient.PlayerModule.Heal (System.Int32 health, System.Int32 armor, System.Boolean requestLock) [0x00033] in C:\Users\Imman\source\repos\GamboCity\Keyinator-FiveM-FFA-v1\KeyinatorClient\Module\PlayerModule.cs:358 
[     55563] [b3095_GTAProce]                25820/   at GamboCityClient.FirstSpawnModule.LoadBasicValues () [0x0006c] in C:\Users\Imman\source\repos\GamboCity\Keyinator-FiveM-FFA-v1\KeyinatorClient\Module\PlayerModule.cs:70 
[     55563] [b3095_GTAProce]                25820/   at GamboCityClient.FirstSpawnModule+<DoFirstSpawn>d__5.MoveNext () [0x0008a] in C:\Users\Imman\source\repos\GamboCity\Keyinator-FiveM-FFA-v1\KeyinatorClient\Module\PlayerModule.cs:23 
public static void UpdateHudHealth() {
    //await Delay(Player.rnd.Next(uiUpdateTimings[0], uiUpdateTimings[1]));

    int ped = PlayerPedId();
    int health = GetEntityHealth(ped);
    int armor = GetPedArmour(ped);

    if (health == 199) health = 200;
    if (armor == 99) armor = 100;

    SendNuiMessage(JsonConvert.SerializeObject(new { //HAPPENS HERE
        type = "healthBarUpdate",
        health,
        armor,
    }));
}

Expected result

The code should've run

Reproduction steps

public class Test : BaseScript
{
  [Tick]
  private async Task PrivateTick()
  {
  }
}

Importancy

Crash

Area(s)

ScRT: C#

Specific version(s)

FiveM Client Canary

Additional information

Reports have started today and the issue only occurs on the canary (aka. "Latest (Unstable)") branch

@Keyinator Keyinator added bug triage Needs a preliminary assessment to determine the urgency and required action labels Feb 6, 2025
@github-actions github-actions bot added crash ScRT: C# Issues/PRs related to either C# scripting runtimes labels Feb 6, 2025
@Keyinator Keyinator changed the title [...] cannot create a delegate on private/internal method [...] (). MonoRT1: [...] cannot create a delegate on private/internal method [...] (). Feb 6, 2025
@DaniGP17
Copy link
Contributor

DaniGP17 commented Feb 6, 2025

I think is caused by this commit: 32090c7

@DaniGP17
Copy link
Contributor

DaniGP17 commented Feb 7, 2025

Already reverted in cc97bd6, this issue can be closed I guess

@iridium-cfx
Copy link
Contributor

Yup, this should be fixed.

@github-actions github-actions bot removed the triage Needs a preliminary assessment to determine the urgency and required action label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug crash ScRT: C# Issues/PRs related to either C# scripting runtimes
Projects
None yet
Development

No branches or pull requests

3 participants