Embed URL’s directly into your C# code

Ok, so this isn’t strictly a language feature and it’s not terribly useful either, but it did cause me to do a double-take when it compiled with no errors.

I had cut and pasted a URL into the block of code I was currently working on, so I could refer to it more easily. However, I accidentally left it there when I compiled the program, and to my dismay it compiled without complaint! Take the following contrived code block for example: 

public int Add( int x, int y )
{
    int result = x + y;
    http://windowscheerleader.com/
    return result;
}

The URL just dumped into the middle of a block of code should certainly have caused some kind of compiler error, right? Or should it…?

In C# (and C++), everything after the “//” is treated as a comment and is therefore ignored. So the compiler will never see “windowscheerleader.com/”. But that still leaves us with “http:” in the middle of the code.

However, it turns out that the compiler thinks the “http:” is a label – the destination for a goto command! In other words, we could write another silly function like the one below, and the compiler would be perfectly happy with it!

public int GetSmallerValue( int x, int y )
{
    if ( x < y )
        goto http;
    return y;
    http://windowscheerleader.com/
    return x;
}

As far as the compiler is concerned, we have a label followed by a comment, which is perfectly valid. As I said earlier, this isn’t terribly useful (unless you want to embed uncommented URL’s into your code for some reason), but I did find it interesting. One word of warning though – since the “http:” is a label, you can only use this “technique” once in each scoped block or the complier will get upset with you!

StreamRipper on Vista

StreamRipper is an excellent open-source plugin for Winamp that allows you to record streaming mp3 directly to your hard drive. It’s very similar to recording songs off the radio onto audio cassette tapes, which is a technology that some younger readers my be unfamiliar with, but it worked well enough at the time.

StreamRipper has a very nice feature where it creates a “relay stream” that you can listen to. Instead of creating two separate streams (one for Winamp for you to listen to, and another for StreamRipper to record from), you can have StreamRipper create a “relay Stream”, which his cuts down on the required bandwidth and allows you to listen to the same stream that you are recording.

I’ve always had a problem getting StreamRipper to create the relay stream properly on Vista, and like everyone else, I was all too keen to blame Vista for Winamp’s inability to connect to the relay stream. However, it turns out that everything is working exactly as it should, and there is a very easy way to get a working relay stream in Vista…

Instead of connecting Winamp to http://localhost:8000, which is the default host and port for the relay, you have to use the local loopback IP address of your local machine instead. In other words, connect Winamp to http://127.0.0.1:8000 and it will work perfectly!

The reason for this, is that localhost under Vista resolves to an IPv6 address and not IPv4 address that previous versions of Windows used. StreamRipper only understands IPv4, and Winamp is apparently trying to connect to it using IPv6. By specifiying the local loopback IP address of your machine explicity, rather than referring to it by name, you are forcing the use of IPv4, which means everything works as it should.

Happy ripping!

Move or Copy?

Yesterday I was unzipping a large (1.7Gb) file on my computer, when the following message box appeared:

Apart from the fact that the responses don’t actually make any sense with regard to the question, I wasn’t even using Internet Explorer to copy the files! I had IE open, but the zip file was being extracted from Windows Explorer…

Anyway, the archive was extracted just fine and everything seems to be working normally again, so I guess there’s nothing really to see here. I just thought it was curious.

Spore vs The Force Unleashed

Just a quick note to let Electronic Arts know that I won’t be buying Spore – at least until they remove the draconian DRM from it. I’m not paying $50 for a game I can only install 3 times, even if I uninstall it after each new install. What happens when the activation servers go offline in a few years?

Anyway, enough people have written about this, including bombing the Amazon reviews for the game, that I don’t really have much to add. Other than the fact that I won’t be pirating it either. Downloading and playing a cracked version will only enforce EA’s view that the game didn’t sell due to piracy – and not becaue of the ridiculous restrictions placed upon it.

So I bought my son Star Wars: The Force Unleashed for his birthday instead. It’s not a very deep or challenging game, but until you’ve seen a seven year old jumping up and down on the couch while cutting down clone troopers with a Wii remote, using his force powers to blow everything up – well, you just haven’t lived!

Chrome

Yeah, just what web developers have been waiting for – one more browser to add to their test bench. Yay!

