Tuesday, 9 December 2008

Saving Space From C:\Windows\Installer

My home PC has been getting critically short of space recently - medium-term I need to get another hard drive for it but I need to take the case off first to see if I have a SATA connection and it's just a hassle.

I deleted a load of old data last weekend but it hasn't made the dent I was hoping for. I noticed my C:\Windows\Installer folder was huge, like taking up nearly 30% of the used space. I had a look to see it was full of MSI and MSP files, which I didn't know for certain whether I could delete or not. However I Googled the folder path and discovered the existence of MsiZap, which will clean up old Installer files from C:\Windows\Installer. You have to install it and then run 'MsiZap G' from a command line. ZAP! 14Gb gone and a much healthier hard drive :-)

I also discovered Defraggler this week, which might be a better defragger then the Windows XP one or not, but even if it isn't it looks much better as you can see your data moving around the drive as it gets defragged.

Thursday, 4 December 2008

SQLExpress and Compressed Files

Another of those things I'm blogging for future reference...

A little while ago I ran the Windows Disk Cleanup utility to recover some space on my hard drive. One of the things it did was go through my filesystem and compress files that I hadn't used in a little while.

I went back to some of those files yesterday - a WinForms project that I started ages ago that uses a SQL Express database - but when I tried to run the project I got strange errors in my DAL. I fired up SQL Management Studio and attached to my SQL Express instance, where things got even stranger. I had two databases showing, one with the path to my database and one with just the name of the database, but no plus sign next to them to expand them. Couldn't detach them, couldn't delete them. I did a bit of Googling and I saw a comment that SQL Express doesn't work with compressed files. Almost instantly I figured out what had happened - I uncompressed all the files in the folder and everything started behaving itself again.

Tuesday, 2 December 2008

Removing Items From the OutputCache

Today's learning point from StackOverflow:

Whilst it's clear that using output caching is a Good Thing, it can be a little counter-productive sometimes if a user changes some detail that invalidates the cached version of the page e.g. changing the price of a product, adding a new comment to a blog post. But as I've now discovered you can programmatically remove the cached version of the page by calling this static method on the Response stream:
Call HttpResponse.RemoveOutputCacheItem(myCachedUrl)

Looking it up on MSDN I discovered that this method has been present since .NET 1.1 and I've never come across it before!

Sunday, 23 November 2008

DDD7 - ASP.NET Scalability

I'd like to thank the organisers and attendees for giving me the opportunity to present 'This One Goes Up To 11, or How To Write Scalable ASP.NET' yesterday at DDD7 at Microsoft in Reading. It was my first time presenting at DDD, and I really enjoyed it. My session seemed to go quite well, there were a couple of demos I need to go through again to figure out why they didn't work, but overall I felt it was quite well received. All the sessions were videoed for Channel 9 , which is both quite exciting and means I'll get to see the sessions I couldn't get into :-)

A session I did get into was Phil and Dave's ASP.NET 4.0 runthrough. A lot of things are still under wraps, but one of the most useful things they demoed was the ability to set a control's ID and not have it munged with the control's container name when the html hits the browser. Which is nice. I feel validated in being unsure about MVC now I've heard that Phil's not keen on. It'll be interesting to see the new provider-based caching model when it arrives, especially as this will fit really well with Velocity. I'm not, however, at all sure about the new WPF-based Studio.

Edit: My slides and code samples are now available at www.philippursglove.com/ScalableASPNET.

Wednesday, 5 November 2008

Goodbye Windows 3.1

In amongst all the Presidential news going on today, this headline caught my eye: Closing Windows. Microsoft are ceasing to sell licences for Windows 3.1/11, the operating system I cut my teeth on (which probably dates me hugely although probably not as much as my recollections of loading programs off tape on my Commodore 64 - ah happy days).

I did my first professional coding on Win3.11 in 1997, using VB4.0 (ugh) for the client and Access 2.0 for the database (double ugh). Fortunately I didn't keep a copy of the code, although I think about reworking it occasionally as a web app with all I've learned since then.

I confess I had no idea MS still sold licenses for it as an embedded OS, though I guess it makes sense as a solid OS and if you have no need for a display etc it probably worked quite well.

Monday, 3 November 2008

Velocity CTP2

