If you see a DllNotFoundException, make sure that you are running the 64-bit version of mono.

On macOS, mono can default to 32-bit, so please either use the --arch=64 flag by passing it as the first argument, e.g. mono --arch=64 CsharpWorkerName.exe, or run mono64 directly, to ensure that SpatialOS SDK native libraries are loaded correctly. This flag is only valid for macOS versions of Mono.


There are several potential issues with Mono versions from 5.0.0 onwards on Windows. These are a result of Mono deprecating xbuild and replacing it with Microsoft's MSBuild and both toolsets being included in Mono installations. SpatialOS csharp generated build scripts for C# workers use xbuild by default which can sometimes cause issues.

A workaround for this is to switch your generated build scripts to csharp_msbuild, which uses MSBuild; however, you can still encounter tricky compiler errors, such as a csc error. These can occur if you already have another MSBuild installation from elsewhere (like Visual Studio). As a workaround for this bug, ensure your other MSBuild implementation (likely from Visual Studio) is present in your PATH environment variable before mono. This will cause Mono's MSBuild to use the csc compiler in Visual Studio instead.

xbuild issue

The generated build scripts use wildcards to specify which generated code sources should be compiled. xbuild (the Mono build tool) reports warnings about source files being included multiple times if they use wildcards, which is a known bug in the compiler. If you see warnings such as

CSC: warning CS2002: Source file
"improbable\generated\improbable\test\TestComponent.cs" specified multiple times

or similar during your build, you can safely ignore them.

Missing GeneratedCode assembly

The mechanism to resolve a component metaclass to the associated ComponentId (ComponentDatabase.MetaclassToId) can fail. If it does, you will get an ArgumentException, with a stacktrace similar to the following:

 System.ArgumentException: <MESSAGE> Component <COMPONENT-TYPE / COMPONENT-ID> is not registered.
    at Improbable.Worker.Internal.ComponentDatabase.MetaclassToId[C]()

This occurs if the assembly containing the generated code has has not been loaded before your code runs, as assemblies are loaded lazily. You can work around this by manually loading the assembly, i.e. Assembly.Load("GeneratedCode").
GeneratedCode is the correct assembly name if you are using the generated build scripts, otherwise it may be different.

Updated about a year ago


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.