So, enough about C#, today we are on to cars.

My year 2000 Scooby (Subaru Impreza) has been suffering from the symptoms that I seems that most of them have at some point in their lives. The symptons are inconsitent delivery of power, with flat spots in acceleration (feels like you have stepped off of the gas suddenly) and surging.

It seems that there is a long list of things that can cause these symptoms (or very similar symptoms), that include:

  • failing lambda (oxygen sensors)
  • failing HT (high tension) leads
  • failing crank angle sensor
  • failing or dirty MAF (mass air flow) sensor
  • air leaks in various pipes

The most common one appears to be the last one, the MAF sensor (which measures the amount of air going into the engine). When the problems developed on my car I therefore checked the MAF sensor first.

When I pulled my MAF sensor it looked spotless, it was clean and I thought it was almost brand new. I ruled it out as a cause and plugged it back in.

Over the next month the symptoms got worse and my local Subaru dealer had a couple of failed attempts at diagnosing the problem (the ECU wasn’t reporting any fault codes, which didn’t help).

They finally fixed it this week, after having the car for three days to give them time to track it down. The main cause of the problem? Yes, you’ve guessed it, it was the MAF sensor failing.

So if I had just replaced my MAF sensor when the problems started (£60 and 10 minutes work) I could have saved myself £200 in labour costs.

So, next time something like this happens I’ll think carefully about just replacing the MAF sensor before looking at other things. Some Scooby owners replace their MAF sensor every year as a preventative measure (it seems that the MAF sensor on the “classic” Impreza is a fragile item), not sure I’ll go quite that far.

I had a problem today when trying to call a C# component from Classic ASP. When I called a method in the C# component I got the error “class doesn’t support automation”.

This was very puzzling because I had already prototyped this to make sure that I could sucessfully call C# from Classic ASP (using both VBScript and Javascript). The C# assembly and class were marked as COMVisible and I had used regasm to register the DLL with COM.

Through a process of elmination I worked out that the problem was that the method had some boolean parameters that I wasn’t initialising with boolean values in my ASP code. I hadn’t completed my ASP page, so the variables being passed to the booleans were in fact set to empty strings.

So the error message is very misleading, as it has nothing to do with the class you are calling not supporting automation.

Once I initialised my booleans correctly the problem went away, which made me a very happy bunny ;)

I ran into a problem today, with VS.NET and references between projects. In the development project that I am working on at the moment we have two main C# classes that are called by various classic ASP pages and client side code.

Because both of the classes have attendant helper classes and they are logically separate (and also being coded by two different people) we have them in two separate VS.NET projects. Until today it all worked fine.

Today however we broke things. Class A was already calling Class B, but in a change today we decided that Class B then had to call back into Class A.

Until today the project for Class A had a reference to Class B, not the other way around. When we tried to add a reference to Class B’s project back to Class A’s we got an error complaining that it could not be done because it would create a circular reference.

I guess the problem is that the two projects get compiled to two separate assemblies and that one can’t be built before the other because they both embed meta data from the other.

We scratched our heads for a while, it didn’t help that it was at the end of the day, and came up with the following options:

  1. move the two classes into the same project (this would be less than ideal two people need to work on the code at the same time and it would also stop us from shipping one of the components without the other)
  2. abandon the VS.NET build process for these two components and build them together into the same assembly using the commandline tools (still has the problem of not being able to ship them separately and complicates the build/debug process)
  3. create another class that sits above A and B that makes calls into A and B (A still then needs to call B, but at least B doesn’t then have to call A)

At the moment it looks like we are going to go with option 3, which means some more work for me tomorrow. I hope I can do it cleanly without duplicating code from A and B into the third class.

So, something to look out for in my next .NET project (in our defence this project wasn’t really designed with .NET in mind).


I have found another and I believe, better solution. I have created a interface in a separate project (that matches Class A’s current public interface). Class A can then implement the interface and pass a reference to itself cast as the interface when it calls Class B. Class B can then call back to into Class A via the interface.

Class A and B then need reference to the project with the interface, but crucially Class B doesn’t need a reference to Class A.

Why are there no USB based WiFi adapters that work with Mac OS X?

