Tomer Gabel's annoying spot on the 'net RSS 2.0
# Wednesday, January 18, 2006

I was doing some research on how to use a certain component we were given as part of a project. It is a COM object written with ATL; I referenced it via interop and everything seemed to work perfectly. Until we integrated it into the main codebase, that is. For some reason the same code would barf on any call made to a method/property of a legacy ADO Recordset object; an instance of Recordset is passed by reference to the COM object, which initializes it to certain values. For some reason any call to the Recordset instance after the COM method call would result in a NullReferenceException being thrown by the framework.

Oddly enough, tests on the research codebase (on my own machine) now proved to generate the exact same error; considering I had written and tested the code merely two days before, I was disinclined to believe the code to be at fault. Something told me to look into the interop assemblies - we sign every COM/ActiveX import in the project with our own keyfile using a script which runs tlbimp/aximp - and reverting to the VS-generated interop assemblies did indeed resolve the issue. I couldn't find any solution using Google (a Groups search provided a similar issue with no solution offered). Finally I stumbled upon the following quote in this article:

But Primary Interop Assemblies have another important use. Interop Assemblies often need modifications, such as the ones shown in Chapter 7 to be completely usable in managed code. When you have a PIA with such customizations registered on your computer, you can benefit from these customizations simply by referencing the type library for the COM component you wish to use inside Visual Studio .NET. For example, the PIA for Microsoft ActiveX Data Objects (ADO), which ships with Visual Studio .NET, contains some customizations to handle object lifetime issues. If you created your own Interop Assembly for ADO using TLBIMP.EXE, you would not benefit from these customizations.

Since the ADO COM object was automatically imported along with our proprietary objects this got me wondering what sort of "custom optimizations" I might be missing out on. A quick look in the knowledgebase article on the ADO PIA didn't prove very effective (short of a vague statement about "the ADO PIA helps to avoid certain problems with ADO and .NET COM interoperability") but I decided to try it out anyway; I removed the preexisting reference from the project, added "adodb" from the .NET tab in the Add References dialogue (you could look it up manually in the GAC, but why would you?), fired it up - problem solved.

As an anecdote, referencing an external library with tlbimp's /reference command line parameter (particularly the ADODB PIA from the GAC) did not stop it from generating the imported library anyway. Just go ahead and delete it.

Wednesday, January 18, 2006 9:23:19 PM (Jerusalem Standard Time, UTC+02:00)  #    -
Development
# Sunday, January 15, 2006

I saw this joke and couldn't help myself. Sorry, it won't happen again.

Sunday, January 15, 2006 12:36:42 AM (Jerusalem Standard Time, UTC+02:00)  #    -

# Tuesday, January 3, 2006
Or rather, help me to help them :-)  I keep filing bugreports (which are usually fixed by the next release) and feature requests, but in order to get attention the feature requests need votes. Have a look at these two feature requests and vote (or comment) if you think they're important. If not, tell me why:

Additionally, build 215 is out.

