Tag Archive for Miscellaneous Debris

“O frabjous day! Callooh! Callay!”

It doesn’t work.
The lights have long since been turned off. Your eyes are red and sore and there’s a stack of empty coffee cups threatening to teeter-totter off of your desk and into your lap.
And it doesn’t work.
You’ve been working on this nagging bug, this annoying program, this insignificant technical NOTHING for hours.
But it just doesn’t work.
And then it comes! the flash, the light, the little cherubs blowing silver trumpets in your mind. Maybe a corworker passed by and idly pointed it out. Maybe your eyes have started looking sideways at your code in frustration. Whatever the reason – it’s OVER. You’ve fixed the bug. The code works. You can go home now.

We’ve all been there. We’ve all banged our heads against the wall in frustration because of some stupid bug or undocumented API. We know the relief that comes when you finally get past it.

So this is what my blog is for. To relieve my frustration when I can’t get something to work, and to gloat in exultation when I finally can. 


SQL Server Woes.

I am not a SQL Server Guru, I admit. Far from it, actually. But still, this shouldn’t be this hard.

I was cheerfully punching away Sharepoint code on my Win2003 machine, when suddenly the power died. Cries of alarm, black smoke from the generator – the works. Not too much of a problem, since I am a reflexive (not to say spasmodic) CTRL-S presser, so it was just a matter of waiting for the power to come back and resume working.

Except that when it did, it seemed my SQL Server (2000, sp3a) decided to call it quits. Whenever I would start the service, it would immediately after launching die again, with an event-log message that the LSN passed to the ‘model’ database was incorrect.

Some checking revealed that the LSN is the Log Sequence Number, and my guess is that the power failure happened exactly while it was processing transaction logs – but should that be fatal?

Furthermore, if it is – shouldn’t there be any way of clearing it up? Is there no command-line tool to let me declare the DB consistent?

What I was forced to do, eventually, is copy my MBF files aside, run the rebuildm.exe command to rebuild the Master database from the original CD, and then re-attach my databases – luckily unharmed and unchanged.

A man’s home (network) is his Castle

The Longhorn Identity System (codename “Castle”) is a long-awaited feature.
It replaces the ancient Workgroup model in home Windows installation with something that’s more lightweight than a full-blown Active Directory. Been hoping for something like that. (And by “hoping”, I mean “idly wondering about it at some point in the past”).
Too bad it’s a Longhorn feature. It’s also apparently based on WinFS, which has been pushed back to, what is it now, 2050?

Here are some slides about it from PDC ’03. Does anyone know if there’s any newer information about this?

Debugging HTML that is rendered at runtime.

A little tip when we’re generating HTML content on-the-fly using client-side code, whether HTC behaviours or javascript:

As we all know, when we try to View Source on such a page, the HTML we see is the base HTML that was received from the server, not the final layout after all the client-side code has run and changed things. This often makes it hard to debug, since we can’t see the final layout that the user sees. This technique will help us get the final, rendered page for debugging.

We’ll add this script block to the end of our HTML:

This can be written with our choice of scripting languages, of course. I don’t know if other platforms have objects equivalent to the FileSystemObject for easily creating a text-file. We’ll have to allow the browser to run ActiveX’s for this to work, of course.

The RenderedPage.html file we save here is the final version of the page as it is rendered, running after all other code has run (at least code that runs on load). This can often point the way to the source of the bug – especially layout bugs.

Outlook Miscellany: Erasing a name from the Autocomplete Cache

