Archive for July, 2006


July 21, 2006

I’ve been trying to write some drivers lately (using Linux) – the problem has never really been understanding the code – its more been setting up a build environemment (pretty stupid huh)… Not really ever having been forced to use Linux I found it a bit of a mission – I’ve normally just used it for pretty standard stuff and only just to play with. Anyway, I tried setting up a few environments using various distributions (they worked fine – just not for making my own drivers – there was obviously something I was missing but I couldnt seem to get them to work…) but I seemed to find 1) they were bulky, and 2) even running make at the source tree level would cause it to blow up/would blow up when I tried to run the module build which I needed for making v2.6 kernel drivers. Finally I gave up and ran with gentoo.

I set this up inside a vm following the online instructions and it all went pretty smoothly. The only problem I had is that when I tried to compile the kernel using my own build options I wasnt sure what drivers the vmware’s virtual hardware needed – resulting in a little bit of a headache – although I learnt lots on the way which I was stoked about 🙂 – finally after a few builds I just went with the full blown build – but even that didnt work – grrr – after adding the flag “doscsi” (im running on sata drives) to the grub kernel boot line I managed to get it to kick off 😀 (I now need to go back and try this with my original “slim” buid)…

 Anyway – I’m now loving gentoo – straight off the bat everything compiled fine and the first driver I wrote worked first time – Yee yeeah! The only extra bit I chucked on there was the “vim” editor – just so that I could get some color syntax going on… the problem was that the vim package I emerged in using emerge didnt ship with the c and c++ syntax files 😦 – So I grabbed the main vim source (which has them :-)) and just manually copied them on… good times!

 So – anyone thats trying to write some drivers and is struggling a little off the bat – maybe this is the way to go 🙂 gentoo seems a little daunting at first (just because you configure everything) but honesly – just follow the online help and you cant go wrong 🙂


Subversion + .Net

July 21, 2006

I set up Subversion + continous integration (Cruisecontrol.Net) + testing (NUnit) + code analysis (NCover.Net) + VS2005 Subversion IDE integration on the weekend. Seems to be running pretty sweet. Why? Well its free – because I can 😛 – and its good to practise this stuff + I find on my little pet projects I seem to edit files and then sometimes need to rollback – now with some source control I can get back to where I was yesterday 🙂

I like the subversion model for editing files in a disconnected mode – makes it really good for working on stuff, when your out and about on some random machine, that may be offline for a while. Anyway, here’s all the bits that I used:

A 1 click subversion and subversion client setup:

or alternativelly: The main Subversion page: , and the TortoiseSVN install (subversion client):





Subversion VS IDE package: (this has a merge tool but maybe TortoiseMerge might be better – I havent checked it out…)

To get it all running I used the following in my ccnet server config (a snippet of the file):

<sourcecontrol type=”svn”>
   <executable>F:\Program Files\Subversion\bin\svn.exe</executable>
   <workingDirectory>F:\Program Files\CruiseControl.NET\server

    <executable>F:\Program Files\Subversion\bin\svn.exe</executable>
    <baseDirectory>F:\Program Files\CruiseControl.NET\server

    <buildArgs>checkout svn://ghost64/TestProject/trunk/ TestProject–username ccnetbuild –password *****</buildArgs>
    <executable>F:\Program Files\nant\bin\nant.exe</executable>
    <baseDirectory>F:\Program Files\CruiseControl.NET\server\TestProject\

     <file>F:\Program Files\CruiseControl.NET\server\TestProject\WorkingDirectory

     <file>F:\Program Files\CruiseControl.NET\server\TestProject\WorkingDirectory


I found I needed a task to pull the source and build it – the main source block didn’t seem to want to do it… I don’t know what that was about… anyway I just put in a task to get a working set and away it went. After that I had the main nant build task (where the build, tests, and coverage where run) and finally I merged all the results in :-). I edited the main environment path variable to include the paths to the nunit and ncover executables and then I could run the following from my nant file (actually this was in a batch file the nant script called out too – note TestLibrary was the name of the test project in the solution):

ncover.console nunit-console TestLibrary.dll //w .\TestLibrary\bin\Debug

By wrapping ncover around the nunit tests it has something to run against… you cant just run it against a raw dll – it needs something to be running the code – this way nunit will exectue the code so you can cover a dll.

Anyway, overall it seems to be running really well 🙂 Check it out some time!

NHibernate 1.2.0 Alpha

July 20, 2006

