zaterdag 3 november 2007

Castle Windsor and ActiveRecord

I sometimes read blogposts where people mention Castle Windsor and Castle's ActiveRecord, so I decided to have a little peek at these two projects.

Castle Windsor is an IoC container and ActiveRecord is an implementation of the Active Record pattern which internally uses NHibernate.
These projects look very interesting, and I'd like to make use of them in a little hobby-project before using it in a real-world project

Is there anybody who has used one (or both) of these projects in a real world scenario and who wants to share his (or her) findings ?

woensdag 24 oktober 2007

New debugging experience in VS.NET 2008

As I was reading a bit on Bart De Smet's weblog today, I came accros an interesting post where Bart talks about a new 'debugging experience in VS.NET 2008.

It seems that Microsoft will release the source code for the .NET Framework libraries, and that there will be an integrated debugging support in VS.NET 2008.
This means: when debugging your code, it should be possible to 'step into' the code of the .NET framework classes.
I think this is great!

I've also read another interesting thing on Bart's weblog: Bart will be working in the MS HQ's in Redmond, where he'll work on WPF. That must be a great job, and I'd like to wish Bart a lot of succes!

donderdag 18 oktober 2007

MSDN RampUp

Microsoft has set up a programme in which you can take part to gain new or refresh your existing .NET development skills.
This programme is called 'MSDN Ramp Up'. It is an online course with a lot of course material and online virtual labs.

The nice thing about this Ramp Up programme, is that Microsoft has made different 'tracks', which are tailored to the existing experience and knowledge of the student.
There are four tracks available:

  • Aspiring Developer; which is suited for people who have no prior programming experience, but want to learn programming with MS technology

  • Java Developer; this track is for Java developers who want to gain knowledge about the .NET framework and want to learn programming in C#

  • MS Visual Basic 6.0 developer; lets existing VB 6 developers become proficient in .NET and VB.NET 2005

  • MS VS.NET 2002/2003 developer; introduces the .NET 1.x developer with the improvements and changes in the .NET 2.0 framework

If you want to learn more about this programme, or want to take part in it, then visit this website.

vrijdag 28 september 2007

MS LEAP Programme, yet another rant.

A while ago, I received an e-mail with an invitation to take part in the MS LEAP programme.

This looked very interesting, so I asked my employer if I could take that course and if my employer could help me bear the costs.
A few days later, I received the answer that I could and that they (the company where I work) would bear the majority of the cost. \o/

Now, today, I wanted to subscribe but unfortunately, the program is already fully booked. :(

The ranting doesn't stop. :(

donderdag 27 september 2007

Auto-Formatting in VS.NET 2005 does not work anymore

After a harddisk-crash, I had to reinstall Visual Studio.NET 2005.
As I started programming again after it was re-installed, I noticed that the 'auto-formatting' function of VS.NET didn't work anymore ...

This is very strange, and very annoying once you're used to it. I've verified my options, and they're set the way I want too.
The options:

  • Automatically format completed statement on;
  • Automatically format completed block on }

are enabled. However, when I type a ; or a }, the code is not being formatted at all...
When I use the shortcut 'Ctrl + E, D (format document)', my current document is formatted.

I've no idea why this doesn't work anymore. I've just made a fresh install of VS.NET.
Is there anybody who has experienced this 'annoyance' as well, and if so, how did you fix it ?
In other words: if there's anybody out there who knows how to fix it, please let me know. :)

maandag 13 augustus 2007

Cleaning a Keyboard

My keyboard is about 5 years old, and it has been used extensively. During these years, it has become more and more filthy.
Now, I thought the time has come to do something about it. Basically, I had two options:

  • Buy a new keyboard
  • Clean my keyboard

I thought the second option was more of a challenge then just buying a new one.
So, this is what I did.

To give you an idea of how filthy my keyboard actually was, I've made a picture of it:

filthy keyboard

After I took a picture of the layout of my keyboard, I removed all keys from the board. You can imagine that the picture I've taken comes in quite handy when I wanted to place the keys back.

removing keys from keyboard

I've put all the keys in a bucket of water, and cleaned them.
After removing all the keys, the keyboard looked like this:

stripped keyboard

Hmm, this contains a lot of filth as well. I made good use of the vacuum-cleaner to remove most of it.
Then, when all the cleaned keys were dry again, I could put all the keys back to where they belong. The result: a clean keyboard:

