Make cassini work with .net 2

Recently I have been playing with Monorail the port of Ruby on Rails to C#/.NET
I needed to get Cassini to work with .NET 2

The initial version of Cassini that I have was built against  

I added the following as CassiniWebServer.exe.config 

<?xml version =”1.0″?>
<configuration>
<startup>
<requiredRuntime version=”v2.0.50727″/>
<supportedRuntime version=”v2.0.50727″/>
</startup>
</configuration>

This is all that was required. 

Paging in sql server

This may not be the most elegant paging code for sql server but it solves the problem:

create database foobar
go

use foobar
go

drop table test
go
create table test(id int not null, name varchar(10) not null, primary key(id))
go

insert into test values (1,’one’)
insert into test values (2,’two’)
insert into test values (3,’three’)
insert into test values (4,’four’)
insert into test values (5,’five’)
go

select top 2 *
from test  
where id not in (select top 2 id from test)
order by id
go

 

Collection of OO Frameworks

There are a number of useful OO Frameworks that allow us to avoid reinventing the wheel:

Castle Project

This project acts as a container for a number of other Open Source Projects

  • Containers – This provides inversion of control services that allows an application to consist of distinct interfaces
    • Facilities
    • Components
    • Services
  • Monorail
  • Active Record
    • NHybernate
  • Dynamic Proxy

CSLA.NET

Microsoft Enterprise Libraries

Genghis

Ubuntu 6.06 : Upgrade instructions

Ubuntu 6.06 (Dapper Drake)   is out on 1st June 2006.

Here are the simplified instructions for upgrading from 5.10 (Breezy Badger) 

 

The instructions for this are not very clear to the uninitiated so here is a simple version:

  • Open a console as root.
  • cd /etc/apt
  • chmod +wr sources.list
  • emacs sources.list
  • replace all references to breezy with dapper
  • If you want non-official packages uncomment the universe lines (remove the # characters)
  • save and close emacs
  • sudo apt-get update
  • sudo apt-get dist-upgrade

Wait and then you have a Dapper Drake system.

Castle : Inversion of control

The Castle Project is a collection of useful  C# tools

This is a sample application of the Castle using an App.config:

It demonstrates the use of Castle.Winsor to allow an app to specify behaviour.
This  could easily be used to switch logging handlers.

Here is the main source of the application:

 

using System;
using System.Collections.Generic;
using System.Text;

namespace CastleConsole
{
    using Castle.Windsor;                            // Castle.Winsor
    using Castle.Windsor.Configuration.Interpreters; //Castle.MicroKernel

    public interface ILogger
    {
        void Log(string msg );
    }

    public class LogToConsole : ILogger
    {
        public void Log(string msg)
        {
            System.Console.WriteLine(“The message was {0}”, msg);
        }
    }

    public class SecondLogger : ILogger
    {
        public void Log(string msg)
        {
            System.Console.WriteLine(“Second logger was {0}”, msg);
        }
    }

    public interface IExecute
    {
        void Execute();
    }

    /// <summary>
    /// This is a class that uses the logger
    /// </summary>
    public class ThreeExecutions : IExecute
    {
        /// <summary>
        /// This is used to store the logger interface
        /// </summary>
       
        ILogger _logger;

        public ThreeExecutions(ILogger logger)
        {
            _logger = logger;
        }

        public void Execute()
        {
            _logger.Log(“One”);
            _logger.Log(“Two”);
            _logger.Log(“Three”);
        }
    }

    /// <summary>
    /// Summary description for CastleConsoleTestClass
    /// </summary>
    public class CastleConsoleTestClass
    {
        static void Main(string[] args)
        {
            try
            {
                // This is the initial version
                //IWindsorContainer container = new WindsorContainer();
                //container.AddComponent(“logger 2”, typeof(ILogger), typeof(SecondLogger));
                //container.AddComponent(“logger”, typeof(ILogger), typeof(LogToConsole));           
                //container.AddComponent(“execute”, typeof(IExecute), typeof(ThreeExecutions));
               
                // This one uses app.config
                IWindsorContainer container = new WindsorContainer(new XmlInterpreter());
                IExecute service = (IExecute)container[“execute”];
                service.Execute();

            }
            catch(Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
           

            System.Console.ReadLine();
        }
    }
}

 

Here is the app.config file:

 

<?xml version=”1.0″ encoding=”utf-8″ ?>
<configuration>
  <configSections>
    <section name=”castle”
         type=”Castle.Windsor.Configuration.AppDomain.CastleSectionHandler,
                   Castle.Windsor” />
  </configSections>

  <castle>
    <components>
      <component id=”logger” service=”CastleConsole.ILogger, CastleConsole” type=”CastleConsole.LogToConsole, CastleConsole”  />
      <component id=”execute” service=”CastleConsole.IExecute, CastleConsole” type=”CastleConsole.ThreeExecutions, CastleConsole” />
    </components>
  </castle>

</configuration>

 

If you replace the first line of the components section with:

  <component id=”logger” service=”CastleConsole.ILogger, CastleConsole” type=”CastleConsole.SecondLogger, CastleConsole”  />