I bought a Mac Mini earlier this year, much to the surprise of my PC loving friends. I needed it for a contract I was working on, porting Gigajam’s music tutition software to the Mac.

When I bought it I opted to get the version without built-in WiFi and Bluetooth, a decision I now regret. I now want to use it in out living room to play video files on the TV (thanks to it’s almost silent operation it is perfect for this).

I don’t want to run Ethernet cables as it would involve drilling through the wall into the garage. So I thought I would WiFi enable the Mac.

I thought it would be easy, a quick trip down to PC World (I know, I know, but on a Sunday afternoon it is the only place open) for a USB WiFi adapter. But no, I couldn’t find any USB WiFi adapters that claimed to support Mac OS X.

After some searching on the net I finally found one that supposedly works with Mac OS X. It is the DLink DWL-122, though you have to download the drivers from the chipset manufacturer’s website. Some comments on the MacOSXHints site are people having problems getting these drivers to work.

I was about to buy one when I realised that it was only a 802.11b device, which for streaming video over SMB isn’t going to cut it. I really need a 54G device :(

So I guess I’ll either have to get an Ethernet-WiFi bridge or run a cable (or get an internal AirPort card fitted, but I think that would be the expensive option).

I have decided that when using the .NET framework’s XML classes it is a bad idea to pass XmlDocument objects to methods. It is a much better idea to pass the document’s root XmlNode object instead.

The reason for this is that at some point down the line you might, as I have today, decide that you need to use one of your methods on a sub-set of a document. If your methods are setup to receive XmlDocument objects then you suddenly have a lot of code to refactor to allow you to pass an XmlNode object from an arbitary level in the document instead.

…insert useful example here…

Passing the XmlNode object is just as easy as passing the document and you can still access the document via the XmlNode.OwnerDocument property anyway.


I discovered a serious problem with this approach today. The XmlNode object that represents the top level of the XmlDocument returns null from its OwnerDocument property! Doh!

How annoying is that? I can see how logically the node that represents the document itself doesn’t really have an owner document. However it seems a very pureist way of looking at it and it isn’t a very useful design decision for someone using the class.

So all the methods on which I carefully replaced the XmlDocument parameters with XmlNode parameters have now had to gain an XmlDocument parameter as well, otherwise there is no way to insert new nodes and elements.

Effective C# is a great book.

If like me you have be coding C# for a while (in my case nearly two years) and are beginning to feel that you have C# completely sussed then this is the perfect book for you. Thanks to this book I now know that there are many more subtlies hidden away in C# and the .NET framework than I first thought.

The book is subtitled “50 Specific Ways to Improve Your C#” and is separated into 50 topics of varying length. The title is slightly misleading though, as many of the topics apply to coding in any .NET language rather than just C#.

I have read at least half a dozen books on C#/.NET and none of them did a very good job of explaining the full implications of the differences between value and reference types. In this book Bill Wagner clearly details the differences between the two and exactly what that means for you class and structure design.

Bill’s descriptions of the issues are very clear, even when he is talking about things as potentially confusing as the relationships between ReferenceEquals(), static Equals(), instance Equals(), operator== and the dreaded GetHashCode().

As an example of one of the subtlies that the book covers, take a look at this code:

int [] foo = new int[100];

// Loop 1:
foreach (int i in foo)

// Loop 2:
for (int index = 0; index < foo.Length; index++)

// Loop 3:
int len = foo.Length;
for (int index = 0; index < len; index++)

So, which loop do you think it fastest? Loop 3 you say?

Nope, the fastest is Loop 1 and Loop 3 is in fact the slowest. To find out why you’ll have to read the book ;)

If you think that you know all there is to know about C# then buy this book…

So, I’ve finally joined the rest of the world and setup a blog.

Why ?

I’m planning on using this mainly as a personal notepad, to record things that I do and stuff that I might like to remember. I don’t expect anyone else will be interested in reading it, though there might be the occasional review of a techie book posted here.

I was spurred on to do it because I have just setup a blog for one of our friends (Satyalila) and I was amazed how quickly she made good use of it.

Most of the posts are likely to be new stuff that I have learnt about whichever new bit of the .NET framework I am using today ;)

« Previous Page