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.
The set of C# bindings is a wrapper around the Worker SDK in C. The C# bindings provide many classes that manage the ownership of objects. The Worker SDK in C allocates these objects. This means that the C# garbage collector can’t directly reclaim these native resources, and if you fail to handle them correctly, this can cause unpredictable behavior.
To avoid this, you must dispose of every
IDisposable object explicitly. To do this, call the
Dispose method on the object, or wrap its initialization in a
using statement. If you don’t do this, the native resources are still released when the corresponding C# object is garbage-collected. If the resources are released in the wrong order, this can cause crashes, especially when you terminate the program. Therefore, it's best to dispose of every
IDisposable object explicitly.
The current list of classes that inherit from
2020-07-13 Page updated with editorial review: added "Managed native resources" section.
2019-11-25 Page added without editorial review.
Updated about a year ago