Tuesday, January 3, 2006 7:34:38 PM (Jerusalem Standard Time, UTC+02:00)  #    -
Development
Or: How I Learned To Stop Worrying And Love Firefox (this is a Dr. Strangelove reference, in case that wasn't obvious).

There are some fundamental principles of UI design most developers have not taken to heart. Developing a good UI is hard, designing one is excruciatingly hard. A good UI designer needs to have a very developed sense of how a typical user thinks; it is therefore a commonly held belief that most programmers make lousy UI designers because they can't "stoop to the level of the non-technical user" (a slightly less rehearsed mantra is that developers are users as well and are susceptible to the same problems with crappy UI, although possibly a little more forgiving). The developer-oriented UI trend is most obvious with open source software, but it is actually exacerbated when we're talking properietary, even if free, software. An open source tool that is essentially really good but has crappy UI will eventually attract someone who is actually capable in that department. Take a look at Eclipse, OpenOffice.org, The Gimp etc. - although based on a more or less solid foundation, these tools were practically useless a few years ago and have only become mainstream when they made leaps and bounds in usability. An even better example is Firefox; although I was personally attracted to Firefox on merit of its technical achievements, I was only able to sell it to friends and relatives becaues it is infinitely more usable than IE and just as free (I mean come on, does anyone doubt why Opera never gained marketshare?)

A proprietary program however, even if fundamentally sound and useful, can only grow better by the efforts of its owners. Even the most obvious bugs can never be fixed by a 3rd party. w.bloggar is a classic example of this; the last version was out in January and, despite being fundamentally stable and usable, has huge flaws which the author never fixed, instead allowing the software to stagnate. I reckon a lot of you, at this point, are thinking along the lines of "hey, you get what you pay for; you should be thankful that w.bloggar is free, let alone supported!" In a way you are right, but also dead wrong. As far as I know Marcelo (the author of w.bloggar) isn't seeing much money from his work on the software; what money he does get is from donations. So why not release the source? Donation systems seem to work for high-profile open-source projects at large, why not for w.bloggar? At least that way someone can fix the bugs that (for me) turned w.bloggar from a useful tool to a constant cause of frustration.

To get to the point, I wrote a blog entry in w.bloggar (specifically the one about missing tools), published it and went on with my work. At the end of the day I left the machine running (as I always do when I'm not leaving for days at a time) along with w.bloggar. Why'd I leave w.bloggar open, you ask? Simple: one of these glaring bugs I mentioned is that w.bloggar does not retain my preview template options (CSS links and so forth), and it's a pain in the ass to enter them manually whenever I want to edit or write a new post. Anyway, w.bloggar has a "Clear Editor after Post" option which in my case was disabled. This means that whenever w.bloggar finishes uploading a post, it retains the text and changes its internal state so that subsequent clicks on Post update the same entry (as opposed to creating a new one). So what basically happened is that when I came in today and wanted to write the note on OpenOffice.org, the previous post was still "live" on w.bloggar. Usually at that point I click on New (which shows a nice, useless warning dialog) and get on with it; this time I guess I was distracted, just shift-deleted everything and proceeded to write. When I next clicked on Post and got the "Post so-and-so-GUID updated successfully" notice I knew I was up the creek: my earlier post was overwritten with no prior warning, no delay and worst of all: no backup.

Which brings me to my first point: w.bloggar sucks. Bugs (like not retaining options and the most defective HTML syntax highlighting known to man) aside, this is a huge usability problem - a user can (and evidently will) inadvertently erase his/her own work and have no way to recover it. The undo buffer is not even remotely deep enough; there are no dialogs to warn you that you're about to update a live post, and there are no backups-shadow copies-anything of published posts if you do not actively save them. Worst of all, there is no-one to mail, no bug tracker, not even a forum (the forum link on the w.bloggar site is broken). My first resolution for 2006: make more effort on PostXING and help Chris make it actually useful.

Now that that's out of the way, time for some damage control; w.bloggar is useless in recovering the lost content, dasBlog does not maintain any sort of backup (side resolution: implement shadow copies into dasBlog) and considering how cheap my hosting package is I seriously doubt my ISP would help me recover yesterday's daily backup (assuming there even is one) without significant trouble and/or cost. The only option that comes to mind is the browser cache; in case it isn't obvious from the title (and the large "take back the web" icon on the right), I use Firefox. Going over the cache files manually proved futile as most of them seemed to be binaries of some sort; some research showed me that you can access cache statistics by navigating to about:cache; from there you can access an actual dump of the in-memory and on-disk hashes. Looking at the on-disk cache via about:cache?device=disk and searching for something useful, I found a cache entry for the editing page. Clicking the link did not prove readily useful (the actual content is not displayed), but the information displayed shows two important details: the file location and the content encoding (in this case, gzip). This explains the strange binaries I found in the cache! A quick decompression via the excellent 7-zip and I had my content back. Second point of the day: Firefox has once again proved its mettle. Firefox rocks!

Tuesday, January 3, 2006 1:55:29 PM (Jerusalem Standard Time, UTC+02:00)  #    -
Personal | Software
Coninciding with the release of OpenOffice.org 2.0.1, the OOo.il team has released a Hebrew version based off of the 2.0 codebase! It is sponsored (ironically) by the Israeli Ministry of Finance.

I haven't really tested this version but I do hope it's all it's cracked up to be. Time will tell.

Tuesday, January 3, 2006 12:16:03 PM (Jerusalem Standard Time, UTC+02:00)  #    -
Software
# Monday, January 2, 2006
Every developer has some glaring omissions from his/her toolbox. I just found one of mine: Chris Sells' XmlSerializerPreCompiler. I honestly don't know how I managed without it thus far.

Now that I mention it, here's a short (?) list of tools I constantly use as a developer, at work and elsewhere:

  • I've said it once and I'll say it again, JetBrains' ReSharper is absolutely indispensable to any serious .NET developer. It's worth every penny.
  • Roy Osherove's The Regulator is so far the best regular expression IDE around. It has its issues, though, so I can't wait for version 3.0. Best of all, it's completely open source!
  • My XML IDE of choice is Stylus Studio, which I find preferable to Altova's XmlSpy. Both cost mundo bucks though.
  • Enterprise Architect combines the UML powerhouse features of XDE with near-Visio ease-of-use. It's not perfect (not even remotely) but is definitely the best modelling tool I've used to date.
  • Cygwin whenever I need anything from the GNU realm (in particular GCC and Unix-oriented open source tools).
  • NDoc is the best thing since sliced bread. I use this open-source tool whenever "hardcopy" design/code documentation is required, or whenever I want to provide an MSDN-like reference to an API.
  • GhostDoc saves many a pointless keystroke. Just Ctrl+D and you're 50% into your XML documentation. Brilliant in simplicity and absolutely stable. Best of all, it's free...
  • Total Commander has replaced Servant Salamander as my Norton Commander clone of choice. I still can't understand how people manage to be productive without an NC-type file manager.
  • NUnit comes in handly when writing test and test-driven code. I'm not a big fan of TDD (to be fair, I never got the chance to try TDD hands-on on a large scale project), but whenever it comes up it's practically synonymous to NUnit. Make sure to install TestDriven.NET as well.
  • One of the best debugging and reverse-engineering tools around, Ethereal, also happens to be open-source. I can't even begin to count the number of times this tool has saved my ass.
  • The single most comprehensive tool I've ever come across is the ubiquitous Google. Make good use of it...
  • I use Process Explorer, psexec and pskill from SysInternals about 20 times a day. Mark deserves knighthood (or maybe half the kingdom) for making these tools.
  • Any .NET developer would do well to know Lutz Roeder's classic Reflector. It is as indispensable as the .NET framework itself.
  • XMPlay and Sennheiser HD600. Music is life.
Monday, January 2, 2006 3:16:19 PM (Jerusalem Standard Time, UTC+02:00)  #    -
Development
# Wednesday, December 28, 2005
I hate ugly hacks, but sometimes you're left with no choice. I was hacking away at the XML schema for one of our projects, and eventually settled on a neat solution. Imagine the following scenario: your system stores its configuration in XML format; the configuration defines several types of events that can occur, and all these events share the same actions. What's the most efficient way to go about it?

Borrowing a page from the object-oriented software design book, I decided to create an abstract BaseActionType. It will include some basic self-describing information (lets suppose I'd like to have an action category; I would simply add an element to the base type and override the value in each subclass.) Each subclass would describe a different type of action, for example a SendEmailActionType would extend BaseActionType, override its category with a fixed value and add fields such as server, subject etc.

Unfortunately, it appears that XML Schema only supports one of two modes of derivation: derive by extension or derive by restriction, whereas what I in fact require is a hybrid of the two. xs:extension will not allow you to override values, whereas xs:restriction will not allow you to define new elements. This is a problem I used to encounter all the time when creating XML schemas, and today it finally pissed me off enough to find a solution. I was really stumped for a while, but eventually noticed that one of the examples on the XML Schema specification was:

<xs:complexType name="length2">
 <xs:complexContent>
  <xs:restriction base="xs:anyType">
   <xs:sequence>
    <xs:element name="size" type="xs:nonNegativeInteger"/>
    <xs:element name="unit" type="xs:NMTOKEN"/>
   </xs:sequence>
  </xs:restriction>
 </xs:complexContent>
</xs:complexType>

It got me thinking: how can they be restricting a type while adding elements? Then it hit me - this is in fact a restriction on an xs:any particle! Here's the solution I came up with:

<xs:complexType name="BaseActionType">
 <xs:sequence>
  <xs:element name="Category" type="CategoryType" />
  <xs:any processContents="strict" minOccurs="0" maxOccurs="unbounded" />
 </xs:sequence>
</xs:complexType>

<xs:complexType name="EmailActionType">
 <xs:complexContent>
  <xs:restriction base="BaseActionType">
   <xs:element name="Category" fixed="Synchronous" />
   <xs:element name="Server" type="xs:string" />
   ...
  </xs:restriction>
 </xs:complexContent>
</xs:complexType>

I reckon developers who are more experienced with XML than I am already knew the answer, but since I've been using XML far more intensively than the average developer and was repeatedly stumped by the same problem I hope someone finds this useful.

Update (January 2nd, 10:26): My technological enthusiasm has an annoying tendency to turn into a display of naïveté. Specifically, the hack above seems to work just fine for Stylus Studio (any maybe other technologies, who knows?) -- but isn't really accepted by the .NET SDK xsd.exe tool. There are two issues here:

  • The tool fails to recognize fixed="value" attributes for enumerations ("Schema validation warning: Element's type does not allow fixed or default value constraint.")
  • The tool does not recognize restriction of xs:any ("Schema validation warning: Invalid particle derivation by restriction.")

I haven't been able to work around these limitations (yet), nor have I the time at the moment to research into XML Schema and find out if these features are supposed to be supported. In the meanwhile I'm reverting to another solution.

Wednesday, December 28, 2005 5:34:37 PM (Jerusalem Standard Time, UTC+02:00)  #    -
Development
# Sunday, December 18, 2005

I've been getting into ARM assembler a little bit. The ensuing conversations were amusing in the extreme (I'm Holograph, in case that wasn't obvious):

(11:49:59) Holograph: you mean to tell me that this shit:
(11:50:00) Holograph: str r4, [sp, #-4]!
(11:50:07) Holograph: all it does is basically "push r4"?
(11:50:35) YK: ja
(11:51:53) Holograph: that is FUCKED UP
(11:53:15) YK: not really, thats the normal way of doing things, x86 is fucked up

I rest my case.

Sunday, December 18, 2005 12:20:45 PM (Jerusalem Standard Time, UTC+02:00)  #    -
Development
Some software-related tidbits (I'll be updating this during the day):
  • ReSharper 2.0 EAP build 213 is out (lots of builds since the 210 I have installed on my machine at work). I'll have a go at it and post comments in the ReSharper EAP post as usual.
  • GAIM 2.0 beta 1 is also out. I've been using it for the past few hours, it seems pretty stable - there've been a lot of small improvements (away mode handling, account display, preferences) but don't expect a quantum leap in usability.
  • Dying to get rid of Windows XP Automatic Update's super-nagging 10-minute interval "Restart Now or Later" dialog? So am I. Luckily, Coding Horror's got the answer.
  • There's no avoiding QuickTime these days, but what with all the iTunes hype the player is taking up ridiculous amounts of drive space (the installer itself is over 30MB!) I've installed the latest QuickTime Alternative and never looked back.
Sunday, December 18, 2005 12:15:02 PM (Jerusalem Standard Time, UTC+02:00)  #    -
Development | Software
# Saturday, December 17, 2005
Been a while since I posted about one of my biggest passions, being movies of course. Aside from spending an increasingly larger portion of my time on studies (who knew differential and integral calculus can be so demanding?) I'm still trying to find the time to work on some of my pet projects, particularly the home theater and car stereo systems I use. I did manage to see some movies and stuff though, so here we go:
  • Tim Burton's latest movie Corpse Bride is a mixed bag. Objectively speaking, aside from maybe being a little short (76 minutes) it is spectacular: visually beautiful, musically brilliant and featuring some of the best voice acting talent ever heard from behind the big screen. The problem is that it's not just a movie, it's a Tim Burton movie. It's no secret that I consider Tim Burton the best film director since... well ever, really, and I'm used to being so moved by his movies that I find it hard to breathe. Corpse Bride was great - the first half particularly so - but it gave me none of those "holy crap, I must've been holding my breath for 10 minutes straight" minutes that are the real highlights of the moviegoing experience.
  • I went to see Serenity with a bunch of friends today, but since some of them have already seen it the choice of movie inexplicably changed to The 40 Year Old Virgin. As far as shitty light comedies go this actually had some genuinely funny movies, but that's probably only because I wasn't expecting much. Bottom line: it's not much better than you'd expect, so stay away.
  • On the same note, Deuce Bigalow: European Gigolo is another "light" comedy. This movie is the embodiment of what I despise in Holywood (stupid, pointless and unbelievably coarse), so I won't bore you with the details. There are funny moments certainly, but the bottom line is it's a really crappy movie.
  • I finally got to see Harry Potter and the Goblet of Fire and was vaguely disappointed. My compadré Oren seems to have similar feelings about the movie; it was in many ways great (particularly the way they went all-out on effects), but it missed out on a lot of seemingly unimportant details that are absolutely vital to the entire Harry Potter experience. Read my comments on Oren's post for more insight (?).
  • Finally, my brother and some friends came over and we settled on watching Total Recall again. It's been at least 5 years since I've seen the movie and it's every bit as good today as it was years ago, with one important distinction: now that I'm older it's far more obvious to me how bad a couple of actors are (yes, Arnold, that means you. You're still the bomb though), and it's also far more astounding that despite the action-oriented mindset of the movie it is actually very well written. They manage to give you all of the clues and none of the answers, and they don't even hint at what the questions really are right until the very end (with that poorly chosen "What if it IS a dream?" line). Bottom line: terrific movie. God I miss the '80s.
Some movies I'm looking forward to:
  • The Chronicles of Narnia: The Lion, the Witch and the Wardrobe might be the "next big thing" (after Lord of the Rings...) I read the prequel a while back and the first book a couple of weeks ago and wasn't actually overly impressed - so far it seems like a plainly overrated fairytale (I can certainly appreciate fairytales, just not the overly childish ones). In some aspects it keeps reminding me of Lemony Snicket's A Series of Unfortunate Events (which upon reflection was actually really very good), I guess I'll just wait and see.
  • I'm still waiting for Memoirs of a Geisha. As someone who's usually not into dramas I'm not quite sure what it is about the movie that attracts my interest, but I have a good feeling about it.
Saturday, December 17, 2005 4:06:11 AM (Jerusalem Standard Time, UTC+02:00)  #    -
Movies
Me!
Send mail to the author(s) Be afraid.
Archive
<January 2006>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234
All Content © 2024, Tomer Gabel
Based on the Business theme for dasBlog created by Christoph De Baene (delarou)