How do I add a .NET Runtime in Edit->Prefrences? - c#

Ok I am using Windows and have .Net 3.5 and the Mono 2.6 frameworks installed. I also have installed MonoDevelop and plan on using it. I just need to know if I am setup to use the Mono runtime.
All my projects have build options for Mono/Microsoft.NET 3.5, but in Edit->Prefrences->.NET Runtimes, all I see is Microsoft.NET. How do I add the Mono runtime to this list and make it default? Or do I even need to do this? I would think I would have to since our projects will be run on Linux, but not sure how to 'make sure' I am actually using Mono and not just .NET?

Mono should show up simply by virtue of being installed. You can try reinstalling Mono to see if that helps.
If not, click the "Add" button on the Edit->Preferences->.Net Runtimes page and choose where you installed Mono to, generally it will be something like:
C:\Program Files\Mono-2.6.1
If you want it to be the default, click "Set as Default" while it's highlighted and it should turn bold, indicating it is now the default. There is also a combobox on the main MD toolbar if you want a quicker way of switching between runtimes.

You shouldnt HAVE to build using Mono's compiler on Windows to have your code run on Linux.
As per answers on Performance: Compile in CS, Run in mono on windows and linux, you can compile with any compiler and run with any runtime because the compiled binary is in an Intermediate Language
You just have to be certain that your code, and the libraries that it uses, do not make operating system specific calls, P/Invoke unmanaged DLL's, or make calls to functions that are incomplete in Mono (mind you, these are getting rare)

Related

Which versions of which compilers I should use to have C# 9 compiler?

Here it was written that compilers of different versions are applied sequentially to build the latest version of compiler.
I don't want to use binaries provided by Microsoft. I want to have everything be compiled from source codes.
Which repositories I should compile exactly? Do they all have open source licenses?
The runtime and the compiler for .NET 5.0 are open-source. You can start by going to https://github.com/dotnet/runtime. However, building the runtime requires the compiler (which will be downloaded by running the build script). So there's little you can do to avoid getting binaries that were built by Microsoft. If you're afraid that they're fake (and in some way different from what you would get if you directly built everything from source) you'll probably have to go a different way.

Linux JetBrains Rider can't use Mono, while it is installed in the system

I am currently using Manjaro Linux 20.2, with official JetBrains Rider from JetBrains Toolbox
I have installed this package package screenshot
When I'm writing in my terminal "mono" it runs.
File location also looks fine.
When I'm opening my Environment tab in Rider. I got this.
Environment Tab
I can create and run/execute/debug any projects with my .NET CORE
But I can't use the framework at all.
A simple application like this New Project Window
And here... the error
In my settings -> build and execution -> I have these parameters
path settings
I don't know what to do and how to fix this error. Tried many times disinstall/reinstall the Mono Package. But it's always the same.
Maybe I should change somehow a Mono path here in Rider Settings ?
But I don't know to where.. there are so many of these files in usr/lib and usr/bin
Please help me, I don't know what to do next and how to fix this..
I just know for sure. That it is possible to run Mono on UNIX.
Something is wrong..
UPD1: I've discovered, that to run Mono on Linux. I should install a different package "monodevelop"
But according to GitHub, this package is not build-able on Linux anymore (only on MacOS)
I've discovered this "dotdevelop" package..
https://github.com/dotdevelop/dotdevelop
But I don't know, it's looks like it doesn't work for me either.
Or maybe I'm just putting a wrong file to my mono path settings in Rider..
UPD2: Maybe there is still hope for me, if I'll use .NET FRAMEWORK from inside a container ?
https://hub.docker.com/_/microsoft-dotnet-framework
I know how to use Docker. It will be possible to use it in my Rider ? I don't get it.
This answer essentially has what you're looking for. There is an issue in recent mono packages for some distributions that causes Rider not to have a proper reference to the mono libraries.
JetBrains Rider not detecting mono or Unity API
I've tried this on Debian 11 and it works as expected. I also use an Ubuntu machine and I didn't have to do this. I'm not entirely sure why, all I know is that some distros need the override set in in order to work. I use KDE Plasma and used their method of setting environment variables. There's a million ways to do that, check Majaro's documentation for what's best for your system.
**Before reading below, be aware that we're talking about legacy software and there's no guaranty that Mono will work in the future since it has been superseded by .NET (core). New development should be done there rather than Mono/.NET Framework unless you really need to. Just be aware it's legacy at this point and ymmv.
As for the other comment that there is no .NET Framework on Linux, that's not completely true. Mono is the .NET Framework implementation for Linux and macOS. It supports a large portion of the .NET Framework that exists in the Windows version, however it has some drawbacks.
For instance, WinForms is only partially supported and extremely buggy. WPF will not work at all.
ASP.NET can be run under Apache with a plugin, however it doesn't support all of the frameworks that you can use on Windows. For modern .NET web development on non Windows platforms, .NET 5+ should be used.
Another weird one is that the Console.Beep() method works unreliably. The Console.Beep(int frequency, int duration) method also doesn't work on macOS at all.
Other than those examples, there's other things that won't work which are mainly things that rely directly on the Windows API though it's possible to run .NET in some capacity under WINE. This isn't recommended though. Anything that uses COM will not work as well. It's also practically impossible to use a printer so that's probably out.
You can review https://www.mono-project.com/docs/about-mono/compatibility/ for a better list of what is and isn't supported.
For console applications, mono works quite well. Just be aware that not everything will work.
Good luck!
You should create a console application by choosing "Console Application" under ".NET Core".
I wonder why Rider guys decided to show the projects under ".NET" to mess things up. Beginners like you won't be easy to know what they are and how to run them on non-Windows machines.

