Server Artifact Version: latest 13458
Operating System (Windows/Linux): Windows
Language : C# (CSharp)
Lib: try to import with Nuget or just with (dotnet new cfx-resource)
Hi everyone!
I’m currently working on creating a RedM RP server and I want to build it entirely in C#, both on the client and server side.
I’ve already set up a basic vanilla RedM server to test things out. The setup goes well, I install the resource with:
dotnet new cfx-resource
The server launches fine, and the client spawns correctly — so far, so good!
But then, on the client side, I run into errors during the ticks. I get this message in the console:
MainThrd/ Failed to run a tick for ClientMain: System.BadImageFormatException: Error verifying dev.Client.ClientMain/<WorldControlLoop>d__5:MoveNext (): Cannot load method from token 0x0a00003a for call at 0x0075
For example, I have this simple code running after spawn:
// when i spawn -> i run this
Tick += WorldControlLoop;
private async Task WorldControlLoop()
{
try
{
Debug.WriteLine("[DEBUG] WorldControlLoop ok !");
SetPedDensityMultiplierThisFrame(0.0f);
SetScenarioPedDensityMultiplierThisFrame(0.0f, 0.0f);
// Clearing the area around the player (commented out for now)
// var ped = PlayerPedId();
// var coords = GetEntityCoords(ped, true);
// ClearAreaOfPeds(coords.X, coords.Y, coords.Z, 200.0f, 0);
}
catch (Exception e)
{
Debug.WriteLine($"[WorldControlLoop] Exception : {e.Message}");
}
await Delay(100);
}
I’m thinking it might be an issue with outdated libraries or some mismatch, so I tried using another installation method.
I found here:
mono_v2_get_started/Setup.md at main · thorium-cfx/mono_v2_get_started · GitHub
or i try to follow this with mono
C# mono v2
But, unfortunately, I couldn’t get it to work either.
I’m pretty stuck right now and going in circles. Does anyone have a working base setup or any advice on how to properly set up a **C# RedM server **?
Any help would be greatly appreciated!
Thanks in advance!