Tomer Gabel's annoying spot on the 'net RSS 2.0
# Monday, August 15, 2005
I've been using NDoc a lot over the last couple of weeks and have found it invaluable. There is, however, one major hurdle I've encountered: it doesn't seem to support documenting of events. At all. Now I'm trying to generate documentation for one of our interfaces (which consists mostly of events) but can't :-(

I couldn't find anything relevant on the web (via Google or Google Groups). Ideas?

Monday, August 15, 2005 12:16:55 PM (Jerusalem Standard Time, UTC+02:00)  #    -

I've updated the lists of open source and proprietary software I use. I also consistently update the post about ReSharper 2.0 beta; finally, I've installed the new version of dasBlog.

The world is a better place, certainly.

Monday, August 15, 2005 10:48:27 AM (Jerusalem Standard Time, UTC+02:00)  #    -
# Sunday, August 14, 2005
Check this out: How to install Windows XP in 5 hours or less. I found this one particularly funny:
56. Time passes. It is getting dark. You are likely to be eaten by a grue.
I'll give a shekel (don't ask) to anyone who knows what that's all about :-) (well no, not really, but it's funny anyway).
Sunday, August 14, 2005 10:43:05 PM (Jerusalem Standard Time, UTC+02:00)  #    -
I was about to download log4net 1.2 beta 8, which I've been using for almost two years now, only to find that the project's been moved from SourceForge to Apache and an incubation release it out.

1.2.9 beta looks extremely impressive and I will report my comments on the subject as I become more experienced with it.

From the list of features the ones that impressed me the most are:

  • The new logging contexts; NDCs was always thoroughly useful (never found any use for MDCs though) and an extensible, scoped NDC should indeed prove useful.
  • PatternLayout customization; combined with the new logging contexts this seems to be an incredibly powerful tool (consider: conditional object state dumps with no little or no code overhead/clutter!)
  • .NET formatting syntax. Trivial but necessary.
  • Customizable levels for finer debug message granularity.
  • Per-appender security contexts: 'nuff said.
  • Pluggable file locking for FileAppender; I'm not readily sure where this would be useful, but I bet I'll find it before long...
I'm always impressed by open source goodness :-)
Sunday, August 14, 2005 3:17:51 PM (Jerusalem Standard Time, UTC+02:00)  #    -
# Saturday, August 13, 2005
Scott's released dasBlog 1.8! I don't have time to install it just yet - will probably save that for tomorrow. Since all the bugs I filed were fixed the new version is bound to be da bomb!

Update (August 15th, 11:32 GMT+2): dasBlog 1.8 is up and running. Oddly enough it seems to be compiled, or at least set up, to run in debug mode (web.config is set to <complication debug="true"... />), so I changed that. Everything seems to be in order.

The new BlogXP theme is very slick, but it's going to take quite a bit of time to rework it to fit the site design (get rid of the calendar, change the title, add a bit of personality...), so I'll stick with my modified DiscreetBlue in the meantime.

Saturday, August 13, 2005 8:22:37 PM (Jerusalem Standard Time, UTC+02:00)  #    -
Personal | Software
I went to see The Island in the cinema with a bunch of friends the other day. Hey, it didn't cost me anything so why not, right?

It's sort of 1984 (at least in the beginning) meets The Matrix (towards the middle). There are plenty of very high-profile actors who do a pretty good job with the mediocre script (including Ewan McGreggor, Scarlet Johansson, Sean Bean, Steve Buscemi and Michael Clarke Duncan) - there's even a guest role for our own Noa Tishby.

Bottom line: harmless generic action movie; ten years ago it might've been considered innovative but nowadays it's just a cash cow. The acting is, as I said, pretty good (considering the amount of star actors), the eye candy is great - but the movie itself is really uninspired.

Saturday, August 13, 2005 6:17:35 PM (Jerusalem Standard Time, UTC+02:00)  #    -
.NET Remoting is a pretty nice piece of technology. It theoretically allows you to tear out a class from the server code and use it remotely from a client; it features all sorts of nice features like SAO and CAO, lifetime leasing and sponsors, pluggable protocols and provider chains etc. But in order to effectively use it there are quite a few things the programmer should take into account: the obvious ones (serialization, object lifetime, state) and the less-obvious ones (object construction [for CAOs], security [e.g. typeLevelFilter]).

Today I'd like to discuss one these less-obvious issues, specifically the usage of events in remotable classes. For clarity, lets assume the following scenario: a Server has a singleton SAO factory for client registration. The CAO class is called IProvider. Suppose it has the following structure:

public delegate void ServerEventHandler( string message );

public interface IProvider
void ClientMessage( string message );
event ServerEventHandler OnServerMessage;

And suppose the client were to register itself to the event like so:

p.OnServerMessage += new ServerEventHandler( p_OnServerMessage );

What happens behind the scene is a little less trivial. Delegates themselves are value types which hold a reference to their target. So in other words, we are sending the server an object which holds a reference to our client class, in itself a MarshalByRefObject derivative. What happens when an object is marshalled by reference? Answer: a proxy is created on the remote machine. What happens, in effect, is that the server is trying to create a proxy of the client object, which requires the assembly containing the client object's type. A naïve implementation like the one above would result in the following error (click for a larger image):

The solution is something of a hack I originally found in this article; the general idea is that for every delegate defined in your shared interface you create a shim object. This object acts as an intermediary between the client and server, passing events from one side to the other; the shim itself is defined in the shared assembly, which means it is always recognized by both client and server. This way the server does not need to recognize the client object type:

