mercoledì 30 maggio 2007

Score another one for me!

So, after a clean format of my machine, I had this weird error in Microsoft Visual Studio 2005: it wouldn't compile one of my web projects. Compilation failed with the following error:

(O): Build (web): Unable to find the required module. (Exception from HRESULT: 0x8007007E)

As you can see, it says nothing about WHICH module is missing. I tried for a few days to fiddle with dependant assemblies, web.config settings, etc. but only today I have been able to investigate and fix it. I downloaded ProcessMonitor from the Microsoft site and after defining the appropriate filters I tracked down the missing assembly: it was MSVCR71.DLL. Just found a copy on some other location on the HD, placed it into C:\Windows\System32 and it worked flawlessly.

I feel like I deserve a reward. Going to buy an icecream! :-)

domenica 13 maggio 2007


While checking the error logs for SkakkiNostri, this morning, I noticed something strange. Yesterday night something like a spider crawled my site, querying the robots.txt as usual, but then it started messing with the file paths.

It tried to visit the pages listed in the web site root (e.g. /forum.aspx), but under the /admin/ folder (/admin/forum.aspx). These do not exist, so I received a notification of the 404 error.

The user agent for those request is Java/1.5.0_11, and the originating host is a dynamic IP of the Telecom Italia range. So maybe one of my user tried a lame scanning tool, but that IP was not in the http logs. How strange...

However I am starting to be annoyed by these notifications. Please, fix that scanning tool! :-)

sabato 12 maggio 2007

Now I have no excuses

...for not documenting my code, that is. I just installed the excellent and free GhostDoc plugin for Visual Studio 2005. Simple and neat, with a right clic on a function prototype this is what is does:

/// <summary>
/// Processes the HTML message.
/// </summary>
/// <param name="message">The message.</param>
/// <returns></returns>
public static string ProcessHtmlMessage(string message)
[ ... ]

venerdì 11 maggio 2007

A little gem

I always liked the way Opera remembers the tabs that were open when it gets closed. Today I looked for a similar Firefox extension, and after a little search I found it is already present in the browser! Just enable it in Tools > Options > Main > Startup. Cool!

A rant

While surfing the net, I usually visit just a handful of sites, and usually three-four times a day.

Now, three of them have video ads. I just can't stand them. Just move the mouse above them, say to click on a link, and they start playing. One of them even starts without intervention. ARGH! It's a long time since I subconsciously installed a brain filter for moving images in web pages, but now they have audio! Imagine my beloved classical music overtaken by a loud voice saying "Take control of the compliance!".

Stop now, please. PLEASE! Video adverts make baby Jesus cry!

mercoledì 9 maggio 2007


While migrating SkakkiNostri from classic ASP to ASP.NET, I noticed quite a lot of unhandled SmtpExceptions. I was fairly shocked, since, before the migration, I did not have any feedback about the relaying of the E-Mails sent by the site, and thought errors were a lot more infrequent.
Right now, my inbox is full of SmtpException notifications. I need to do something to track them in an appropriate place, possibly filtering and grouping notifications. Any ideas are welcome.

Reminder to myself

Request.UserAgent can be null (when the client does not specify it). I was trying to detect the Googlebot and be nice with it, and later found it failed with a few other requests because of a missing null check. DOH!

How to escape apostrophes in XPath / .net

Yesterday I found something interesting: there isn't a correct way to escape string literals in XPath queries.


galleryDocument.SelectSingleNode("//photo[filename='" + photoFileName + "']");

This line raises an exception if photoFileName contains an apostrophe. Neither ' nor \' nor '' work as an escape sequence - the XPath specifications do not handle that. So, how do we deal with it?

The answer is a small routine that relies on the concat XPath function:

public static string EscapeApostropheForXPathParameter(string parameter)
if (!parameter.Contains("'")) return "'" + parameter + "'";

string[] parts = parameter.Split('\'');

string result = String.Empty;
foreach (string part in parts)
result += ", \"'\", '" + part + "'";

return "concat(" + result.Substring(7) + ")";

This routine basically maps the string "foo'bar" into concat('foo', "'", 'bar'). Please note the different kind of quotes around the apostrophe. Nice to know, huh? :-)