Install Monodevelop to build for .NET 3.5 (using Mono 3.14) - RimWorld

This tutorial will show you how to install Mono and Monodevelop in order to develop .NET 3.5 projects. This is useful when writing C# assembly mods for Unity engine based games, such as RimWorld, as they tend to require .NET 3.5.

If you don’t use .NET 3.5, you may get errors including but not limited to:

System.TypeLoadException: Could not load type 'System.Action' from assembly 'ModName'.

That error is commonly thrown when versions such as .NET or .DLLs mismatch.

Mono 4.0 and later don’t support .NET 3.5. Therefore, we’ll need to install an older version.

I couldn’t find many posts about this, doesn’t seem that many people develop RimWorld on Linux.

After this tutorial, MonoDevelop will support the following target frameworks: Mono / .NET 2.0, Mono / .NET 3.0, .NET 3.5 Client Profile, Mono / .NET 3.5, .NET 4.0 Client Profile, Mono / .NET 4.0, Mono / .NET 4.5, .NET Framework 4.5.1

Uninstall any installed Mono versions

Unfortunately I do not know of a way to keep multiple versions of Mono and Monodevelop installed at a time, so you’ll need to uninstall them:

sudo apt-get remove mono-complete mono-devel monodevelop
sudo apt autoremove

Now check that mono is not installed:

mono --version
# you should get something like command not found

Add PPA for Mono 3.12.x

We need to add a snapshot PPA, as described in the mono-project docs.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy/snapshots/3.12.0 main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update

Install Mono and Monodevelop

Now we need to install Mono 3.14 and Monodevelop 5.7. We also need to lock the versions of the installed packages, to stop apt-get upgrade from installing Mono 4.0+ and reversing our efforts. We use apt-mark hold to do this.

sudo apt-get install build-essential cli-common libgtk2.0-cil-dev libglade2.0-cil-dev libgnome2.0-cil-dev libgconf2.0-cil-dev
sudo apt-get install -t wheezy/snapshots/3.12.0 mono-complete
sudo apt-mark hold mono-complete
sudo apt-mark hold mono-devel
sudo apt-mark hold libmono*
sudo apt-get install -t wheezy/snapshots/3.12.0 monodevelop
sudo apt-mark hold monodevelop

For more information, see this thread about installing from a specific repository and this thread about locking package versions.

Profit!

mono --version

Should give something like:

Mono JIT compiler version 3.12.1 (tarball Fri Mar  6 19:12:47 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com

And monodevelop should be in the start menu. Note that you may need to restart your computer, depending on your window manager.

Next: Setting up a MonoDevelop solution and project for RimWorld modding.

Appendix

Here is an error you may get when implementing a JobDriver using .NET 4.0+

Exception in SetupToil(pawn=Kimmy, job=Accident): System.TypeLoadException: Could not load type 'System.Action' from assembly 'toilets'.
    at Verse.AI.JobDriver.SetupToils()
Verse.Log:Error(string)
Verse.AI.JobDriver:SetupToil()
Verse.AI.Pawn_JobTracker:StatJob(Job, JobCondition, ThinkNode, Boolean, Boolean, ThinkTreeDef)
Verse.AI.Pawn_JobTracker:TryFindAndStartJob()
Verse.AI.Pawn_JobTracter:EndCurrentJob(JobCondition)
Comments

Comments are currently disabled whilst we remove the dependency on a third party service which was taken offline. In the meantime, feel free to send a message to me on Twitter.