简体   繁体   中英

Older version of .Net not installed with latest Mono?

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?

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).

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM