I am having the same exact problem as this post. I hate to create a new topic for this, but that was marked as solved and its likely nobody will read it. The solution provided in that post does not work for me.
[ 78936] InvokeNative: execution failed: No current resource manager.
[ 79046] Unhandled exception: System.ArgumentException: Value does not fall within the expected range.
[ 79046]
[ 79061]
[ 79061] Server stack trace:
[ 79061] at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR (System.Int32 errorCode) [0x0000a] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79061] at (wrapper cominterop) CitizenFX.Core.IScriptHost:InvokeNative (CitizenFX.Core.fxScriptContext&)
[ 79077] at (wrapper cominterop-invoke) CitizenFX.Core.IScriptHost:InvokeNative (CitizenFX.Core.fxScriptContext&)
[ 79077] at CitizenFX.Core.MonoScriptRuntime+WrapScriptHost.InvokeNative (CitizenFX.Core.fxScriptContext& context) [0x00000] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\MonoScriptRuntime.cs:242
[ 79077] at (wrapper remoting-invoke-with-check) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:InvokeNative (CitizenFX.Core.fxScriptContext&)
[ 79077] at (wrapper xdomain-dispatch) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:InvokeNative (object,byte[]&,byte[]&)
[ 79077]
[ 79092] Exception rethrown at [0]:
[ 79092] at (wrapper xdomain-invoke) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:InvokeNative (CitizenFX.Core.fxScriptContext&)
[ 79092] at CitizenFX.Core.ScriptContext.InvokeInternal (System.UInt64 nativeIdentifier, CitizenFX.Core.IScriptHost scriptHost) [0x0000c] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\ScriptContext.cs:173
[ 79092] at CitizenFX.Core.ScriptContext.Invoke (System.UInt64 nativeIdentifier, CitizenFX.Core.IScriptHost scriptHost) [0x00000] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\ScriptContext.cs:166
[ 79108] at CitizenFX.Core.Native.Function.InvokeInternal (CitizenFX.Core.Native.Hash nativeHash, System.Type returnType, CitizenFX.Core.Native.InputArgument[] args) [0x00026] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\Native.cs:28
[ 79108] at CitizenFX.Core.Native.Function.Call (CitizenFX.Core.Native.Hash hash, CitizenFX.Core.Native.InputArgument[] arguments) [0x00000] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\Native.cs:16
[ 79108] at CitizenFX.Core.BaseScript.TriggerClientEvent (System.String eventName, System.Object[] args) [0x00012] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\BaseScript.cs:133
[ 79108] at BrigSteamScoreBoardSV.BrigSteamScoreBoardSV+<ScoreboardJoined>d__11.MoveNext () [0x00302] in <8a32d18219be4c6096a01937759c7d7d>:0
[ 79108] --- End of stack trace from previous location where exception was thrown ---
[ 79124] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79124] at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_1 (System.Object state) [0x00000] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79124] at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x00007] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79124] at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79124] at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79139] at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00021] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79139] at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79139] at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79342] GlobalError: Unhandled exception in Mono script environment: System.ArgumentException: Value does not fall within the expected range.
[ 79342]
[ 79342]
[ 79342] Server stack trace:
[ 79358] at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR (System.Int32 errorCode) [0x0000a] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79358] at (wrapper cominterop) CitizenFX.Core.IScriptHost:InvokeNative (CitizenFX.Core.fxScriptContext&)
[ 79358] at (wrapper cominterop-invoke) CitizenFX.Core.IScriptHost:InvokeNative (CitizenFX.Core.fxScriptContext&)
[ 79358] at CitizenFX.Core.MonoScriptRuntime+WrapScriptHost.InvokeNative (CitizenFX.Core.fxScriptContext& context) [0x00000] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\MonoScriptRuntime.cs:242
[ 79358] at (wrapper remoting-invoke-with-check) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:InvokeNative (CitizenFX.Core.fxScriptContext&)
[ 79373] at (wrapper xdomain-dispatch) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:InvokeNative (object,byte[]&,byte[]&)
[ 79373]
[ 79373] Exception rethrown at [0]:
[ 79373] at (wrapper xdomain-invoke) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:InvokeNative (CitizenFX.Core.fxScriptContext&)
[ 79389] at CitizenFX.Core.ScriptContext.InvokeInternal (System.UInt64 nativeIdentifier, CitizenFX.Core.IScriptHost scriptHost) [0x0000c] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\ScriptContext.cs:173
[ 79389] at CitizenFX.Core.ScriptContext.Invoke (System.UInt64 nativeIdentifier, CitizenFX.Core.IScriptHost scriptHost) [0x00000] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\ScriptContext.cs:166
[ 79389] at CitizenFX.Core.Native.Function.InvokeInternal (CitizenFX.Core.Native.Hash nativeHash, System.Type returnType, CitizenFX.Core.Native.InputArgument[] args) [0x00026] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\Native.cs:28
[ 79389] at CitizenFX.Core.Native.Function.Call (CitizenFX.Core.Native.Hash hash, CitizenFX.Core.Native.InputArgument[] arguments) [0x00000] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\Native.cs:16
[ 79404] at CitizenFX.Core.BaseScript.TriggerClientEvent (System.String eventName, System.Object[] args) [0x00012] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\BaseScript.cs:133
[ 79420] at BrigSteamScoreBoardSV.BrigSteamScoreBoardSV+<ScoreboardJoined>d__11.MoveNext () [0x00302] in <8a32d18219be4c6096a01937759c7d7d>:0
[ 79436] --- End of stack trace from previous location where exception was thrown ---
[ 79436] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79436] at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_1 (System.Object state) [0x00000] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79436] at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x00007] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79436] at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79451] at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79451] at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00021] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79451] at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79451] at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79467]
[ 79467] Server stack trace:
[ 79467] at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR (System.Int32 errorCode) [0x0000a] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79467] at (wrapper cominterop) CitizenFX.Core.IScriptHost:InvokeNative (CitizenFX.Core.fxScriptContext&)
[ 79467] at (wrapper cominterop-invoke) CitizenFX.Core.IScriptHost:InvokeNative (CitizenFX.Core.fxScriptContext&)
[ 79482] at CitizenFX.Core.MonoScriptRuntime+WrapScriptHost.InvokeNative (CitizenFX.Core.fxScriptContext& context) [0x00000] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\MonoScriptRuntime.cs:242
[ 79482] at (wrapper remoting-invoke-with-check) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:InvokeNative (CitizenFX.Core.fxScriptContext&)
[ 79482] at (wrapper xdomain-dispatch) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:InvokeNative (object,byte[]&,byte[]&)
[ 79482]
[ 79482] Exception rethrown at [0]:
[ 79498] at (wrapper xdomain-invoke) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:InvokeNative (CitizenFX.Core.fxScriptContext&)
[ 79498] at CitizenFX.Core.ScriptContext.InvokeInternal (System.UInt64 nativeIdentifier, CitizenFX.Core.IScriptHost scriptHost) [0x0000c] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\ScriptContext.cs:173
[ 79514] at CitizenFX.Core.ScriptContext.Invoke (System.UInt64 nativeIdentifier, CitizenFX.Core.IScriptHost scriptHost) [0x00000] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\ScriptContext.cs:166
[ 79514] at CitizenFX.Core.Native.Function.InvokeInternal (CitizenFX.Core.Native.Hash nativeHash, System.Type returnType, CitizenFX.Core.Native.InputArgument[] args) [0x00026] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\Native.cs:28
[ 79514] at CitizenFX.Core.Native.Function.Call (CitizenFX.Core.Native.Hash hash, CitizenFX.Core.Native.InputArgument[] arguments) [0x00000] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\Native.cs:16
[ 79514] at CitizenFX.Core.BaseScript.TriggerClientEvent (System.String eventName, System.Object[] args) [0x00012] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\BaseScript.cs:133
[ 79514] at BrigSteamScoreBoardSV.BrigSteamScoreBoardSV+<ScoreboardJoined>d__11.MoveNext () [0x00302] in <8a32d18219be4c6096a01937759c7d7d>:0
[ 79529] --- End of stack trace from previous location where exception was thrown ---
[ 79529] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79529] at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_1 (System.Object state) [0x00000] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79529] at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x00007] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79545] at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79545] at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79545] at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00021] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79545] at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 79560] at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
This is the function in question. This is being triggered by the client when NetworkIsSessionStarted()
becomes true, basically right as the player spawns.
public async void ScoreboardJoined([FromSource] Player ply)
{
string plySteam = ply.Identifiers["steam"];
string avURL = "NONE";
if (plySteam != null)
{
...Get info using HttpClient...
}
else
{
...
}
ScoreBoardPlayer temp = new ScoreBoardPlayer();
temp.AvURL = avURL;
temp.SteamID = plySteam;
scoreboardPlayers.Add(int.Parse(ply.Handle), temp);
await Delay(5000); // Prevent crash on join
int plyHand = int.Parse(ply.Handle);
TriggerClientEvent("scoreboardAdd", plyHand, temp); // ** CRASH HERE **
...
}
I have put in an await Delay(5000);
as a temporary work-around, which has worked, but if the player is still not fully spawned in (on really slow computers) the server will crash with the error above. If the player is spawned in before this triggers, nothing is wrong.
I am 100% lost with this, and I have no alternative (that I know of). I need to fetch info as a client joins and then send it to everybody.