MoinMoin Logo
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • Start
  • Sitemap
Revision 15 as of 2023-05-26 14:08:05
  • CSharp
  • mono

mono

An open source, cross-platform, implementation of C# and the CLR that is binary compatible with Microsoft.NET

SlackBuild

   1 su
   2 cd /tmp
   3 wget http://slackbuilds.org/slackbuilds/14.0/development/mono.tar.gz
   4 tar xvzf mono.tar.gz
   5 cd mono
   6 wget http://download.mono-project.com/sources/mono/mono-2.11.4.tar.bz2
   7 ./mono.SlackBuild
   8 installpkg /tmp/mono-2.11.4-x86_64-1_SBo.tgz 

Package 64: mono-2.11.4-x86_64-1_SBo.tgz

  • 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: gtk-sharp-2.12.10-x86_64-1_SBo.tgz

  • 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: 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

  • 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

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

   1 .
   2 |-- bin
   3 |   `-- hello.dll
   4 |-- build.sh
   5 |-- index.aspx
   6 |-- index.aspx.cs
   7 `-- web.config

index.aspx

   1 <%@ Page language="c#" CodeBehind="index.aspx.cs" Inherits="helloworld.Index" AutoEventWireup="false"%>
   2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   3 <html xmlns="http://www.w3.org/1999/xhtml" >
   4 <head runat="server">
   5     <title>Hello Page</title>
   6 </head>
   7 <body>
   8   <div>
   9     <form method="post" runat="server">
  10       <asp:Label id="lblx" runat="server"></asp:Label>
  11       <asp:Button id="btnx" runat="server" onclick="btnx_Click" Text="Click me" ></asp:Button>
  12     </form>
  13   </div>
  14 </body>
  15 </html>

index.aspx.cs

   1 // xsp --applications /helloworld:.
   2 // http://localhost:9000/helloworld/
   3 
   4 using System;
   5 using System.Web.UI.WebControls;
   6 using System.Configuration;
   7 
   8 namespace helloworld
   9 {
  10    public class Index : System.Web.UI.Page
  11    {   
  12       protected Label lblx; 
  13       protected Button btnx;
  14       
  15       protected override void OnLoad(EventArgs e)
  16       {          
  17          base.OnLoad (e);
  18          Console.WriteLine("OnLoad");
  19          lblx.Text = "Beerrrr ...";
  20   
  21          if(!IsPostBack){
  22            ViewState["counter"]=0;    
  23            var appSettings = ConfigurationManager.AppSettings;
  24            Console.WriteLine(  appSettings["setting1"] );
  25          }
  26       }
  27       
  28       protected override void OnPreRender(EventArgs e)
  29       {          
  30          base.OnPreRender (e);
  31          Console.WriteLine("OnPreRender");
  32       }      
  33       
  34       protected void btnx_Click(object sender, EventArgs e)
  35       {
  36         Console.WriteLine("Btnx clicked");  
  37         int val = (int) ViewState["counter"];
  38         val++;
  39         lblx.Text = String.Format("Pint time ! {0}",val);
  40         ViewState["counter"] = val;
  41       }
  42    }
  43 }

web.config

   1 <?xml version="1.0" encoding="utf-8"?>
   2 <configuration>
   3     <system.web>
   4         <customErrors mode="Off"/>
   5         <httpModules>
   6         </httpModules>
   7     </system.web>
   8 
   9     <appSettings>
  10       <add key="setting1" value="asdf"/>
  11     </appSettings>
  12 </configuration>

build.sh

   1 #!/bin/sh
   2 mkdir -p bin
   3 mcs *.cs -r:System.Web.dll -r:System.Configuration.dll -r:System.Web.Services.dll -target:library -out:bin/hello.dll
  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01