Load vs. Get in NHibernate

I really like the lazy-loading feature of NHibernate, because it can dramatically reduced unneeded traffic to your database.

But I had a hard time figuring out, why I could not distinguish whether an object exists in the database or not. Because of the way lazy-loading works, you always get an object returned by the load method. Usually this will be a proxy object. If you try to access a property of an non-existing entity (on the proxy), you well get an exception, but I would rather know this a time ahead.

Well, this is where the get method comes into play. This methode retrieves the values of the properties of an entity directly, instead of lazy-loading these values by using a proxy-object like the load method does.

WCF: using Interfaces in Operation Contracts

WCF (Windows Communication Foundation) is a great think. If you ever though supplying and consuming web-services with .Net 1.1 & .Net 2.0 was easy – think again! WCF goes a long way to even reduce the burden of this process!

OK, so you’re all excited about using WCF and setup your service-contract by defining an interface like this:

public interface IReviewService
void InitiateReview(IReviewTrigger reviewTrigger, IDocument reviewDocument);

As you can see, I used interfaces as ther parameters for my operation-contract. Within the application I’ve a concrete implementation of the IReviewTrigger as well as the IDocument interfaces, So now you go ahead and consume your service in an application like this:

ChannelFactory<IReviewService> factory = new
IReviewService myService = factory.CreateChannel();
ReviewTrigger myTrigger = new ReviewTrigger();
Document myDocument = new Document();
myService.InitiateReview(myTrigger, myDocument);

But this is a booboo. You will get an exception from the service-host, that an object of type ReviewTrigger was not expected. Well, what should I say – the contract defined IReviewTrigger instead of ReviewTrigger. I would consider this to be a shortcomming of WCF … but who is asking me!!

Well, after struggeling with this for quite some time (and being stubborn not to use the concrete class in my operation-contract!) I found a solution. Aaron Skonnard blogged about using a NetDataContractSerializer instead of the built-in serializer … and all over sudden this works!!

Follow-Up: I finally did give up on passing complex types (objects) to operation contracts; instead I’m only passing the primary key of my object to the operation contract. This is reducing the overall overhead and eliminates the necessarity of the NetDataContractSerializer. I just read my Trigger and Document from the above example from my data-layer instead.

Trillian & Miranda – a story of two ICQ Messangers

I’ve been using Miranda for quite some time now, and try always to stick with the lastest releases.

The last release is Miranda IM v0.8.0 Build #3. Unfortunatly there seem to bee some issues concerning the ICQ protocol:

  • communication with Trillian does not work anymore
  • contacts seem to be offline, even though they are online

The first issue can be solved using a previous version if the icq.dll. Version seems to be fine. It seems that Trillian can not handle the new message format, which was introduced to Miranda to improve the compatibility with ICQ 6.

The other issue is more severe. AOL seems to have changed something regarding communication with unauthorized contacts … there has been already some discussion at the Miranda Forum.

Extending the Command Prompt

OK, you know all about pimping your Windows, but there is this one piece, that has never been touched bevor: the command prompt!

Well, guess what? There is more to it! When looking at the properties of the prompt you might be tempted to change the font of the command prompt, only to find out, that only one TTF is actually available: Lucida Console

This is because, there is – what else could there be!! – a registry-key controlling which fonts are valid for the command prompt. Looking at HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont reveals that only Lucida Console is actually available. So just add another font to the key by adding an extra zero to the name. I added 00=Envy Code R 🙂

Another option is to use a replacement for the plain-old-command-prompt … like Console or PowerCmd.

Customizing the appearance of Visual Studio

Well, Visual Studio comes quite boring to you. Especially customizing the use of colors and fonts greatly enhances the use of Visual Studio.

I recently came across some sites, that offer some nifty stuff you might need to pimp you appearance of Visual Studio:

  • Fonts
  • pre-configured vssettings-files


One font I just stumbled across is Envy Code R by Damien. This font is just awesome, and I personally like it much better than Consolas (not to mention Courier New, which is out of the question by now!!).


Besides a nice and appealing font you also might want to tweak the color-coding of visual studio; preconfigured vssettings might ease this step.

Thomas Winterdom has a nice collection of Visual Studio Color schemes.