How to pass object from Lua to C# export

Just wondering if anyone know why I’m getting this error and how to fix?
SCRIPT ERROR in reference call: System.InvalidCastException: Could not cast event argument from ExpandoObject to ExtendedPlayer

This is what my C# code looks like and I’m calling the AddXPlayer method:


image

On the Lua side…
This is where a stripped down version of xPlayer from ESX gets created:
image

And this is where I create the stripped down one from the main ESX xPlayer to be passed to the C# export:

local xPlayer = CreateExtendedPlayer(playerId, identifier, userData.group, userData.accounts, userData.inventory, userData.weight, userData.job, userData.loadout, userData.playerName, userData.coords)
local xPlayerNet = CreateExtendedPlayerNet(xPlayer)
		
exports.es_extended:AddXPlayer(playerId, identifier, xPlayerNet)

Why does it say there’s an “event” that can’t be cast given there’s only a string on the object being converted?

Actually I realised what my issue was, the incoming object had to be ‘dynamic’:
Exports.Add("AddXPlayer", new Action<int, string, dynamic>(AddXPlayer));