How to properly add DLL to Editor

I am following the guide here. I’ve successfully added DLLs that are now not giving any compilation errors. However when I try to call code during play-time I am getting warnings saying the DLLs are not present.

[ 00:07:45.784 ]: [Warning] Exception has been thrown. Unable to load one or more of the requested types.
Could not load file or assembly 'MessagePack, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b4a0369545f0a1be'. The system cannot find the file specified.
Stack strace:
   at System.Reflection.RuntimeModule.GetTypes(QCallModule module, ObjectHandleOnStack retTypes)
   at System.Reflection.RuntimeModule.GetDefinedTypes()
   at System.Reflection.RuntimeModule.GetTypes()
   at BlastNet.Common.INetMessage.RegisterAssembly(Assembly assembly)
   at BlastNet.Common.INetMessage.RegisterAllMessages()
   at BlastNet.Common.INetMessage.Initialize()
   at BlastNet.Common.BlastNetManager.Initialize(Logger logger)
   at Game.BlastNetworker.StartNetworker(String address, UInt16 port) in G:\Flax\UMMO\Source\Game\BlastNetworker.cs:line 46
   at Game.RealmConnectScreen.OnEnable() in G:\Flax\UMMO\Source\Game\RealmConnectScreen.cs:line 42
   at FlaxEngine.Interop.NativeInterop.Invoker.InvokerNoRet0`1.InvokeThunk(Object delegateContext, ManagedHandle instancePtr, IntPtr* paramPtrs) in C:\Users\Wojtek\Flax\FlaxEngine\Source\Engine\Engine\NativeInterop.Invoker.cs:line 301
   at FlaxEngine.Interop.NativeInterop.ThunkContext.InvokeThunk(ManagedHandle instanceHandle, IntPtr param1, IntPtr param2, IntPtr param3, IntPtr param4, IntPtr param5, IntPtr param6, IntPtr param7) in C:\Users\Wojtek\Flax\FlaxEngine\Source\Engine\Engine\NativeInterop.cs:line 1840

When I try to add the DLL (MessagePack) to editor as the guide states:

options.ExternalModules.Add(new BuildOptions.ExternalModule(BuildOptions.ExternalModule.Types.CSharp, path));

I get the error:

[ 00:20:56.925 ]: [Info] Exception: Index was outside the bounds of the array.
Stack trace:
[ 00:20:56.928 ]: [Info]    at Flax.Build.Builder.BuildTargetNativeCppBindingsOnly(RulesAssembly rules, TaskGraph graph, Target target, Dictionary`2 buildContext, Platform platform, TargetArchitecture architecture, TargetConfiguration configuration, Boolean skipBuild) in C:\Users\Wojtek\Flax\FlaxEngine\Source\Tools\Flax.Build\Build\NativeCpp\Builder.NativeCpp.cs:line 1073
   at Flax.Build.Builder.BuildTargets() in C:\Users\Wojtek\Flax\FlaxEngine\Source\Tools\Flax.Build\Build\Builder.cs:line 350
   at Flax.Build.Program.Main() in C:\Users\Wojtek\Flax\FlaxEngine\Source\Tools\Flax.Build\Program.cs:line 152

This may be the result of MessagePack using dynamic code generation though I thought that wouldn’t be the case as Flax uses NET 8.0 compared to something much lower like Unity.

Either way, I’d love to know what I am doing wrong or what limitation I am up against. Thanks so much~

The first error comes from the fact that the given dll is not present nearby game assemblies in compiled binaries folder.

options.ExternalModules shoudl be used to game script modules, to reference 3rd party lib with C# code use:

options.ScriptingAPI.FileReferences.Add(path);

Oh yes, I have tried that. I only tried options.ExternalModules as a means to fix it. Here is my full Game.Build.cs

using System.IO;
using Flax.Build;
using Flax.Build.NativeCpp;

public class Game : GameModule
{
    /// <inheritdoc />
    public override void Init()
    {
        base.Init();
        // C#-only scripting
        BuildNativeCode = false;
    }

    /// <inheritdoc />
    public override void Setup(BuildOptions options)
    {
        base.Setup(options);
        options.ScriptingAPI.IgnoreMissingDocumentationWarnings = true;
        // Here you can modify the build options for your game module
        // To reference another module use: options.PublicDependencies.Add("Audio");
        // To add C++ define use: options.PublicDefinitions.Add("COMPILE_WITH_FLAX");
        // To learn more see scripting documentation.
        // Reference C# DLL placed Content folder
        options.ScriptingAPI.FileReferences.Add(AssemblyPath("MessagePack.dll"));
        //options.ExternalModules.Add(new BuildOptions.ExternalModule(BuildOptions.ExternalModule.Types.CSharp, AssemblyPath("MessagePack.dll")));
        options.ScriptingAPI.FileReferences.Add(AssemblyPath("MessagePack.Annotations.dll"));
        options.ScriptingAPI.FileReferences.Add(AssemblyPath("MessagePack.Analyzers.dll"));
        options.ScriptingAPI.FileReferences.Add(AssemblyPath("MessagePack.SourceGenerator.dll"));
        options.ScriptingAPI.FileReferences.Add(AssemblyPath("MessagePack.ReactiveProperty.dll"));
        options.ScriptingAPI.FileReferences.Add(AssemblyPath("BlastNet.Common.dll"));
        options.ScriptingAPI.FileReferences.Add(AssemblyPath("BlastNet.Client.dll"));
    }  
    private string AssemblyPath(string assemblyFileName)
    {
        return Path.Combine(FolderPath, "..", "..", "Content", "Assemblies", assemblyFileName);
    }
}

Thanks for the quick response btw. Your engine is absolutely amazing.

EDIT: I think I understand the issue better. I believe what is happening here is that BlastNet.Client.dll depends on MessagePack.dll and when the code is being called in BlastNet.Client, it cannot find the reference to MessagePack.