## page was renamed from mono
= mono =
An open source, cross-platform, implementation of [[CSharp|C#]] and the CLR that is binary compatible with Microsoft.NET

== SlackBuild ==
{{{#!highlight sh
su
cd /tmp
wget http://slackbuilds.org/slackbuilds/14.0/development/mono.tar.gz
tar xvzf mono.tar.gz
cd mono
wget http://download.mono-project.com/sources/mono/mono-2.11.4.tar.bz2
./mono.SlackBuild
installpkg /tmp/mono-2.11.4-x86_64-1_SBo.tgz 
}}}

Package 64: [[attachment:mono-2.11.4-x86_64-1_SBo.tgz]]

{{{#!highlight sh
su
cd /tmp
wget http://slackbuilds.org/slackbuilds/14.0/libraries/gtk-sharp.tar.gz
tar xvzf gtk-sharp.tar.gz
cd gtk-sharp
wget http://ftp.gnome.org/pub/gnome/sources/gtk-sharp/2.12/gtk-sharp-2.12.10.tar.gz
chmod 755 gtk-sharp.SlackBuild 
./gtk-sharp.SlackBuild 
installpkg  /tmp/gtk-sharp-2.12.10-x86_64-1_SBo.tgz
}}}

Package 64 bit: [[attachment:gtk-sharp-2.12.10-x86_64-1_SBo.tgz]]

{{{#!highlight sh
su
cd /tmp
wget http://slackbuilds.org/slackbuilds/14.0/development/mono-addins.tar.gz
tar xvzf mono-addins.tar.gz
cd mono-addins
wget http://ponce.cc/slackware/sources/repo/mono-addins-1.0.tar.gz
chmod 755 mono-addins.SlackBuild 
./mono-addins.SlackBuild 
installpkg /tmp/mono-addins-1.0-x86_64-1_SBo.tgz
}}}

Package 64 bit: [[attachment:mono-addins-1.0-x86_64-1_SBo.tgz]]

== Register .net/Mono for binfmt_misc ==
http://www.mono-project.com/Running_your_first_Mono_application
{{{#!highlight sh
modprobe binfmt_misc
mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
echo ':CLR:M::MZ::/usr/bin/mono:' > /proc/sys/fs/binfmt_misc/register
}}}

== XSP, ASP.Net mono web server ==
{{{#!highlight sh
cd /tmp
wget https://slackbuilds.org/slackbuilds/14.2/development/xsp.tar.gz
tar xvzf xsp.tar.gz
cd xsp
wget https://github.com/mono/xsp/archive/4.4/xsp-4.4.tar.gz
./xsp.SlackBuild 
installpkg /tmp/xsp-4.4-i586-1_SBo.tgz
}}}

=== Example site in asp.net ===
{{{#!highlight sh
.
|-- bin
|   `-- hello.dll
|-- build.sh
|-- index.aspx
|-- index.aspx.cs
`-- web.config
}}}

==== index.aspx ====
{{{#!highlight html
<%@ Page language="c#" CodeBehind="index.aspx.cs" Inherits="helloworld.Index" AutoEventWireup="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Hello Page</title>
</head>
<body>
  <div>
    <form method="post" runat="server">
      <asp:Label id="lblx" runat="server"></asp:Label>
      <asp:Button id="btnx" runat="server" onclick="btnx_Click" Text="Click me" ></asp:Button>
    </form>
  </div>
</body>
</html>
}}}

==== index.aspx.cs ====
{{{#!highlight csharp
// xsp --applications /helloworld:.
// http://localhost:9000/helloworld/

using System;
using System.Web.UI.WebControls;
using System.Configuration;

namespace helloworld
{
   public class Index : System.Web.UI.Page
   {   
      protected Label lblx; 
      protected Button btnx;
      
      protected override void OnLoad(EventArgs e)
      {          
         base.OnLoad (e);
         Console.WriteLine("OnLoad");
         lblx.Text = "Beerrrr ...";
  
         if(!IsPostBack){
           ViewState["counter"]=0;    
           var appSettings = ConfigurationManager.AppSettings;
           Console.WriteLine(  appSettings["setting1"] );
         }
      }
      
      protected override void OnPreRender(EventArgs e)
      {          
         base.OnPreRender (e);
         Console.WriteLine("OnPreRender");
      }      
      
      protected void btnx_Click(object sender, EventArgs e)
      {
        Console.WriteLine("Btnx clicked");  
        int val = (int) ViewState["counter"];
        val++;
        lblx.Text = String.Format("Pint time ! {0}",val);
        ViewState["counter"] = val;
      }
   }
}
}}}

==== web.config ====
{{{#!highlight xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.web>
        <customErrors mode="Off"/>
        <httpModules>
        </httpModules>
    </system.web>

    <appSettings>
      <add key="setting1" value="asdf"/>
    </appSettings>
</configuration>
}}}

==== build.sh ====
{{{#!highlight sh
#!/bin/sh
mkdir -p bin
mcs *.cs -r:System.Web.dll -r:System.Configuration.dll -r:System.Web.Services.dll -target:library -out:bin/hello.dll
}}}