CTP2 of Velocity was announced at PDC last week - the announcement on the Velocity blog is here, you can download the bits here.

First thoughts are that they've done a lot of work since CTP1.

I installed this CTP tonight and ran up a super-quick demo, and it worked perfectly first time. And by perfectly I mean once I'd fixed my code. And by first time, I mean once I'd updated my web.config. This is good as it means all the problems were on my end, not theirs! (Same old story)

I'm going to have a bit more of a play today/tomorrow and will post some more details then. I've also got the PDC videos to watch.

Friday, 10 October 2008

How to Write Scalable ASP.NET

Like Barry, I got my email last night to tell me my talk on writing ASP.NET that scales sensibly (or indeed at all given the standard of code I've been reworking for the last two weeks) has been selected for inclusion at DDD7.

Suddenly I'm rather nervous and wondering if I can actually pull this off...

Thursday, 2 October 2008

.webinfo Files

Just one of those things I'm blogging so I can look it up when it happens again...

I converted one of our Web Application projects the other day from Visual Studio 2005 to Visual Studio 2008. It all built on my machine without any problem, but when one of my colleagues opened the updated project in 2008 on his machine it opened as a Website.

Eventually I compared folders between my machine and his, and I spotted a ProjectName.vbproj.webinfo file. I had a quick look at it in Notepad, the contents all looked correct but I had a sneaking suspicion that this was the culprit. I moved the file up a folder, and then re-opened the project in VS, just to see what happened. And it opened as a Web Application.

Thursday, 4 September 2008


Installed Chrome yesterday but haven't been able to do anything with it yet as it shares its' proxy settings with IE. Which sucks.
I'd much rather it managed its' proxy settings separately like Firefox and Opera.

Friday, 29 August 2008

IE 8 Beta 2: Rolled Back

I've had to roll back IE 8 Beta 2 :-(

I couldn't work out how to adjust the security enough to make our menus work in our own application, and also our intranet menus weren't working either. Looks like I'll have to have a look at the UserAgent string to fix that.

So I'm back on IE7, which I love.

Thursday, 28 August 2008

IE8 Beta 2: First Thoughts

IE8 Beta 2 is available from http://www.microsoft.com/ie.

I installed it today - haven't given it much of a workout yet but here are some first thoughts.

Standards mode by default is interesting, I think I'm going to see some odd result over the next few weeks.
I love that items in the Address Bar history can now be individually removed, the drawback with this is where they've put the button. It'sright on the right-hand edge of the dropdown area, which means if you drop it down from the arrow, it's then far too easy to click on a url and delete it instead of going to it. More usability research required here Microsoft!
Looks like security has been bumped up a bit again, which as a general concept I approve of. However it looks like it's broken our scriptlet-based menu and I haven't found how to turn the security down enough to resurrect it yet :-(

Friday, 22 August 2008

Recovering the Sharepoint Central Admin Website

I've been through a process of discovery today of some of the rules of Sharepoint.

  1. You do not stop the Sharepoint Central Admin service.
  2. You DO NOT stop the Sharepoint Central Admin service.
I stopped the Sharepoint Central Admin service (by accident). This is such a fundamental thing not to do that it totally baffles me that Microsoft provide a UI to do it for you.

To get it back, you need to run the Sharepoint Products and Technologies Configuration Wizard. If you've already created a site, you'll be asked if you want to overwrite it, create a new site, or not to create a site. I chose not to create a site as I didn't want to screw up previous work. The wizard then ran through and at the end of it I had a working admin site again.

I tried some playing around with the STSADM command-line tool with the -createadminvs option, which looks like it ought to create a new admin website for you (I'm assuming the vs bit is short for Virtual Site) but I couldn't make this work and I couldn't find any discussion of this through Google to suggest what I was missing.

Friday, 15 August 2008

What I Want in ASP.NET 4.0

Well, a thing rather than the thing...

We're looking at redoing the menu ystem for our application which means we're getting into all the yummy provider goodness that shipped with ASP.NET 2.0.

Except there's a provider missing and it's one we could really do with. Although we can use the XmlSiteMapProvider to generate a menu, it doesn't stop a user typing a URL directly into the address bar. We can stop this by setting up each URL with a element in web.config, but this isn't manageable. What we really want is a LocationProvider, though we'd settle quite happily for an add-on to the SiteMapProvider that does the same thing. The frustrating thing is there's already a ConfigurationLocation class that wraps the element but I can't see any way to get at it to generate a collection that is used across the site.

Thursday, 7 August 2008

ReMix Discount

Kudos to the boys and girls at El Reg. They've posted a discount code for £50 off a ticket to Remix.

Am I going? Certainly not on the strength of this discount on it's own.

Now that an agenda's been published, I'm considering it. I'd be interested to see ScottGu's (all hail, we're not worthy etc) session on ASP.NET MVC, but right now that's about the only must-see. Hopefully it'll all be videoed so I can watch at my leisure later.

Windows Search 4.0

I'm sort of blogging this to see if anyone else has had similar symptoms.
I've been having trouble getting the security patch KB948109 installed on my laptop - SMS has tried installing the patch about six times now, it seems like my SQL Server instance is patched but my SQL Express instance refuses to take it even if I stop the SQL Express service :-(
One of the things I tried last week manually going to Windows Update to install it. While I was there I noticed Windows Search 4.0 and thought I'd install that too. Big mistake.
Immediately after I installed Search, any use of the Google Toolbar crashed the toolbar and then IE. It took me a day and a half to get back to some kind of working configuration, even using Windows Restore didn't solve the problem. I don't have a proper resolution now, I can't use the Google Toolbar and using the IE Search box with Google has ... interesting effects.

Tuesday, 5 August 2008

Non-Relational Databases

I read this piece on The Register yesterday about the new database from the original makers of MySQL. I was particularly intrigued by the statements 'won't support Windows ... and neither will it be SQL relational compliant'. All I could hear was Sir Humphrey congratulating them on a 'courageous decision'.
But I got to thinking about it last night and it occurred to me that Velocity does more or less the same things i.e. allows you to perform CRUD operations on data in a non-relational store, is suited to cloud computing etc.
Except Velocity works on Windows, and Drizzle doesn't. Which really is a courageous decision - love it or hate it, it's the most widely used OS. As a Microsoft developer, if I can't use something on Windows I'm not going to use it at all, so it's difficult to see Drizzle taking off. Maybe Microsoft should make a publicly-available Velocity store available in the cloud and position it as a competitor to Drizzle. Now that would be a Live/Mesh/Whatever service I'd like to use.

Wednesday, 23 July 2008

Velocity Samples

This week's UK MSDN Flash included a piece about Velocity and a link to http://code.msdn.microsoft.com/velocity, which has code samples. Downloading now, will report back later.

Slightly annoyed that I've seen no mention of these on the Velocity team blog!

Monday, 21 July 2008


In the past I've always been pretty unfazed by different browsers and I suppose I still am - IMHO far too many people see Firefox as the Second Coming. But I think I may be wavering...

I used Firefox a lot last week on my BizTalk course at DevelopMentor, and the installation of FireFox on the machines had a couple of really nice FF plug-ins that I hadn't come across before.
  • FasterFox - which shows you how long a page takes to download. This is really nice, the only thing I don't like is having to register with Mozilla before it would let me install it.
  • FoxClocks - which puts clocks for different time zones on the FireFox status bar.

And now I'm missing these features in IE :-(

And then...

I was sat at Starbucks at Liverpool St on Friday afternoon waiting to get a train back to East Anglia, and browsing on my N95. T-Mobile offered me 'Cool Applications' - how could I not follow the link! Which led to me installing Opera Mini on my phone. I had a little play with it, so far I'm not overly impressed (there's no pointer!) BUT this may be a case of me just being used to the Symbian web browser....

Friday, 11 July 2008

Velocity: Struggling :-(

I've finally got to writing some code against Velocity (one of our servers at work has decided it's not going to talk to the domain controller any more so nobody can log onto it). And ... it's not working :-(
I'm pretty sure I'm doing the right things, I suspect it's a configuration issue. The exception I'm getting (having modified my code slightly to throw CacheExceptions rather than just Exceptions) is 'Could not connect to cache service'. I'm slightly gratified to see Christian Weyer gets the same problem - if someone like that gets it, what chance do I have! ;-)

For now, I've removed the extra instances so I'm back to a single host. I thought briefly that it was due to not having set up 'Everyone' to have read/write access but that didn't fix it. Worth remembering as a setup action though.

I'm going to review all my .config files to see if I've missed something - if I don't find anything then I guess it's for the Velocity team.

Thursday, 10 July 2008

Pixel8ed Podcast

I listened to Craig Shoemakers' Pixel8ed podcast on debugging with John Robbins yesterday. This isn't a podcast I've come across before, I followed the link from John Robbins' blog. I generally liked it though I found some of the music under the speech a bit distracting.

I've used some of the attributes Craig talks about before - I'm a fan of DebuggerStepthrough for code like property getter/setters where I'm pretty sure they're bulletproof bits of code. I think it's worth noting that you can still set breakpoints in code with DebuggerStepthrough on it and your code will break there if you still need to debug it.

Haven't come across Tess Ferrandez' blog before but it looks like she may well deal with some hardcore ASP.NET debugging situations. I love her Yoda-like 'if it is broken, fix it you should'! Subscribed.

I saw John Robbins speak at DevWeek a few years ago - the man's a legend! I love the concept of a developer who used to be in Special Forces. And it reminds me that I must go back and read some more of his 'Debugging .NET 2.0 Applications'.

Tuesday, 8 July 2008

Velocity: Regions

I did a bit more digging into Velocity last night. I still haven't written any code yet but I'm getting there!

I was poking around in the Object Browser at the System.Data.Caching namespace and I discovered that the context-sensitive help for each method is probably more helpful than the helpfile.

But more interesting than that, the help for Cache.Add(key As String, value As Object) suggests that if you call this particular overload, the item gets cached in the default region of the cache. Which raises all kinds of questions: if there is a region created by, well, default, which host is it tied to? Does the default region span hosts (in which case regions suddenly become a lot more appealing to me)? Can I use the default region everywhere?

Now I've got multiple instances, I can do a bit more experimentation with regions and see if they start to be a bit more useful, but I suspect my next course of action is to run ClientLibrary through Reflector and have a look at what Cache.Add actually does.

Creating Multiple Velocity Instances on a Single Machine

I now have three instances of Velocity running on my laptop, as per these instructions. I found it a little painful, though probably I wasn't reading the directions closely enough - it took me a while to get all the .config files set up right as I got confused between the cacheHostName (which is the name of the Windows service) and the hostName (which is the machine name). There may have been additional confusion involving the folder names...

Friday, 4 July 2008

Velocity: Digging Deeper

I started looking properly at some Velocity bits and pieces this afternoon, including starting to write a little code against it. And I've already found one or two frustrations, or at least things that don't seem to work quite the way I want them to.

You use the CacheFactory to create an instance of a Cache. So far, so good - I like the Factory pattern. What I'm not so keen on here is that the CacheFactory's methods all have to be called on an instance e.g. instead of:
Dim cache As Cache
cache = CacheFactory.GetCache("MyCache")
you have to write:
Dim factory As CacheFactory
Dim cache As Cache

factory = New CacheFactory
cache = factory.GetCache("MyCache")
[EDIT: It came back to me at the weekend that these are called static methods, or Shared in the one true language of VB]
It's a small annoyance, but I'm a small person sometimes.

I'm going to come right out and say it: I don't get Regions. I'm completely sold on the concept of a single cross-machine cache - it solves the major issue with the ASP.NET Cache (which runs per-machine). So why then require Regions to live on a single machine? It's like they're saying "here, do this to be fault-tolerant, but to get the most out of it you have to do things that aren't fault tolerant".
It's doubly frustrating when you discover that if you want to add an item to a Velocity cache with an expiry time, you have to add it to a Region. The Cache on its' own just allows you to add an item that's there forever.

I really think dependencies are the biggest missing element in the first CTP of Velocity. The SqlCacheDependency in .NET 2.0 was the biggest enabler for caching as it meant you could run multiple web servers and keep their caches in sync with database changes without much effort. You can't do this in CTP1.

I'm interested to see Barry has proposed a session on Velocity for DDD7. That's good 'cos it means I can pick his brain for suggestions to solve some of these things!

Blue Screen: SQL Server Management Studio vs Intellipoint 6.2

I've been randomly getting the Blue Screen of Death when using SQL Server Management Studio 2005, mostly when either scrolling across an open table or resizing a column. It did it again today and I'd had enough.

A bit of Googling suggests that the problem is between Management Studio and Intellipoint. I started hunting through Microsoft's support pages looking for someone to pin this on but it seems the SQL Server team are aware of this but said they aren't going to fix it (though this report is marked as Active at time of writing). Anyway I ended up on the Hardware Support pages where I discovered that I get two free support calls with my Wireless Presenter Mouse. So I've logged the problem with them but with the Intellipoint team, not the SQL Server team. Hopefully the Intellipoint team can either come up with a hotfix or alternatively make the SQL Server team come up with a hotfix. Either way I'm hoping we can get a permanent resolution to the problem.

Update: I've had a first contact from Microsoft. Didn't get to talk to them as I'd already left for the day but I'm hopeful this means they've accepted the issue!
Update 2: Looks like my contact at Microsoft is now trying to pass this off to the Windows team.

Thursday, 3 July 2008

Andy Is An MVP!

Saw yesterday that Andy Westgarth has been made an MVP for IIS. Andy's done a lot of work in evangelising the new features in IIS7 for ASP.NET developers and it's great that Microsoft have rewarded him for it.

Monday, 30 June 2008

Velocity First Look

Normally I avoid CTPs like the plague, but I'm interested enough in this one that I installed the first CTP of the Velocity caching engine over the weekend.

Haven't tried coding against it yet but I had a bit of a play with the command-line admin console and read some of the help.

The most obvious missing element right now is a CacheDependency object (+ subclasses viz. SqlCacheDependency) - I've been trying to think of a way to chain this and the ASP.NET Cache together to retain the ability to have dependencies butI haven't come up with one yet :-(

I'm intrigued by the idea that you can lock and unlock cached objects, though since in the finished version it should run across multiple servers I guess this is a way to avoid race conditions.

Edit: Something else missing I just discovered is that the service out of the box doesn't survive a restart i.e. you have to go into the Admin console and issue a new 'START CLUSTER' command. I've now marked the Windows service as 'Automatic', not 'Manual'.

Thursday, 26 June 2008


Well that was disappointing.

I installed the MS OpenXML SDK this morning (from http://www.microsoft.com/downloads/details.aspx?FamilyId=AD0B72FB-4A1D-4C52-BDB5-7DD7E816D046&displaylang=en) after reading about it in Woody's Office Watch. I was hoping it would have classes to let you generate Office documents on a server without having Office itself installed (been bitten by this before). Unfortunately, it doesn't. Or at least not that I can see from looking at the Class Reference in the Help.

BTW Microsoft, what's with shipping the help file as a CHM? I thought all DevDiv products now shipped with MSDN-style help (don't know the technical name for that one). The helpfile is also slightly unpolished - all the 'How Do I' topics are suffixed with '... using the OpenXML API' - isn't that slightly obvious in the OpenXML API Help!

Wednesday, 25 June 2008

Editing Collections

If you try to edit a collection using, say, a For...Each loop e.g.

For Each item in Collection.items
Next item

it's quite feasible to get an error which says you can't edit the collection you're iterating over while you're iterating over it. Which kind of makes sense.

The trick to doing it is to iterate over it backwards e.g.
Dim i As Integer
For i = Collection.Count To 0 Step -1
item = Collection.Item(i)
Next i

This way, you remove the items from the end of the collection, not the middle, which allows the .NET Runtime to keep track of the collection correctly.

(This might seem obvious to some but it held up some coding for me for about a month until a colleague made chance remark about it!)

Tuesday, 24 June 2008

CancelButtons and Visual Inheritance

I started writing a new WinForms app yesterday, which is going to be a Wizard. I created a base form to inherit from so that all forms would be the same size, have Next & Previous buttons etc. I also added a button called CancelButton, which has to be marked as Shadows so it doesn't screw up the CancelButton property of the form itself.
However when I tried to create the first form subclassing my base form, I got an 'Ambiguous match found' error in the Visual Studio designer. Couldn't find any obvious solution from Googling (partly why I'm blogging it here), but the solution was to rename the button on the base form to 'MyCancelButton' (or, I suspect, anything but CancelButton). It seems that even if my CancelButton was marked as Shadows, the VB.NET compiler isn't quite cute enough to figure out what's supposed to happen.