From v1.7 there is a Tip added to Multithreading example code.
Add
options.ScriptingAPI.SystemReferences.Add("System.Threading.ThreadPool");
inSetup
function inside yourGame.Build.cs
to properly reference threading lib.
At first I thought it was like adding a GAC assembly reference to CS project like .net Framework, but it wasn’t. .Net 7’s project was already including System.Threading.Thread assembly in default,
and in Visual Studio main game csproj was built with no problem.
But in editor (hot reloading) CS0103 error occured-
[ 00:02:31.405 ]: [Info] Compiling Y:\MTTest\Binaries\GameEditorTarget\Windows\x64\Development\Game.CSharp.dll
[ 00:02:31.601 ]: [Info] Y:\MTTest\Source\Game\MTTest.cs(21,9,21,19): error CS0103: The name ‘ThreadPool’ does not exist in the current context
[ 00:02:31.606 ]: [Info] Task C:\Program Files\dotnet\dotnet.exe exec “C:\Program Files\dotnet\sdk\7.0.401\Roslyn\bincore\csc.dll” /noconfig /shared @“Y:\MTTest\Cache/Intermediate\GameEditorTarget\Windows\x64\Development\Game.CSharp.response” failed with exit code 11 task failed
and error disappeared successfully after adding options.ScriptingAPI.SystemReferences.Add(“System.Threading.ThreadPool”) just as manual said.
I examined Game.csproj project file but nothing was changed - so it is purely about engine specific compilation (cooker?).
What exactly options.ScriptingAPI.SystemReferences does with the engine? And how we know when to add, and which string to be added?