thorium-cfx / mono_v2_get_started

Mono v2 runtime for FiveM/RedM
35 stars 1 forks source link

Remote export not called #35

Open JLFSL opened 8 months ago

JLFSL commented 8 months ago

What happened?

When trying to call an export with remote binding from the client to the server, an exception occurs that the object reference is not set to an instance.

I'm thinking that by looking at Exports.cs, it seems like REMOTE_FUNCTION_ENABLED is false. My code should be perfectly fine.

Client call

string json = await Exports["serverresource", "dosomething"]();

Example server export

[Export("dosomething", Binding.Remote)]
public string DoSomething()
{
    return "{}";
}

Client logs

[    646110] [b2944_GTAProce]             MainThrd/ System.NullReferenceException: Object reference not set to an instance of an object.
[    646110] [b2944_GTAProce]             MainThrd/   at NRP_JobManager.Client.Handlers.JobHandler+<SingleJobTick>d__5.MoveNext () [0x00557] in <190051bc189e4252990e44c10ec23095>:0 
[    646110] [b2944_GTAProce]             MainThrd/ --- End of stack trace from previous location where exception was thrown ---
[    646110] [b2944_GTAProce]             MainThrd/   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <b575c7ac070e41ffa0751333b6ac9f42>:0 
[    646110] [b2944_GTAProce]             MainThrd/   at CitizenFX.Core.Coroutine.GetResult () [0x00000] in C:\gl\builds\cfx-fivem\master\fivem\code\client\clrcore-v2\Coroutine\Coroutine.cs:201 
[    646110] [b2944_GTAProce]             MainThrd/   at CitizenFX.Core.CoroutineAwaiter.GetResult () [0x00000] in C:\gl\builds\cfx-fivem\master\fivem\code\client\clrcore-v2\Coroutine\Coroutine.cs:296 
[    646110] [b2944_GTAProce]             MainThrd/   at CitizenFX.Core.CoroutineRepeat+<Execute>d__6.MoveNext () [0x00032] in C:\gl\builds\cfx-fivem\master\fivem\code\client\clrcore-v2\Coroutine\CoroutineRepeat.cs:41 

Expected result

The export to be called, thus returning data.

Reproduction steps

1. Create a server export with a remote binding
2. Call this export from the client script of another resource

Importancy

Can't use this feature until fixed

Specific version

FiveM, latest as of today

Extra

This might also be a misunderstanding of the available documentation as of now, but I suspect it as a bug.

thorium-cfx commented 7 months ago

Thank you for the report. This functionality was initially planned, but disabled pre-beta as it was built on an unsafe protocol. New plans and work has already been done for all runtimes to offer this functionality, once that's finished then this feature will be enabled again.

I'll mark this issue as a feature request and remove the bug label because this was intended.