When a client UI contains a media file larger than 1 MB and the [client].ui_cdn setting is not configured, the server logs a warning about the file size and then crashes with a System.IO.FileLoadException while initializing the game mode.
Environment
UI directory: gamemodes/kingdomclient/ui
UI configuration: server.toml
Steps to reproduce
Add a media file larger than 1 MB to the UI directory. For example:
gamemodes/kingdomclient/ui/img/auth-bg.png (approximately 2.5 MB).
Leave [client].ui_cdn empty or unconfigured.
Start the server.
Actual behavior
The server logs the following message:
ui: gamemodes/kingdomclient/ui: "img/auth-bg.png" is 2.5 MB; media over 1.0 MB comes from a CDN: set [client] ui_cdn (the files to upload are what --pack-ui writes)
Immediately afterward, the server terminates with an exception similar to:
System.IO.FileLoadException: Could not load file or assembly
'Microsoft.Extensions.DependencyInjection.Abstractions, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
An operation is not legal in the current state. (0x80131509)
---> System.InvalidOperationException:
AssemblyLoadContext is unloading or was already unloaded.
The game mode starts normally when the UI is disabled in the server configuration or when the oversized media file is removed.
Expected behavior
The server should report the oversized UI asset and handle the missing CDN configuration gracefully. It should not crash the entire server or cause an unrelated-looking .NET assembly-loading exception.
Possible acceptable behaviors include:
Rejecting the UI bundle with a clear, actionable error while keeping the server running.
Automatically excluding oversized media files from the local UI bundle and reporting that they must be hosted via the CDN.
Continuing server startup without the UI if the UI bundle is invalid.
Additional observations
The assembly-loading exception appears to be a secondary failure triggered during startup after the UI validation message. The exact causal relationship has not yet been confirmed.
Configuring [client].ui_cdn or removing the oversized asset appears to avoid the issue.