July 2004 Entries

Language Lawyers (and Nasal Demons)

As soon as a development language has an official specification behind it, the first language lawyer appears. If you’ve never seen one in action, they are the type who can rattle off section and paragraph numbers from a specification while explaining the bizarre behavior of some code snippet. You might see them write something along the lines of: The values of a and b are automatically promoted back to int [6.2.1.1/ 3.2.1.1], which is then the type of the result of the / operator [6.2.1.5/3.2.1.5]. Since -32768 is exactly divisible by -1, and the result of 32768 is representable in...

Static Constructors Are Not Miracle Workers

The CLR guarantees a type initializer (static constructor) will execute only once for any given type. This simplifies my life, because I don’t need to worry about multiple threads inside of a static constructor. Take for example the following program: static void Main(string[] args) { Thread threadA = new Thread(new ThreadStart(TouchFoo)); threadA.Name = "Thread A"; Thread threadB = new Thread(new ThreadStart(TouchFoo)); threadB.Name = "Thread B"; threadA.Start(); threadB.Start(); threadA.Join(); threadB.Join(); } static void TouchFoo() { Foo.SayHello(); } class Foo { static...

Database Retirement

I installed SQL Server 2005 Beta 2 last night. This morning I noticed something missing. If the current bits hold true till RTM, then I will have to lament the disappearance of a dear friend. Everyone called your design a disaster, but I have fond memories of your eccentricities. Your Order Details table taught me how to delimit identifiers with [ and ]. Your "Ten Most Expensive Products" stored procedure taught me SET ROWCOUNT. A countless number of articles, books, and newsgroup postings contain the query SELECT * FROM EMPLOYEES – a tribute to your ubiquity. Now they will lie...

FileVesionInfo

Getting the version number of any managed / unmanaged DLL or executable in .NET 1.0, if I recall correctly, required some magic incantations with PInvoke. I just discovered the FileVersionInfo class from System.Diagnostics: FileVersionInfo versionInfo; versionInfo = FileVersionInfo.GetVersionInfo(@"e:\win2003\system32\svchost.exe"); MessageBox.Show(versionInfo.ToString()); Notice the class overrides the ToString method to provide nicely formatted information: File: e:\win2003\system32\svchost.exe InternalName: svchost.exe OriginalFilename: svchost.exe FileVersion: 5.2.3790.0 (srv03_rtm.030324-2048) FileDescription: Generic Host Process for Win32 Services Product: Microsoft® Windows® Operating System ProductVersion: 5.2.3790.0 Debug: ...

Lookout Assembly Hell

I decided to download and try Lookout, the search tool for Outlook (now a free download from Microsoft). I’m hesitant to give out the link, since, like Elvis, it seems to popup and then disappear, but recent sightings have the download at Lookout Software again. After installation, Outlook greeted me with the following error: Sorry!! It looks like another Outlook Plugin has installed an unofficial version of the Outlook libraries which breaks Lookout. Lookout will not be able to load. For more information, see this link: http://www.lookoutsoft.com/forums/topic.asp?topic_id=10 Unfortunately, the aforementioned link doesn’t offer many leads on why the problem occurs, nor how...

Who Moved My Furniture? (Small Company Life)

On January 31st 2001 the company I worked for closed the doors. A company near Philadelphia had bought all the rights to the software and intellectual property of the former company, and 4 of us were given the opportunity to work for them on a short term consulting basis, starting January 2nd. I had a lead on going to work for a startup company in the video game industry, but it was taking some time to pan out, so I prepared to spend 3 days a week in Philly. I have to admit I had a bias against Philadelphia going...

A CEO and His BMW (Small Company Life)

Optimism is a primary trait of startup company CEOs. With all of the risk and obstacles involved in getting a company off the ground, they have to be optimistic. The type of optimism goes beyond “glass half full” optimism. I’ve worked with CEOs who, when spotting an empty glass sitting on the hot asphalt of a desert highway, will convince everyone nearby that a freak microburst of rain is inevitable, and the glass will be full any moment now. I worked with one of these CEOs during the bubble years. He was a charismatic factory of entrepreneurial ideas. Once the...

The FBI Raid (Small Company Life Flashback)

Years ago I used to juggle two different projects by spending my morning writing C and assembler code for 8-bit embedded CPUs, and in the afternoon I’d switch over to Windows code with Borland’s OWL framework. This was a day I’d never get to launch the Borland IDE. My office was in a building housing two companies. My company occupied the front of the building, and the second company (let’s call it XYZ Inc.) occupied the back of the building. The only proper way into the back of the building was to go through a door just past my office. These two...

Small Company Life

I was thinking back today at some of the weird and funny stuff I’ve lived through at startup companies over the years. Someday I should write in more detail about the following: The FBI raid. The CEO who, on his last day, managed to cram 1 executive leather chair, 2 desktop computers, a file cabinet, and a bookshelf into a 2 door BMW. The intern who wore pink teddy bear clips in his beard. The CEO who painted his toenails the company colors. The CFO who was amazed to see how Excel could recalculate cell C3 based on the contents...

Server Or Workstation Garbage Collection?

I did some experimentation this evening because I read something that struck me as odd in a comment on Scott H’s blog. First, some background. There are two versions of the garbage collector for .NET. The garbage collector optimized for multi-processor machines (packaged in MSCorSvr.dll), and the workstation garbage collector (packaged in MsCorWks.dll). I can see who is running the workstation garbage collector on a Win2003 machine using tasklist from the command line: tasklist /m mscorwks.dll Image Name PID Modules ========================= ====== ================== OUTLOOK.EXE...

Generic Gotchas

The introduction of generics will be a welcome addition to C# and VB in 2.0, except the change is little more disruptive than I would have thought. Consider the current use of Hashtable: Hashtable lastNames = new Hashtable(); lastNames.Add("Beatrice", "Arthur"); lastNames.Add("Lucille", "Ball"); object name = lastNames["Audrey"]; if (name == null) { lastNames.Add("Audrey", "Hepburn"); } Now here is how it might look after an porting to use the generic type Dictionary<K,V>: Dictionary<string, string> lastNames; lastNames = new Dictionary<string, string> (); lastNames.Add("Beatrice", "Arthur"); lastNames.Add("Lucille", "Ball"); // the next line throws KeyNotFoundException string name = lastNames["Audrey"]; if (name == null) { lastNames.Add("Audrey", "Hepburn"); } In Beta 1 the indexer throws...

Book Shopping

I've been running low on reading material, so I decided it was a good time to go book shopping. One title that has caught my eye with it's quirkiness is Coding Slave. Judging by the web site, this should be entertaining. I also found out Neal Peart has a new book on the way. I'm just wondering if I should pre-order through Amazon, or wait until the Rush tour hits Virginia this August. Pehaps some copies might be available for sale there. Decisions, decisions.

More Fun With Generics: Action, Converter, Comparison

As a follow up to yesterday’s blog about the Predicate<T> delegate, I wanted to try out the three additional delegate types in the generics area. First, a new type to work with: class Person { public Person(string name, DateTime birthday) { this.name = name; this.birthday = birthday; } public string Name { get { return this.name; } set { this.name = value; } } ...

Generics and Predicates

What will be an elegant technique to remove objects matching a condition from a List in C# 2.0? If the following code finds a match, we’ll find out it’s a no-no. foreach (string s in list) { if (s == "two") list.Remove(s); } In VS2005, the code creates this friendly little dialog. C# 2.0 introduces generics, and with generics come predicates. A predicate returns true when an object meets a set of conditions, otherwise false. A method like List.RemoveAll will run each object in the collection through a given predicate to test each object for a match. When the...

Does Michael Powell Have The Ugliest Blog On the Planet?

While veering through Yahoo news this evening I came across the headline: “FCC Boss Launches Blog Aimed at High-Tech Industry”. I was stunned. For the first time ever I read about a new blog from a source outside the blog world. Usually you find out about these sorts of thing by plowing through 25 insightful blog entries which read: “so and so is blogging – subscribed!”. In true Yahoo / Reuters fashion, however, the news article didn’t contain an actual link to the blog, but links to news and websites about the FCC. At the very bottom of the article,...

Latest OdeToCode Articles

I've added a few articles to the site recently: Using The Amazon Web Service From ASP.NET Screen Scraping, ViewState, and Authentication using ASP.Net  And Poonam has chipped in too: Saving Images in a SQL database using ASP.Net Reporting Services and the Report Viewer component - Part II

ASP.NET 2.0 and Site Maps

I hereby interrupt the “week of the malcontent” with the “evening of possible enlightenment”. The provider design pattern in ASP.NET 2.0 is sweet. I’ve been toying around in the SiteMapProvider area since the first CTP. There is an XmlSiteMapProvider which let’s you describe the navigation and layout of your web site in an XML file like so: <?xml version="1.0" encoding="utf-8" ?> <siteMap> <siteMapNode title="Home" url="Default.aspx" > <siteMapNode title="Products" url="Products.aspx"> <siteMapNode title="Seafood" url="Seafood.aspx"/> <siteMapNode title="Produce" url="Produce.aspx"/> </siteMapNode> <siteMapNode title="Contact" url="Contact.aspx"> ...

Why Do Microsoft Webcasts Have To Stream?

The MSDN Webcasts Weblog is online. Since I am doing nothing but whiney posts this week, then I’d like to ask: Why can’t we download the webcasts for offline viewing? Bill has me salivating over the Personal Media Center. I started to imagine myself downloading MSDN TV, Channel 9 videos, and TechEd webcasts to watch at my leisure, away from the desktop. There are just two problems with this dream:   The Personal Media Center isn’t for sale as yet. The Microsoft webcasts do not download as a file I can save, they only stream. [Updated with MSDN Webcasts new URL].

Yearning for Yukon

Let me say that the Express version of SQL 2005 has not been a disappointment to me. The disappointment has been in not getting a new beta of the ‘real thing’, the ‘Venti espresso’, the ‘yellow yolk of the Yukon egg’. I have not tried to do much with SQL Express. As soon as I heard the product mentioned in the same sentence as MSDE, I pictured it appearing in the Server Explorer window of the IDE, doing all the mundane things databases have done for the last 5 years. I think a previous forced experience in wrestling with MSDE helped...

Office Needs A Better Managed API

A few days ago, I decided I wanted a new button on my Outlook toolbar. When I click the button I want highlighted items redirected to a web mail account with the ‘From’ address intact. I’m sure this already exists somewhere, but I wanted to learn how to do it myself. With the Shared Add-In extensibility project wizard and code from “An Introduction to Programming Outlook 2003 Using C#”, I thought I was 90% of the way there, except it didn’t work. Specifically, the following line of code from the article would never return: CommandBars commandBars = applicationObject.ActiveExplorer().CommandBars; The call would literally disappear...

Scott Allen
Posts - 869
Comments - 4493
Stories - 14