VS doesn’t start, all of a sudden – “Cannot find one or more components. Please reinstall the application.”

After a reboot yesterday, I got the following error message from Visual Studio.

“Cannot find one or more components. Please reinstall the application.”

I did the control panel fix/repair this app, nothing. Today i’ve found the solution on a messageboard so I thought I’d post it to save others hours of frustrated re-installation.

To resolve…

Look in C:WINDOWSWinSxSx86_Microsoft.VC90.ATL_1fc8b3b9a1e18e3b_9.0.30729.4148_x-ww_353599c2
Is it empty? Mine was. Copy atl90.dll from an adjacent x86 folder into that folder.
Start Visual Studio.

This worked for me on Windows 2003 Server, with Visual Studio 2008.

Email clients need to get clever

Coming back from a few days off work to a bloated inbox got me thinking, why isn’t my client helping me to get through the backlog? So here’s a few features i’d like to see..

  • If my out of office was on, rather than group my emails by date, group them by ‘received whilst away’
  • Watch what I do – if I repeatedly delete an email called “Spam Summary” then create a rule for me to remove them.
  • A lot of messages get sent to a group email and processed by a colleague in my absence in a conversation in which i’m not included, why can’t my email client/server interrogate the conversation ID and the message content, determine a completed task, and then suggest that the email is no longer necessary? (although the privacy issue may need resolving)
  • Remove meeting requests and invites for things which have occurred whilst I was away.
  • Remove duplicate emails, or group them into a single row in my client (GMail has this feature, and Outlook 2010 will have a similar feature too)
  • Identify emails like ‘Donuts for the team’, or ‘Team drinks tonight’, or ‘Leaving speech for Fred Bloggs today at 3pm’ etc

At a click of a button i’d like to see a summary of the emails identified for deletion, have been grouped, etc and then let me confirm the action to remove. I estimate this would reduce my inbox volume by around 40%, and let me concentrate on the important emails.

I know I could create rules for most of this stuff, but I have less spare CPU cycles than my computer.

Improving your code with Kaizen sessions

From Wikipedia, “Kaizen is a Japanese philosophy that focuses on continuous improvement throughout all aspects of life”. After a review of our systems from a software coach in the department, I decided to instigate a weekly Kaizen session for the whole dev team. (I first heard of the term Kaizen a few years ago when my then department manager spoke of it and I guess now I understanding what he was meaning – thanks Marc!)

The plan is to spend 1 to 1.5 hours a week pairing with another dev investigating a certain area of the code trying to improve it with no strict deliverables. The hope is that the tools and techniques we use in these sessions will become integral to our daily work and code quality will measurably improve.

To feed into these sessions I created a backlog of features to be investigated. These were stuck on cards on the whiteboards for the pairs to select from. Anyone is free to submit a card for an area of code they’d like to look at.

Here’s a few of the cards I created for week 1 to start us off.

Method foo has a Cyclomatic Complexity of 28, aim to reduce it.
Using NDepend i’ve been looking at some metrics across one of our projects. NDepend gives you so much data that it’s easy to be overwhelmed so I chose Cyclomatic Complexity. This found a single method in our code rated at 28 – that’s to say, there are 28 paths through that method. Although we have 13 unit tests for this method we aren’t testing every line of code, and there’s probably some refactoring that can be done.

Class foo has test coverage of 72%, aim to increase it.

Using the TestDriven.net Visual Studio plug-in with NCover we monitor code coverage of our unit tests. 72% is great, but quite a lot of our code has over 95% coverage so this class needs more testing.

There are 8 unit tests currently marked as [Ignore], without simply deleting the unit test, aim to reduce that count.

This is pretty self explanatory. I don’t know why the tests were marked with the Ignore attribute, but they are, and they shouldn’t be.

I was shown today how by using the Duplicates.NET build runner in our Team City CI server it can automatically identify duplicate code across the system. Despite the fact that this project was a greenfield development we’ve still ended up with some duplicate code in need of an Extract Method refactor. Metrics from these reports will feed into our Kaizen backlog.

For those interested, the end result of the above 3 cards was 12, 74% and 4 respectively, so i’m happy we’ve improved the code and got familiar with the tool set.

NHibernate Lifecycle Callbacks appearing not to fire

Had a problem with NHibernate Lifecycle events recently where they appeared not to be firing when I was hitting ISession.Save(entity). After some investigation I finally realised that if you create a new entity, then query NHibernate it may implicitly persist the transient object during a Flush. When it does this any interceptors will be fired at *Query time* thus preventing them from firing when you explicitly call SaveNew. This is by design of NHibernate to ensure the query results are always valid, and is documented here.

Apache failed to start under OS X Leopard

I love my Mac, but this morning I found the one reason why the glossy UI isn’t always that great – since upgrading to Leopard Apache hasn’t been working on localhost but according to the System Preferences panel all is well.

A quick Google and I found several references to apachectl which is the server control interface. Running “apachectl -k restart” at the prompt returned


(13)Permission denied: make_sock: could not bind to address 10.0.0.1:80
no listening sockets available, shutting down
Unable to open logs

There were 2 clues – the one which I ignored at first about permissions (“i’m logged into an administrative account so it can’t be permissions… doh”), and the reference to the logs. Turns out that on my installation of Leopard the log file folder had failed to be created and thus Apache wasn’t starting.

If you’re having these problems, try the following.

sudo mkdir /private/var/log/apache2
sudo apachectl -k restart

Hey presto everything back under glossy System Preference panel controls once more, and just PHP to get working again.

NHibernate and NOCOUNT

The system i’m working on at the moment recently went into systest and we found a couple of database errors relating which NHibernate was throwing an exception of

Unexpected row count: -1, expected 1

This wasn’t happening on the development system so we took the apparently faulty database from systest and ran it in dev. No errors. This all pointed to an environment issue and after a little checking we discovered that the NOCOUNT setting was different between each database server.

But hang on – when we create the ISession we were creating an IDbCommand and setting NOCOUNT OFF, surely this was enough? Running a SQL profiler I spotted sp_reset_connection commands being executed almost every other statement from NH. This was resetting the NOCOUNT setting and thus it inherited it from the server setting all the time.

Comparing another system’s NH provider versus the one in this system, and I discovered a subtle difference. System A creates an IDbConnection itself and passes it into NH, whereas system B lets NH generate its own connection. It seems that the ConnectionProvider in NH tracks where the connection was created and aggressively releases it if it was internally created.

So my advice is always pass your own connection to NH which allows for better testing and removes the possibility of this happening. Spring.net was a very quick candidate for doing this DI for me.

UPDATE: Since writing my post, i’ve found that providing your own connection prevents NHibernate using the second-level cache so the better solution is to write your own implementation of ConnectionProvider which calls the NOCOUNT OFF on new connections and wire that up in your .config file. Here’s my implementation.

UPDATE 2: I’ve been writing a Linq to SQL app this week, and it turns out that it also requires NOCOUNT OFF, otherwise you get a “Row not found or changed” exception of type ChangeConflictException with a single ObjectChangeConflict object, which has 0 MemberConflicts!