Pain with .NET 4 assemblies and the GAC

by brendan on October 5, 2011

Installing a Microsoft .NET assembly into the GAC used to be fairly trivial. Unfortunately, I just spent some frustrating time learning that things have changed quite a bit with .NET 4.

I began with my .NET 4 assembly and tried to install it via the usual approach, dragging and dropping it into the %windir%\assembly folder via the Explorer shell extension. Strange; nothing happened.

A quick search revealed that for .NET 4, Microsoft, for reasons which do not seem to be well documented, have created a new GAC location, in the %windir%\Microsoft.NET folder.

Well, that was annoying, I thought: but I could deal with it. I tried dropping the file into the new GAC folder… but there is no nice Explorer shell extension for the new GAC. Doh! (for the second time)

Ok, time to drop to the command line and fire up good ol’ gacutil.exe.

FAIL

I received this error message:
“Failure adding assembly to the cache: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.”

Sigh. Ok, I thought, I’ll just use the .NET 4 version of gacutil.exe. After a quick search of my PC I learned that it’s not installed with Version 4 of framework, nor with Visual Studio 10.

Yet another brick wall! But no worries – I would just download it. I found out via Matt Whetton’s Blog that I needed to download Microsoft Windows SDK for Windows 7 and .NET Framework 4 to get it, so I did (while wondering why I need to download that whole SDK to get gacutil??)

So then I found gacutil in the bin folder of the SDK and I ran it. Arrgh, it returned the same error message again!

Eventually I found the .NET 4 version of GACUtil in the SDK – it’s nestled in
C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools.

Sigh. Could Microsoft really make things any more difficult? I just wanted to install an assembly into the GAC!

By the way, if you need to copy gacutil onto a server, you will need to copy the following files to it: gacutil.exe, gacutil.exe.config and gacutlrc.dll (the last one located in the 1033 sub folder containing gacutil).

{ 4 comments }

Leave the Code in a Better State than you Found It

by brendan on September 22, 2011

We’ve all been there: code that hurts your brain to look at, let alone comprehend.

Not written by you, of course. You wouldn’t write a mess like that, and you can hardly believe that somebody else did (or maybe you can…?)

Your mind wanders to who to blame for this abomination before your eyes. You start complaining to the person sitting next to you. Then to your boss. Then you decide that it’s time for a coffee and then to browse for new jobs.

Sound familiar? I bet it does!

The difference between an average programmer and a good one is in what you do next.

Do you ignore it and try to forget you ever saw it, or do you attempt to improve it?

I have a simple rule that I like to follow: I always try to leave the code in a better state than I found it.

This might involve small improvements, like improving code formatting, renaming methods or variables, or adding useful comments. Tiny improvements add up over time, especially if the whole team is doing the same thing!

Or the improvement could be larger, like refactoring or adding test coverage.

Yes, this can take time, and yes you do have that deadline to consider. But it’s amazing how quickly small improvements can be done; certainly in much less time than it took to understand that grotesque code. Which means that your improvement might make it much quicker for the next person to understand – and that next person might be you, when you revisit it in a year’s time…

The important thing is to do it, and encourage your whole team to do it. Don’t be afraid to change things. Take responsibility for that code, even if you didn’t write it: embrace collective code ownership!

{ 6 comments }

Notes from Jean Tabaka’s talk, “The 12 Failure Modes of Agile”

July 25, 2011

I recently had the opportunity to hear Jean Tabaka, Agile Coach from Rally Software, speak in Brisbane at Yow! Nights about The 12 Failure Modes of Agile. Jean has been consulting as an Agile coach for many years, so it was really thought-provoking to hear her top reasons of why the adoption of Agile might [...]

Read the full article →

The Emerging Trend of Agile for Non-Development Projects

May 23, 2011

Recently I attended a session of the Brisbane Agile Academy Meetup Group (which I highly recommend, and not just for the free pizza!) chaired by Craig Smith, on Using Agile for Non-Development Projects. I must admit have a special interest in this idea: ever since I began using Agile for software development I have fantasised [...]

Read the full article →

How you can use Gmail as a lean, mean, email-processing machine

May 4, 2011

I like to see the process of managing email as a little like gardening. You need to prune the plants and keep on top of the weeds. If you get it right, you end up with a beautifully manicured garden. If you don’t, you just end up with an overgrown backyard full of weeds! With [...]

Read the full article →