The actual shim implementation is ugly but trivial. Here's one example of how to do this for the ServerEventHandler delegate:

public class ServerEventShim : MarshalByRefObject
ServerEventHandler target;

private ServerEventShim()

public void DoInvoke( string message )
target( message );

public static ServerEventHandler Wrap( ServerEventHandler handler )
ServerEventShim shim = new ServerEventShim(); = handler;
return new ServerEventHandler( shim.DoInvoke );

Now all that's left is to slightly modify the way the client registers itself for the event:

p.OnServerMessage += ServerEventShim.Wrap( new ServerEventHandler( p_OnServerMessage ) );

Be advised: the client is now effectively also a .NET Remoting server, which means you have to register a channel for it (you should use 0 for port; this instructs Remoting to use whatever available incoming port.) You are also serializing custom types here, which means you must also set typeLevelFilter=true for this incoming channel.

Finally, to be honest I'm a little astonished that the .NET Remoting team didn't realize this shortcoming and found a more reasonable way to do this (anonymous, automatically generated shim classes? Why not - there are anonymous, automatically generated proxy classes...) Oh well, another few hours down the drain.

Update (August 29th 09:45 GMT+2): As per the request of Peter Gallati, here's some source code demonstrating the technique. Feel free to drop me a line if you need any further help.

Saturday, August 13, 2005 2:14:54 PM (Jerusalem Standard Time, UTC+02:00)  #    -
I just installed The Gimp 2.2.8 on my laptop. Somehow when I used it on other machines I managaed to miss the fact that it's partially migrated to Hebrew, and that this mode is enabled by default on machines with their regional options set up accordingly.

Now, I can't stand Hebrew in applications so I generally always set localizable applications to English (including GAIM and even Windows itself); getting Hebrew menus is bad enough, but when they're only partially translated and the dialogs aren't RTL'd to begin with it looks absolutely terrible.

If you try to run The Gimp on a Hebrew-enabled machine I seriously suggest you set LANG=en in your environment settings.

Saturday, August 13, 2005 1:22:12 PM (Jerusalem Standard Time, UTC+02:00)  #    -
# Thursday, August 11, 2005

I've converted. Three of what I considered the most useless Windows features have one me over. Specifically: large font sizes, large icons and ClearType.

Now let me make myself clear: for the vast majority of people on the vast majority of equipment, these features are indeed absolutely useless. Six months ago I bought an LG LM50 laptop (which is absolutely terrific, by the way) with an 1400x1050 SXGA+ display. I was stunned by the resolution, particularly the desktop real-estate and sharpness the new display provided, and never felt that the default font sizes were too small: they were certainly smaller, but the display was sharper and when typing on the laptop I was sitting much closer to the display than I was used to. Then I figured what the hell, I'll give it a try, enabled the three features and was absolutely stunned: I had (at worst) the same desktop real-estate I did on the old CRTs with much clearer fonts and icons. The whole experience is that much easier on the eyes, and I still get the added bonus of extra desktop real-estate (particularly when browsing) and much better resolution when displaying images etc.

I'm never moving back to CRTs!

Thursday, August 11, 2005 8:19:21 PM (Jerusalem Standard Time, UTC+02:00)  #    -
I had started to write an article about event shimming in .NET Remoting (yes, I know there are such articles already, but I couldn't find one that was easily accessible and understood) yesterday, but simply crashed and slept over 9 hours. Now I'm at work, so I guess it'll just have to wait until later today or tomorrow. That said, there's the usual variety of things of interest:
  • GuestMaps are a really awesome third party tool based on Google Maps; the idea is that you basically put a map on your site and it allows your readers to mark where in the world they are. I would've put one myself, but I'd rather save myself the embarresment of finding out how many readers I have :-)
  • China's on the news again, this time for putting a young man behind bars for political activies (posting "harmful" essays on the 'net). There are two things I find extremely worrying about this: the first is the way the Chinese propaganda machine operates, specifically the official reasons for incarcarating the man: "[he] jeopardised national unity and territorial sovereignty, spread lies and disturbed public order and social stability". There is also the reason given by the Chinese government for its attempts to monitor internet cafés: "[they] can affect the mental health of teenagers while spreading unhealthy information". The second is that any "western" country with its eyes on Chinese business is decidedly ignoring these increasingly dangerous signs of human rights violations, turning a blind eye to what will undoubtedly come back to bite everyone on the ass.
  • The Commentator is really funny. I'm very glad it is a joke, because after showing it to some of my colleagues I was a bit worried that they might actually use it.
  • There is this movie I was attempting to find for ages. I haven't seen it since I was 6 or so and only knew it by its Hebrew name, the direct translation being "hole in time". Well thanks to the wonders of the 'net I was finally able to find it: it's called Biggles: Adventures in Time, and according to one reviewer it sucks rather badly. Excellent! I'm waiting for my copy and will post my opinion when I have one.
  • Go play Psychonauts.
  • Here's an interesting article explaining why you must never use "double-checked locking", which is an (apparently broken) technique for saving some CPU cycles on synchronization checks. If you do any performance-savvy multithreading code it's an absolute must-read.
  • This is absolutely awful.

Things to expect in the (reasonably) near future:

  • The .NET Remoting vs Events article I was talking about
  • My experiences with Linux
  • Reviews for Psychonauts, Half Life 2, Chronicles of Riddick
Thursday, August 11, 2005 9:11:04 AM (Jerusalem Standard Time, UTC+02:00)  #    -
Send mail to the author(s) Be afraid.
<August 2005>
All Content © 2024, Tomer Gabel
Based on the Business theme for dasBlog created by Christoph De Baene (delarou)