15

I've been working on a .NET 3.5 C# project using Visual Studio Community 2015, but I had always intended to do most of the development on Linux (Ubuntu Gnome 15.04) using Mono and MonoDevelop.

I'm running the latest stable Mono release (4.0.4) and MonoDevelop (5.9.6), which supports .NET 4.5 and can open the VS created solution file without issue.

Now I've been writing C++ apps on Linux for the best part of a decade, but C# and .NET are completely new to me. So I assumed that if I installed a Mono version that supports .NET 4.5, I would get .NET 3.5 as well because the later version is a superset of the older - much like a C++14 compiler supports C++03.

However this doesn't seem to be the case, as MonoDevelop states (under the Target Framework option for each project):

  • .NET Framework 4.5.1
  • Mono / .NET 4.5
  • Mono / .NET 3.5 (Not installed)

So do I have to install a parallel older version of Mono in order to get .NET 3.5 support, or am I just suffering a configuration problem?

cmannett85
  • 21,725
  • 8
  • 76
  • 119
  • 1
    On Ubuntu 17.10 I could just `sudo apt-get install mono-reference-assemblies-3.5`. Found that [here](https://forum.unity.com/threads/framework-mono-net-3-5-not-installed.448857/). – EagleBeak Mar 14 '18 at 17:29

3 Answers3

10

No configuration issue, Mono dropped support for the older frameworks in the 4.x release. If you need to compile against the 3.5 assemblies, then yes, you will need a parallel install.

Dropped Support for Old Frameworks

Reference Assemblies

We no longer build the reference assemblies for the .NET 2.0, .NET 3.5 or .NET 4.0 APIs, we now ship binaries of the reference assemblies (API contracts, without any actual executable code in them).

Mono will now only build the .NET 4.5 assemblies as well as the mobile-based profiles.

Note: You can still run assemblies compiled for earlier .NET profiles on Mono, there’s no need to recompile them (they’ll just run on the .NET 4.5 assemblies instead).

Community
  • 1
  • 1
SushiHangover
  • 73,120
  • 10
  • 106
  • 165
  • 1
    Ugh, what a pain. Thank you for the answer though. – cmannett85 Oct 17 '15 at 14:27
  • Just one minor note, should be the Mono community :) Xamarin != Mono. – Lex Li Oct 17 '15 at 15:46
  • 6
    I wrote a tutorial here: http://blog.rubenwardy.com/2016/07/20/rimworld-install-monodevelop-with-dot-net-3.5/ I found it quite hard to work out how to install an older version of Mono and MonoDevelop which supported 3.5, so I made a blog post. Hope this helps someone – rubenwardy Jul 22 '16 at 18:23
  • @rubenwardy Funny I happen to be doing this for RimWorld Linux dev exactly like your blog refers to, but it's ridiculous how much it takes to get this working. Coming from Java dev, where building with an older JDK is trivial and routine, this is a really crappy greeting to the world of .NET dev. Unfortunately I guess due to Linux version diffs, it's not as simple on my PC as following the steps listed. Even more "awesome", I assume I'll lose ability to build Kerbal mods which I think rely on later versions. :/ – Manius Oct 27 '18 at 22:40
3

I had a similar issue (project targeting .NET 4.0, but now only 4.5 is available through mono). My workaround was to create a symlink for 4.0:

On my Fedora 32 machine this was done by

cd /usr/lib/mono
sudo ln -s 4.5 4.0

This is supposed to work because there a (almost) no breaking changes between .NET 4 and 4.5 - YMMV

ChriPf
  • 2,700
  • 1
  • 23
  • 25
2

Finally, Got it to work. I'm using Visual Studio for Mac - https://www.visualstudio.com/vs/visual-studio-mac/

Under Preferences->Projects->.Net Runtimes you can change the Default .Net Runtime. It defaults to Mono 4.8.0.

This is located here on a mac : /Library/Frameworks/Mono.framework/Versions/4.8.0

From here you can download older versions of Mono https://download.mono-project.com/archive/

I downloaded 3.12.1 from https://download.mono-project.com/archive/3.12.1/macos-10-x86/ and copied it into the /Library/Frameworks/Mono.framework/Versions/ folder.

Within VisualStudio you can then add the .net framework and set it as default. My project then compiled.

Emile
  • 11,451
  • 5
  • 50
  • 63
  • 1
    You don't have to set it as the default. You can just choose Project->Active Runtime -> Mono 3.12 and then compile – PandaWood Jun 15 '17 at 11:55