Navigation
Browse the developer docs

FH2 Mod Platform for .NET

Hosted or NativeAOT?

The same project built two ways, and when to use each.

By Bartholomew Ho (qiangqiang101) · MIT license · v0.12.0 · 15 Nov 2026 · repository · original page

On this page

The same project builds two ways. You don't change any code, only how you build it.

HostedNativeAOT
Builddotnet builddotnet publish -c Release -p:FH2ModHosting=Aot, or dotnet build -c Aot
In Visual StudioDebug or Release, then BuildAot, then Build
Goes infh2-mods-dotnet\<Name>\ (the whole output folder)fh2-mods\<Name>.dll (one file)
Players needthe .NET 10 runtime (x64) and Platform.NETnothing more than the platform
Sizeyour assemblyabout 1 MB, the runtime compiled in
Reload while the game runsyesno
Breakpoints in Visual Studioyesno
.NET featureseverything, including reflection and loading assembliesNativeAOT limits
Own pages and links on the MODS tabno (all hosted mods share one entry)yes
Named in crash reportsnoyes

Which one?

Develop hosted, ship NativeAOT. Hosted gives you reloads and breakpoints while you work. NativeAOT gives players one DLL that loads like any C++ mod, with no runtime to install.

Stay hosted for players only if your mod needs something NativeAOT can't do, like reflection-heavy libraries.

Don't install both builds of the same mod: it registers twice. The build warns you if it finds the other one in your game folder.

Building NativeAOT

NativeAOT needs Visual Studio's C++ tools to link (the free Build Tools for Visual Studio with "Desktop development with C++" are enough).

In Git Bash, use the Visual Studio Developer prompt or PowerShell instead, or keep ProgramFiles(x86) set: bash drops it, and the linker can't be found without it.

How hosted mods are loaded

fh2-mods\FH2DotNet.dll is an ordinary platform mod. It starts the .NET runtime, then loads each fh2-mods-dotnet\<Name>\<Name>.dll in alphabetical order. Each one gets a load context of its own, so two mods can use different versions of the same library.

Each hosted mod registers with the platform under its own name, so its text, file and database edits work like any native mod's. Without any hosted mods, the runtime isn't started at all.

Copied from the wiki page Hosted-or-NativeAOT at commit 7396a07 · MIT license
MIT License

Copyright (c) 2026 Bartholomew Ho

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.