Raspberry Pi and C#

Can I run C# code on the beast?

Here are my notes from installing the OS to running a trivial C# application.

Ignore greyed text - they are blind avenues I took, and you should not follow.

Installing

Preparing an SD card

Google for "Raspberry Pi Fedora Remix" and you will find instructions.

The zip file must be extracted before you run the installer.

Logging on

You’ll be asked for an administrator password; and a user and associated password.

The display overscans on the 46" Sony Bravia  KDL-46W4500

Prepare a config.txt file so you can see the entire screen.
Here’s the contents of that file – use notepad from within Windows to create it – far easier than “vi” the vile editor.

overscan_left=80
overscan_right=80
overscan_top=40
overscan_bottom=40

From Windows place the file in root of the SD card, and re-insert and reboot the RaspberryPi

Details on config.txt can be found here:

http://elinux.org/RPi_config.txt

Google for "RPi config.txt"

Installing mono

Use the terminal window LXTerminal

Type "su"

You’ll be asked for the admin password.

Now you are god!

Blind avenue 1

Now you can edit the SUDO file with
visudo
i
Insert before cursor
:x
Exit, saving changes
:q!
Exit and ignore any changes
just under the line that looks like the following:
    root ALL=(ALL) ALL
Add the following (replacing nick with your actual username):
    nick ALL=(ALL) ALL 

That seems to be a waste of time as you don't have to use sudo to download...and nor can you use apt-get

For those interested and using Debian based systems, you can install mono by typing:

sudo apt-get install mono-complete

you need apt-get... but I foolishly ...and just so simply, I installed Fedora (Debian based systems use apt-get)

What does fedora use in place of apt-get?

It uses yum
 
Yum
 
yum check-update

Blind avenue 2

yum install yumex
 
I’m using the graphical front end – and keeping an eye on the green trace on the processor usage graph.
Now run yumex
Open a user logon – lxterminal. (It forbids you to run as su!)
Yumex – and wait!
That seems to be a waste of time. Forget that.

Install Mono

yum install mono-core

Getting there!

Now that mono is installed...

compile a .cs file

mcs program.cs

and run it

mono program.exe

 

Here's the C# code:

using System;
 
class Program
{
    static void Main(string[] args)
    {
        int x = 0;
 
        while (true)
        {
            Console.WriteLine("" + x++);
            Console.ReadLine();
        }
    }
}