clean keyboard

It was quite some work, but, devving with a clean keyboard is much nicer then using a dirty one. ;)

woensdag 8 augustus 2007

C# 3.0: new language features

I've already written a blogpost regarding LINQ and new language features that we may expect in C# 3.0 a while ago.
Since the release of VS.NET 2008 and thereby C# 3.0 is coming closer and closer, I was planning to write an updated blogpost about the new language features in C# 3.0.

However, I've noticed that John Papa has already written an excellent article already concerning the language enhancements in .NET 3.5, so I've decided to just link to that article:

.NET 3.5 Language Enhancements
That's much easier for me, and it saves me some time. :)

zaterdag 4 augustus 2007

XSD Schema for configuration of Log4Net

A few days ago, I was playing around with log4net, the open source framework that allows you to easily log messages in an application.

Since log4net is very configurable, I wanted to have Intellisense in Visual Studio.NET when I'm editing the log4net configuration.
Therefore, I need a schema definition for the log4net XML configuration file so that I can set up the Intellisense for the log4net configuration as I did here for NHibernate.

Unfortunately, it seems that the source of log4net doesn't contain such an XSD.
So, before I take the time and effort to create such an XSD, I wonder if anyone has already made such an XSD for log4net and is willing to share it. :)

vrijdag 27 juli 2007

NHibernate & MS Access: problems with autonumber fields

I was playing around with NHibernate and MS Access a bit the other day, and I ran into an annoying problem.

When I tried to save an object which maps to a table wich has an 'autonumber' field, I received this error:

a different object with the same identifier value was already associated with the session: 0

It looked like NHibernate was unable to retrieve the ID that has been given to the new record in the database.

So, I decided to set up log4net to see if I could find any clue in the logs about the reason for this problem.

As it turned out, it seems that NHibernate was closing the database-connection between the INSERT and the SELECT @@identity statements.

DEBUG NHibernate.SQL - INSERT INTO table ...
DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining
IDbConnection from Driver
DEBUG NHibernate.Impl.BatcherImpl - Closed IDbCommand, open IDbCommands: 0
DEBUG NHibernate.Impl.ConnectionManager - aggressively releasing
database connection
DEBUG NHibernate.Connection.ConnectionProvider - Closing connection
DEBUG NHibernate.Impl.BatcherImpl - Opened new IDbCommand, open IDbCommands: 1
DEBUG NHibernate.Impl.BatcherImpl - Building an IDbCommand object for
the SqlString: select @@identity
DEBUG NHibernate.SQL - select @@identity

After some research in the Hibernate documentation and on the Internet, I discovered that this is caused by the 'connection release mode'.

The default connection release mode seems to release the connection after each SQL statement, so obviously, Access is not able to determine the correct ID of the last inserted record, since the select @@identity command must be executed on the same connection as its related INSERT statement.

Now that we know what caused this problem, it is easy to fix it: just make sure that you do not use the default connection release mode when using NHibernate with MS Access.

To do so, you should specify the connection release mode in your NHibernate configuration file like this:

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="hibernate.connection.release_mode">on_close</property>
</session-factory>
</hibernate-configuration>

More information regarding the different options / settings for the connection-release mode can be found here.

woensdag 18 juli 2007

Counting in SQL Server: SELECT COUNT(*) != SELECT COUNT(columnname)

Today, I've learned something new; or rather, I was being pointed out something that I didn't know about:
It seems that, doing a SELECT COUNT(columnname) does not always give you the same results as doing a SELECT COUNT(*). As it was pointed out to me, doing a SELECT COUNT(columnname) returns the number of rows in the resultset in where the value of the field in 'columnname' is NOT NULL.

This means that, given the following set of data:

idname
1Name1
2NULL
3Anothername

performing this statement:

SELECT COUNT(*) FROM table
gives us 3 as a result, while doing this:
SELECT COUNT(name) FROM table
returns 2 as result.

I really was ignorant to this behaviour, as I do (or did), most of the time a SELECT COUNT(1) FROM table instead, since I thought that this was the most performant option, but this also seems to be not true in some circumstances;
doing a SELECT COUNT(*) enables SQL Server to use indexes in calculating the number of results in a resultset.

For a more thourough article about this, I'd like to refer to this article on SQL Server Central.

Thanks to Peter De Boer for pointing this out