citizenfx / fivem

The source code for the Cfx.re modification frameworks, such as FiveM, RedM and LibertyM, as well as FXServer.
https://cfx.re/
3.39k stars 1.99k forks source link

[clrcore-v2] Exports crash when executed #2590

Open DaniGP17 opened 2 weeks ago

DaniGP17 commented 2 weeks ago

What happened?

After the new addition of the custom msgpack serializer(#2546), the export system has stopped working, and I always get an error when I run an export registered in C# from lua.

Expected result

Don't show any errors

Reproduction steps

  1. Register a export in C#
  2. Execute that export in lua

Importancy

Crash

Area(s)

FXServer, ScRT: C#

Specific version(s)

Server 8552(Latest)

Additional information

Error:

[    c-scripting-mono] Exception in Mono script environment: System.NotSupportedException: Requested serializer for MethodInfo.CustomAttributes of type System.Collections.Generic.IEnumerable`1[System.Reflection.CustomAttributeData] could not be found.
[    c-scripting-mono]   at CitizenFX.MsgPack.Formatters.TypeFormatter.BuildSerializeMapBody (System.Type type, System.Reflection.Emit.ILGenerator g, CitizenFX.MsgPack.Detail.DynamicArray`1[T] members, System.Reflection.MethodInfo currentSerializer) [0x0023f] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\Formatters\TypeFormatter.cs:323
[    c-scripting-mono]   at CitizenFX.MsgPack.Formatters.TypeFormatter.BuildSerializer (System.Type type, System.Reflection.Emit.TypeBuilder typeBuilder) [0x00117] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\Formatters\TypeFormatter.cs:170
[    c-scripting-mono]   at CitizenFX.MsgPack.Formatters.TypeFormatter.Build (System.Type type) [0x000ce] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\Formatters\TypeFormatter.cs:79
[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackRegistry.CreateSerializer (System.Type type) [0x0008e] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackRegistry.cs:214
[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackRegistry.GetOrCreateSerializer (System.Type type) [0x00000] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackRegistry.cs:167
[    c-scripting-mono]   at CitizenFX.MsgPack.Formatters.TypeFormatter.BuildSerializeMapBody (System.Type type, System.Reflection.Emit.ILGenerator g, CitizenFX.MsgPack.Detail.DynamicArray`1[T] members, System.Reflection.MethodInfo currentSerializer) [0x0015b] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\Formatters\TypeFormatter.cs:293
[    c-scripting-mono]   at CitizenFX.MsgPack.Formatters.TypeFormatter.BuildSerializer (System.Type type, System.Reflection.Emit.TypeBuilder typeBuilder) [0x00117] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\Formatters\TypeFormatter.cs:170
[    c-scripting-mono]   at CitizenFX.MsgPack.Formatters.TypeFormatter.Build (System.Type type) [0x000ce] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\Formatters\TypeFormatter.cs:79
[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackRegistry.CreateSerializer (System.Type type) [0x0008e] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackRegistry.cs:214
[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackRegistry.Serialize (CitizenFX.MsgPack.MsgPackSerializer serializer, System.Object obj) [0x0018a] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackRegistry.cs:143

[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackSerializer.Serialize (System.Object v) [0x00000] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackSerializer.cs:70
[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackSerializer.Serialize (System.Object[] v) [0x0000d] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackSerializer.cs:256
[    c-scripting-mono]   at (wrapper dynamic-method) System.Object.MsgPackSerializer(CitizenFX.MsgPack.MsgPackSerializer,object)
[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackRegistry.Serialize (CitizenFX.MsgPack.MsgPackSerializer serializer, System.Object obj) [0x0017b] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackRegistry.cs:139

[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackSerializer.Serialize (System.Object v) [0x00000] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackSerializer.cs:70
[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackSerializer.SerializeToByteArray (System.Object value) [0x00005] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackSerializer.cs:59
[    c-scripting-mono]   at CitizenFX.Core.Native.InPacket..ctor (System.Object obj) [0x00000] in C:\gl\builds\cfx-fivem\master\fxserver\code\client\clrcore-v2\Native\Types\NativeTypes.cs:80
[    c-scripting-mono]   at CitizenFX.Core.Native.InPacket.Serialize (System.Object obj) [0x00000] in C:\gl\builds\cfx-fivem\master\fxserver\code\client\clrcore-v2\Native\Types\NativeTypes.cs:81
[    c-scripting-mono]   at CitizenFX.Core.Native.InPacket.op_Implicit (System.Object[] obj) [0x00000] in C:\gl\builds\cfx-fivem\master\fxserver\code\client\clrcore-v2\Native\Types\NativeTypes.cs:82
[    c-scripting-mono]   at CitizenFX.Core._LocalFunction.Invoke (System.Object[] args) [0x00000] in C:\gl\builds\cfx-fivem\master\fxserver\code\client\clrcore-v2\Interop\LocalFunction.cs:46
[    c-scripting-mono]   at CitizenFX.Core.ExportsManager.IncomingRequest (System.String eventName, System.String sourceString, CitizenFX.Core.Binding origin, System.Byte* argsSerialized, System.Int32 serializedSize) [0x0003b] in C:\gl\builds\cfx-fivem\master\fxserver\code\client\clrcore-v2\Interop\ExportsManager.cs:34
[    c-scripting-mono]   at CitizenFX.Core.ScriptInterface.TriggerEvent (System.String eventName, System.Byte* argsSerialized, System.Int32 serializedSize, System.String sourceString, System.UInt64 hostTime, System.Boolean profiling) [0x0003c] in C:\gl\builds\cfx-fivem\master\fxserver\code\client\clrcore-v2\ScriptInterface.cs:151
[    c-scripting-mono]   at (wrapper native-to-managed) CitizenFX.Core.ScriptInterface.TriggerEvent(string,byte*,int,string,ulong,bool,System.Exception&)
[    c-scripting-mono]   at CitizenFX.MsgPack.Formatters.TypeFormatter.BuildSerializeMapBody (System.Type type, System.Reflection.Emit.ILGenerator g, CitizenFX.MsgPack.Detail.DynamicArray`1[T] members, System.Reflection.MethodInfo currentSerializer) [0x0023f] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\Formatters\TypeFormatter.cs:323
[    c-scripting-mono]   at CitizenFX.MsgPack.Formatters.TypeFormatter.BuildSerializer (System.Type type, System.Reflection.Emit.TypeBuilder typeBuilder) [0x00117] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\Formatters\TypeFormatter.cs:170
[    c-scripting-mono]   at CitizenFX.MsgPack.Formatters.TypeFormatter.Build (System.Type type) [0x000ce] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\Formatters\TypeFormatter.cs:79
[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackRegistry.CreateSerializer (System.Type type) [0x0008e] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackRegistry.cs:214
[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackRegistry.GetOrCreateSerializer (System.Type type) [0x00000] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackRegistry.cs:167
[    c-scripting-mono]   at CitizenFX.MsgPack.Formatters.TypeFormatter.BuildSerializeMapBody (System.Type type, System.Reflection.Emit.ILGenerator g, CitizenFX.MsgPack.Detail.DynamicArray`1[T] members, System.Reflection.MethodInfo currentSerializer) [0x0015b] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\Formatters\TypeFormatter.cs:293
[    c-scripting-mono]   at CitizenFX.MsgPack.Formatters.TypeFormatter.BuildSerializer (System.Type type, System.Reflection.Emit.TypeBuilder typeBuilder) [0x00117] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\Formatters\TypeFormatter.cs:170
[    c-scripting-mono]   at CitizenFX.MsgPack.Formatters.TypeFormatter.Build (System.Type type) [0x000ce] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\Formatters\TypeFormatter.cs:79
[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackRegistry.CreateSerializer (System.Type type) [0x0008e] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackRegistry.cs:214
[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackRegistry.Serialize (CitizenFX.MsgPack.MsgPackSerializer serializer, System.Object obj) [0x0018a] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackRegistry.cs:143

[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackSerializer.Serialize (System.Object v) [0x00000] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackSerializer.cs:70
[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackSerializer.Serialize (System.Object[] v) [0x0000d] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackSerializer.cs:256
[    c-scripting-mono]   at (wrapper dynamic-method) System.Object.MsgPackSerializer(CitizenFX.MsgPack.MsgPackSerializer,object)
[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackRegistry.Serialize (CitizenFX.MsgPack.MsgPackSerializer serializer, System.Object obj) [0x0017b] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackRegistry.cs:139

[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackSerializer.Serialize (System.Object v) [0x00000] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackSerializer.cs:70
[    c-scripting-mono]   at CitizenFX.MsgPack.MsgPackSerializer.SerializeToByteArray (System.Object value) [0x00005] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackSerializer.cs:59
[    c-scripting-mono]   at CitizenFX.Core.Native.InPacket..ctor (System.Object obj) [0x00000] in C:\gl\builds\cfx-fivem\master\fxserver\code\client\clrcore-v2\Native\Types\NativeTypes.cs:80
[    c-scripting-mono]   at CitizenFX.Core.Native.InPacket.Serialize (System.Object obj) [0x00000] in C:\gl\builds\cfx-fivem\master\fxserver\code\client\clrcore-v2\Native\Types\NativeTypes.cs:81
[    c-scripting-mono]   at CitizenFX.Core.Native.InPacket.op_Implicit (System.Object[] obj) [0x00000] in C:\gl\builds\cfx-fivem\master\fxserver\code\client\clrcore-v2\Native\Types\NativeTypes.cs:82
[    c-scripting-mono]   at CitizenFX.Core._LocalFunction.Invoke (System.Object[] args) [0x00000] in C:\gl\builds\cfx-fivem\master\fxserver\code\client\clrcore-v2\Interop\LocalFunction.cs:46
[    c-scripting-mono]   at CitizenFX.Core.ExportsManager.IncomingRequest (System.String eventName, System.String sourceString, CitizenFX.Core.Binding origin, System.Byte* argsSerialized, System.Int32 serializedSize) [0x0003b] in C:\gl\builds\cfx-fivem\master\fxserver\code\client\clrcore-v2\Interop\ExportsManager.cs:34
[    c-scripting-mono]   at CitizenFX.Core.ScriptInterface.TriggerEvent (System.String eventName, System.Byte* argsSerialized, System.Int32 serializedSize, System.String sourceString, System.UInt64 hostTime, System.Boolean profiling) [0x0003c] in C:\gl\builds\cfx-fivem\master\fxserver\code\client\clrcore-v2\ScriptInterface.cs:151
[    c-scripting-mono]   at (wrapper native-to-managed) CitizenFX.Core.ScriptInterface.TriggerEvent(string,byte*,int,string,ulong,bool,System.Exception&)Failed to execute event __cfx_export_monodb_AwaitQuery - 80070057.
prikolium-cfx commented 2 weeks ago

Hi. Can you upload minimal resource to reproduce it and code how do you use this export in Lua?

DaniGP17 commented 2 weeks ago

Hi. Can you upload minimal resource to reproduce it and code how do you use this export in Lua?

Hello, sorry I did not attach a code to reproduce the error because all the methods I tried resulted in this same error and I assumed that it would not work in any way, here I attach the code that I am using to test it: C#:

using CitizenFX.Core;
using System.Collections.Generic;

namespace monodb
{
    public class Program : BaseScript
    {
        [Export("ExportTesting")]
        private string ExportE2()
        {
            return "yeehaa";
        }
    }
}

Lua:

local result = exports.monodb:ExportTesting()
print('Export result: ', result)
junredzik commented 6 days ago

I have the same problem even when I call something like this up

using CitizenFX.Core;

namespace CsClient
{
    public class Program : BaseScript
    {
        public Program()
        {
            Debug.WriteLine("test first");
        }

        [Export("test")]
        public void test()
        {
            Debug.WriteLine("test");
        }
    }
}
DaniGP17 commented 6 days ago

I have the same problem even when I call something like this up

I think that's a problem caused by the new msg pack serializer