I would like to start learning C# and really want to code in it on my raspberry pi. However, I can't find a way to get C# onto my pi. Does anyone know how to do this? I have the Raspberry pi 2 model B. Thanks for your help.
5 Answers
'Mono' is a toolset and C# used to create “.NET” compatible programs based on Linux, and the resulting binaries are fully compatible with Microsoft.NET.
start from the Basic programs given in the link here which will definitely help you to understand ´mono´ better.
In Addition I have also used the documentation from the mono developers this which was very useful.
-
For this to work as a useful answer, can you please elaborate on the solution provided in the link? I.e. give a summary of the information and/or the next steps to take so that the OP does not have to click on the link to find out what your answer is about.– Phil B.Jan 25, 2016 at 12:54
-
1The Details in the link are sufficent for the user to start from the Basics. I thought the user just needs Information to the question he posted. It doesn't make any sense to provide again a summary of the link. I don't understand the downvote for this!!– qwertyJan 25, 2016 at 13:07
-
2Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. See here Provide context for links Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline.– Ghanima ♦Jan 25, 2016 at 13:19
-
1
-
1To make this answer even more usefull it is best to use
Jessie
as the Mono packages are MUCH more up to date. wheezy is really out of data. You can also use Xamarin repository to get bleeding edge or RC, if you looking for the newest and most stable for things like webservers, threading and GUI Jan 25, 2016 at 17:32
I think you need to clarify what you are trying to achieve, but hopefully this will help.
Firstly, C# is a language. You write programs in C# and these will run on the .NET framework. It is the .NET framework that must be installed on your device for your C# program to run.
Since last year you have the option to install Windows 10 IoT Core on your Raspberry Pi 2. This is new technology so it is being actively developed and improving at a rapid pace, but there are a few limitations. You will need to use Visual Studio (Community Edition "free" version is fine) and you can currently only connect to a Pi2 from a Windows 10 computer. If you have these, then IMHO this is the best way to get C# running.
Alternatively there is the open source Mono Project which will run on Raspbian (and other flavours).
It will depend on your current skills as to which of these approaches will be best for you.
-
Using Visual Studio is great because of the debugging feature that is enabled when using IoT. There are also extensions for Visual Studio that enable you to debug C/C++ code on Raspbian (VisualGDB), now that is a killer extension that I use allot, in my favourite IDE :) Jan 25, 2016 at 17:35
-
1Windows 10 IoT Core appears to be now available on Raspberry Pi 3: developer.microsoft.com/en-us/windows/iot/getstarted/prototype/… Mar 14, 2018 at 13:27
The answers referencing Mono are largely correct, but I would recommend as an alternative checking out .NET Core instead. .NET Core supports Raspbian as a deployment target. For more detailed information, check out the blog entry at https://blogs.msdn.microsoft.com/david/2017/07/20/setting_up_raspian_and_dotnet_core_2_0_on_a_raspberry_pi/, but to chunk out the "how to set it up" portion, you can obtain it by doing the following:
- Run sudo apt-get install curl libunwind8 gettext. This will use the apt-get package manager to install three prerequiste packages.
- Run curl -sSL -o dotnet.tar.gz https://dotnetcli.blob.core.windows.net/dotnet/Runtime/release/2.0.0/dotnet-runtime-latest-linux-arm.tar.gz to download the latest .NET Core Runtime for ARM32. This is refereed to as armhf on the Daily Builds page.
- Run sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet to create a destination folder and extract the downloaded package into it.
- Run sudo ln -s /opt/dotnet/dotnet /usr/local/bin` to set up a symbolic link...a shortcut to you Windows folks 😉 to the dotnet executable.
- Test the installation by typing dotnet --help.
You can use any text editor to edit the C# programs and I have heard that VSCode will install, but I haven't been successful in getting that running yet.
Install C sharp shell
$ sudo apt-get install mono-csharp-shell
Install MonoDevelop which is an IDE to help run C# on Pi
$ sudo apt-get install mono-runtime
$ sudo apt-get install mono-complete
$ sudo apt-get install monodevelop