The drop-down list of names that Outlook gives us to auto-complete a name or address being written is stored in a file called .NK2 in our Application DataMicrosoftOutlook directory. This file is stored in a proprietary binary format, and there's no known documentation for it as far as I know. There seems to be a company that (apparently) reverse-engineered the format and are selling a cache-editing tool, but it's pricey – the basic desktop version can edit, import/export and print for $35. The network/helpdesk editions can do remote NK2 editing for all computer on the network, but gets really pricy with per-seat licenses and so forth.
(They're called Ingressor, if anyone needs those tools)

It turns out, however, that the most common usage for such an editor isn't necessary. If we just want to remove an item from the cache we can do it from within Outlook itself – simply navigate the drop-down options using the arrow keys and press Del on the one we want to erase – and away it goes.

Very simple, and even logical when you think about it. We're just not used to live editing of an auto-complete list.

Macro Origins

I’ve been wondering about the origin and etymology of the term “macro” as it is used in programming. The general use for it is to mean something large – the opposite of “micro” – but it didn’t seem to fit for the concept it’s used for.

Luckily, the Online Etymology Dictionary came to my rescue:

“As a stand-alone word, in computer programming, meaning “a macro-instruction,” it is attested from 1959. “



When is a dash not a dash?

An interesting an unusually frustrating pitfall that I’ve stumbled into a few times:

Many times when we’re preparing for deployment of a software product, we find ourselves preparing a Word document with the steps for installation. In the case of my current system, installing the server requires several manual steps, among them running a command-line utility to set some Kerberos security parameters.

Naturally, being the friendly and considerate developers we are, we supplied the full command-line that is to be run on the target machine, complete will all options, parameters and variables.

Imagine our surprise, then, to learn that the command line simply fails to run, claiming a syntax error in the inputs. Even when we went over to the system to see it for ourselves, we saw that a direct copy-paste operation from the Word document to the commandline fails mysteriously. What is even stranger is that typing out the command-line, letter by letter, will cause the command to succeed.

The answer, as you might guess by the title of my post, is that Word tends to be a bit too smart for its own good. When I copied the command-line to the document with a option parameter like this:

setspn.exe -a http/MyServerName.domain.com

it replaced the dash in “-a” automatically with this:

setspn.exe –a http/MyServerName.domain.com

Similar at first glance, but what we have on the first line is a Hypen-Minus (U+002D) and on the second an En Dash (U+2013). Word’s grammar rules changes the minus-sign to a Dash, and the command-line parser chokes on it and dies. This is almost impossible to spot; command-line fonts don’t display the difference to any discernable degree. The only way we stumbled onto it is because we tried replacing every other element on the command-line with no success.

So remember – by default Word allows itself freedom in altering your documents. For letter-perfect preservation, consider disabling AutoText/AutoCorrect in word, or just storing syntax-sensitive data in normal text files.



VSS2005 – staying in line

Working with Visual SourceSafe always feels to me like walking on eggshells. One wrong move and you get that sickening crunching feeling and things seem to collapse.

My current project’s integrator decided to keep things neat. There’s a central solution containing all the projects, sitting under a central project in VSS. Dozens of projects, divided with Solution folders, all neat and ready for integration builds.
Naturally, most of us don’t really need all those projects open in our solutions when we work. They slow down work and are generally a headache, so we decided that everyone can create his own customized solutions and work against them.
For some reason, the decision was made to create a project folder under VSS for each team member, and have each team-member keep his own solutions there so as to not mess up the main project folder with random SLNs. It goes something like this:

  / MainSolution
  / MainSolution / FirstProject
  / MainSolution / SecondProject
  / Avner

Where my SLN file now sits in $/Avner but references projects in $/MainSolution/FirstProject.

Anyone who’s worked with VSS might already be wincing in anticipation.
Visual Studio doesn’t really like to have project references not sitting underneath the current solution’s VSS root. If I add a new project under my solution and then check it in, it will automatically check that project in under my solution folder ($/Avner/ThirdProject). I have to remember to manually go to File -> Source Control -> Add to Source Control and answer ‘No’ when it asks me whether to add it under the solution folder.

Assuming I made a mistake, I can either spend 20 minutes struggling with moving it around and updating the bindings, or go the easy way: Erase the projects from VSS, remove them from the solution, then re-add them, permanently remove all SCC bindings and re-add them to the proper place. Ugh.

Since no-one enjoys that, I’ll try to list some recommendations:

1) When working with multiple solutions, it’s best to have them all reside in the same root solution project.
2) If you must put them in alternate folders, it’s best to create any new projects from the master solution to ensure they are created in the right place, then add them to the sub-solution using File->Add Existing Project -> From SourceSafe (LAN).
3) If you created them directly from the subsolution, make sure you don’t check them in immediately, but manually add them to the right place from File -> Source Control -> Add Project To Source Control.
4) If you did, don’t try to fix it. Just erase from VSS and from the solution and re-do from start.

One-Click Wonder

It turns out that you can easily close a tab with one click on the middle mouse button. On most modern mice, this would be the scroll wheel button. No fuss, no right-clicking, no selecting the tab and going to the other end of the screen for the X button. Just a single middle-click.

This works in Visual Studio 2005, in IE7, Firefox 1.5 and RSSBandit, to go by the applications I’ve tested it in. Seems to be a common UI convention that I have been entirely ignorant of. It’s probably common knowledge for many people, but I only recently discovered it.
When I shared the discovery with my office-mates, it turned out that quite a few of them weren’t aware of this trick either, so I figured I’d share it here for all the others who have missed it:


Zune Desktop Theme – A Warning


A few days ago, Microsoft released a new Desktop Theme for Windows XP named the “Zune Desktop Theme” – even though it looks a lot like Vista, all in black and orange. It fits in with Office 2007’s Black skin, so I gleefully installed it.

Everything was fine for a few days until the first time I had to reboot (rather than Standby/Hibernate) – late last night. From that moment on, my Windows Explorer would crash every time you tried to do anything. Windows loaded? Explorer crashed. Tried to open a folder? Expolrer crashed. Save As from Word? You guessed it.

Took me a while to put two and two together since there were a few days between the two, but the solution is to:

a) Uninstall the Zune Desktop Theme.

b) Choose a different desktop theme (Luna, for instance).

c) Reboot.

This solved the problem for me. Even though I’d gotten used to the gloomy Vista-ish look, I won’t be reinstalling it any time soon. Your experience might be different, but beware. If you’re feeling curious or suicidal, here’s the download link:

Zune XP Desktop Theme