Can I use MONO to create a program that runs without the .NET framework being installed?

I need to write something for a Windows XP embedded computer, which does not have .NET installed.
I already have written the program in .NET, so I'm wondering if there's a way to make it run without .NET?
Perhaps using MONO to create some all-in-one .exe?
Thanks for any thoughts / ideas!
Take a look at mkbundle from Mono:
The resulting executable is self contained and does not need the Mono
runtime installed to run.
When running managed code - .NET/Mono assemblies, a framework is required to be installed. Depending on your dependencies, you may be able to run under mono without modification. Mono is compatible with Windows XP. Parts of .NET are not compatible with Mono such as WPF.
Firstly make it run without .NET is an error concept. .net program must run at .net Environment. You can say without .netframework.
If you want to use .netframework, may these can help you:
http://blogs.msdn.com/b/embedded/archive/2007/03/23/deploying-net-framework-3-0-desktop-distribution-package-on-windows-xp-embedded-sp2-runtime.aspx
http://social.msdn.microsoft.com/Forums/en-US/93e39489-2c61-439d-aa3f-865195fb79d7/net-framework-35-on-windows-xp-embedded?forum=embeddedwindowscomponents
Or you can setup monoruntime on this os

MonoDevelop for .NET application on Linux

I need to develop C# applications, but i use Linux (ubuntu), I found MonoDevelop, but I don't understand if i can write .NET applications from Linux to use on Windows, so the development on linux and the execution on Windows. are them compatible?
On the Mono website I found:
Mono is a software platform designed to allow developers to easily
create cross platform applications.
What does it means? Can I write on Linux c# applications that can run wherever the .NET framework is installed?
Thank you for the clarification
Any C# code you compile from MonoDevelop or anywhere else can be run on any platform with either Mono or the .NET Framework. As long as the linux system has Mono installed, it can run any compiled C# application, including .exe's copied from a Windows machine.
The reason for this is that when you compile a C# application, it's not being compiled to native system code, it's being compiled to CIL. When you run the program, it automatically JIT compiles your code for the system it's running on, leaving the original executable intact. Both the .NET Framework on Windows and Mono on everything else can read and compile the CIL bytecode.
And one thing to keep in mind, Mono doesn't have the entire .NET Framework stack available. Almost all of the BCL is intact, but libraries like WPF are not available on Mono. Mono recommends you use GTK# for your GUIs.
Yes, you can use mono to create .NET applications that will run on Linux, Windows and Macs.
Mono is:
It is an open source implementation of Microsoft's .Net Framework based on the ECMA standards for C# and the Common Language Runtime.
This means that so long as you don't write code that is platform specific, you can run it on all platforms that .NET can run on. (So, instead of concatenating paths using \ or / you use Path.Combine, and instead of hardcoding linebreaks as \n you use Environment.NewLine and such).
Another advantage is that the mono development tools are free. (see: http://www.mono-project.com/Main_Page)
You can indeed write .NET code in Mono on Linux and run the application on Windows, Mac OS X and Linux.
But keep in mind that the full .NET stack is not available for you. Most noticeable is the complete lack of WPF support.
You can as long as you are careful to not assume anything about things like file system layout and use libraries that are also portable. Graphical interfaces in particular are problematic: Windows.Forms looks alien on Linux, and Gtk may feel a little out of place on Windows.

Can't get Microsoft.VisualBasic.dll for Mono 2.10

I've been trying to port a .NET library built on/for Windows to Ubuntu 11.04 using Mono. The library uses .NET 4.0 so the version of mono (2.6.7) that is standard with Ubuntu 11.04 doesn't cut it. Specifically, I'm trying to use Microsoft.VisualBasic.Devices.Computer.Info.TotalPhysicalMemory. I've searched high and low for packages or parallel build scripts that install Microsoft.VisualBasic.dll, but none of them do.
Ideally I'd like to find a way to get the best of both worlds, Mono with .NET 4.0 support and Microsoft.VisualBasic so that the code won't have to be modified. I would settle for an alternative that uses another method (although, the P/Invoke method I saw in this previous post does not appeal to me).
Any help is greatly appreciated.
It looks like getting VB.dll won't help you either. This method is not implemented in Mono:
https://github.com/mono/mono-basic/blob/master/vbruntime/Microsoft.VisualBasic/Microsoft.VisualBasic.Devices/ComputerInfo.vb
You could try to fool Cudafy by creating your own version of the DLL.
Use reflector or check here to see the interface
https://github.com/mono/mono-basic/blob/master/vbruntime/Microsoft.VisualBasic/Microsoft.VisualBasic.Devices/ComputerInfo.vb
You can use a performance counter on Mono to actually get the amount of memory;
var pc = new PerformanceCounter("Mono Memory", "Total Physical Memory");
var mem = pc.RawValue();
You can use the MoMA tool to check how compatible mono is for your project.
In your particular case the method you need isn't implemented, if that's the only thing preventing your project from working, you can implement it, and build and provide your own MS.VB.dll until mono releases a version with the change in it. Once you've built mono-basic it's simple to install on any machine (with mono already installed), just run:
gacutil -i path/to/MS.VB.dll
and the dll will be installed into the gac.

Categories