Well, I’m not going to talk about it here, since plenty of other people already have it covered. I really just wanted to get a post up, since I haven’t written anything for 3 months. I’ve been too busy playing Hellgate:London…

Smooth Move, Warioware

At the behest of my wife I have recently purchased a Nintendo Wii. Actually, she wanted to get the Wii Fit, but since the Wii is somewhat of a pre-requisite, we had to get one first.

Warioware Smooth movesAnyway, I’ve been keeping my eye out for some good party games that the whole family can enjoy together, when I came across this list of the best ever Wii games, on Gamespot. As you can see, Warioware Smooth Moves scores 9.1 out of 10 and is even credited with editors choice. Reading through the review, it sounds like the perfect party game – fun, innovative, hilarious, easy to play etc.

However, to play the multiplayer game (for which this game comes so highly recommended) you must first complete the single payer game! In what universe does this actually make sense?

I came home from work yesterday, showed the game to my kids and of course they immediately wanted to play it. I fiddled around with it for a bit, but couldn’t get the multiplayer game to activate. I finally went to the internet and discovered the amazing truth – that you must complete the single player game to unlock the multiplayer game!! So there we all are, crowded round the TV and looking forward to a night of hilarity and the game is useless. Well, unless everyone wants to watch someone else play through it first.

The really daft part of this is that whoever completes the single-player game will have an innate advantage over everyone else who has never played it! I’m really finding it hard to understand why Nintendo decided to cripple what is essentially a party game, by forcing you to play it alone first.

I’m seriously thinking about taking it back to the store for a refund.

Vista SP1, where are you?

Windows Vista ServicePack 1 was released a few weeks ago, and I have been eagerly waiting for it to show up in my list of updates to be installed. Several of my friends have already installed it, but I am still waiting for it to appear…

So I decided to do a little research and discover exactly why I wasn’t being offered the upgrade. Of course, I could have just downloaded it and installed it myself, but I was curious as to why my Windows Update didn’t appear to be working.

Well, it turns out that there are a number of reasons why I wasn’t seeing SP1 as an available upgrade. After reading the support article, poking through the version numbers for a bunch of drivers I discovered that I had a “problematic” driver – “SigmaTel Stwrt.sys – version 6.10.5511.0 or earlier for x86 computers” to be exact.

So the first thing I do is head over to Sony‘s web site and look for an updated driver, but of course it doesn’t exist. The most recent driver on offer is over a year old and is the one I already have that is preventing SP1 from installing.

Second stop is SigmaTel‘s website, and a Vista Support Update link – now we’re getting somewhere! But hang on – this just tells me to go to my PC vendor and get an updated driver from them! It appears that SigmaTel has been bought out by IDT and they are no longer supporting the audio chipset in my laptop.

It would seem that I cannot install Vista SP1 on my laptop, due to a single “problematic” driver that is no longer supported by the device manufacturer (SigmaTel/IDT) or the OEM (Sony). What exactly does “problematic” mean? Will my computer fail to boot, go Bluescreen of Death on me or worse? Or is it something I really couldn’t care less about, like the sound card won’t reinitialize correctly after resuming from hibernation? Will it work? Do I dare install it, only to find out that I’ve just turned my laptop into a useless brick?

Unfortunately, it’s rather difficult to pin the blame on a single entity. Is it Microsoft‘s fault for failing to write a proper service pack? Perhaps they had a very good reason, such as a security issue and the driver no longer works after the issue was fixed? Is it SigmaTel‘s fault for selling the chipset to another company? Is it IDT‘s fault for not writing an up to date driver? Or is Sony to blame, since they are using the technology in their computers and should provide an OEM driver?

At the end of the day, it doesn’t really matter who is at fault – the customers are getting the short end of the stick. And this doesn’t just affect Sony customers, but also Dell, HP and any other vendor that used these very popular audio chipsets.

But the worst part is not that this problem exists, but that Windows Update does not even show SP1 as an option. Hundreds of users are not even going to know that there is a service pack available, let alone to try to update their drivers first! There is no indication whatsoever that a service pack is available, leaving many people completely in the dark.

It’s really quite difficult to Cheerlead things like this. I just hope it gets sorted out soon, but I’m not going to hold my breath…

And in the meantime, there are hundreds of customers – including myself  – that cannot install Vista SP1.