This has been out for a little while… but I just thought I’d post a couple of bits I noticed in going forward.

1) Find is being deprecated – the new query stuff seems to look pretty tight and makes it heaps better – gives the comfort of some compile time checks which we all love 🙂

2) You now need to supply an interface for each of your mapped classes (well this is what I seemed to have to do when I recompiled my solution and ran it up). Fortunatelly I already had interfaces for each of my mapped classes but I had to add the following to the mapping file (the little proxy bit):

<class name=”Mappings.Client,TestConsole” proxy=”Mappings.IClient,Mappings”  table=”[Client]”>

 That seemed to get me to a point where I could just run my app that I had originally written on 1.0.2 🙂 Hopefully that helps someone else out there get there 1.0.2 stuff running smoothly on the new build 🙂

NHibernate – Find not returning a result?

July 20, 2006

I was having an issue with NHibernate a while back (which I fixed a while back :-P) – anyway – here’s the problem and a hopeful fix if anyone else has come across the same thing. Maybe it might be something to go into the NHibernate base… Although I noticed with the new 1.2.0 Alpha release Find is being deprecated so maybe this comes a little late but anyway… It might be something you also want to patch in as I did (into the 1.0.2 release and the 1.2.0 Alpha releases – it still exists in the 1.2.0 Alpha release) 🙂

 The problem was when I did a search over a entity and the field I was searching on contained both full stops(.) and commas(,), even though I could see the entity in the database, it wouldn’t return it – it would always say the entity didn’t exist (if I escaped it – rightly so – the fields wouldn’t match) but if I didn’t escape it it would start throwing exceptions – arrrhhh. For example, say I was looking for a company with the name “BigCompany, United.” using Find – I would get nothing (escaped) or would blow up (unescaped). What was going on? Time to bust out the source code 😀

 Here’s the query at fault:

array = (ArrayList)session.Find(string.Format(“from Business.Mappings.Company as company” +
      ” where company.Name = ‘{0}'”,

The problem exists down in the parsing of the find string. When it comes across commas and full stops it tried (if it wasnt escaped) to cast it to a class in the solution – if it failed to cast it would blow up. Trying to modify the source as little as possible, so everything else will stay the same, (theres some code down in here that really needs to be tidied up by the NHibernate crew – sorry guys) I did the following:

In the class ReflectHelper, in the method GetConstantValue I moved the try up 2 lines – so the exception will get caught and then the code that calls this will fall back on the “else” action (to pass the string through as a parameter – what we want). Here’s the modified method:

public static object GetConstantValue( string typeName, string fieldName )
        System.Type clazz = System.Type.GetType( typeName, false );

        if (clazz == null)
            return null;
            return clazz.GetField(fieldName).GetValue(null);
    catch( Exception )
        return null;

Drop that guy in and away you go 🙂 The problem is that with any extension dll’s they are compiled against a signed version of the NHibernate dll 😦 (which I dont have) To get around this I either had to recompile the extension packages from source – or – using reflector dissassemble the dll back to source so I could recompile it – or – in one case (where reflector was throwing hissy fits on some generics that were being used) dump the dll out to msil – delete the signed part form the msil code (its near the top of the file) and then reassemble it – turned out to be a little mission but fixed a bug that was really bugging me… Was good to get it solved 🙂

If anyone finds this useful then let me know/forward on a link to the Nhibernate guys… 🙂

NHibernate – SQL2005 Dialect

July 20, 2006

I had a random error happening the other day when I was running an NHibernate based app I was working on – the problem was the error (“Unable to perform find”) would only happen every now and it wasnt consistantly occurring in the same place. After a bit of digging I read a few other people where having similar issues – running on Sql2005 – something to do with the way 2k5 works with returning rows in certain block sizes… anyway I grabbed the Sql2005 dialect, compiled a dll and chucked it in – as I said the errors seemed to be sparatic… hopefully its fixed now but if anyone else is having the same problem then maybe give this a shot 🙂

 I originally got the dialect file off a link from Ayende Rahien’s blog:

I can’t find it now but I’m sure google might show you some love 🙂 If not then flick me an email and I’ll send you a copy…

In the config file you need to change the dialect setting:

<add key=”hibernate.dialect” value=”NHibernate.Dialect.Extension.MsSql2005Dialect, NHibernate.Dialect.Extension” />

Note the fully qualified class name and then the assembly name (the assembly you compile containing the new dialect will need to be referenced in the project or signed and placed in the gac) 🙂